aaronontheweb avatar

Dependency Injection Patterns

Aaron Stannard's skill tackles the organizational mess that happens when your ASP.NET Core service registrations pile up in Program.cs. It shows you how to use extension methods to group related services together, making configurations reusable across production and test environments. The advanced patterns file covers conditional registration, factory patterns, keyed services, and even Akka.NET actor scope management if you're working with that. With over 300 installs and nearly 1,000 GitHub stars, it's clearly solving a pain point for .NET developers who want cleaner dependency injection setups without fighting Microsoft.Extensions.DependencyInjection.

skills.sh installs
703
GitHub stars
1.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add aaronontheweb/dotnet-skills --skill dependency-injection-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

Dependency Injection Patterns

When to Use This Skill

Use this skill when:

  • Organizing service registrations in ASP.NET Core applications
  • Avoiding massive Program.cs/Startup.cs files with hundreds of registrations
  • Making service configuration reusable between production and tests
  • Designing libraries that integrate with Microsoft.Extensions.DependencyInjection

Reference Files

  • advanced-patterns.md: Testing with DI extensions, Akka.NET actor scope management, conditional/factory/keyed registration patterns

The Problem

Without organization, Program.cs becomes unmanageable:

// BAD: 200+ lines of unorganized registrations
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddScoped<IUserRepository, UserRepository>();
builder.Services.AddScoped<IOrderRepository, OrderRepository>();
builder.Services.AddScoped<IProductRepository, ProductRepository>();
builder.Services.AddScoped<IUserService, UserService>();
// ... 150 more lines ...

Problems: hard to find related registrations, no clear boundaries, can't reuse in tests, merge conflicts.


The Solution: Extension Method Composition

Sponsors

Details

Repository
github.com/aaronontheweb/dotnet-skills
Category
.NET & C#
First seen
Jun 3, 2026

More from aaronontheweb/dotnet-skills

All 34

Recommended

More .NET & C#
1aaronontheweb avatardatabase-performanceaaronontheweb/dotnet-skillsDatabase access patterns for performance. Separate read/write models, avoid N+1 queries, use AsNoTracking, apply row limits, and never do application-side joins700skills.sh installs
2github avatarmsstore-cligithub/awesome-copilotMicrosoft Store Developer CLI (msstore) for publishing Windows applications to the Microsoft Store. Use when asked to configure Store credentials, list Store ap7Kskills.sh installs
3affaan-m avatarwindows-desktop-e2eaffaan-m/eccE2E testing for Windows native desktop apps (WPF, WinForms, Win32/MFC, Qt) using pywinauto and Windows UI Automation.5.7Kskills.sh installs
4dotnet avatarbinlog-failure-analysisdotnet/skillsAnalyze MSBuild binary logs to diagnose build failures. USE FOR: build errors that are unclear from console output, diagnosing cascading failures across multi-p4.3Kskills.sh installs
5dotnet avatarbuild-parallelismdotnet/skillsDiagnose and fix under-parallelized MSBuild builds. USE WHEN a multi-project solution build is slower than expected, doesn't speed up when you add cores, pegs a4.2Kskills.sh installs
6dotnet avatarplatform-detectiondotnet/skillsReference data for detecting the test platform (VSTest vs Microsoft.Testing.Platform) and test framework (MSTest, xUnit, NUnit, TUnit) from project files. DO NO4.2Kskills.sh installs