Skills for Real Engineers. Straight from my .agents directory.
dependency-injection-patterns
Agent skill fromAaronontheweb/dotnet-skills
Organize DI registrations using IServiceCollection extension methods. Group related services into composable Add* methods for clean Program.cs and reusable configuration in tests.
How to install dependency-injection-patterns
npx skills add Aaronontheweb/dotnet-skills# or add only this skill to Claude Code: copy the folder
skills/microsoft-extensions-dependency-injection/
# into
~/.claude/skills/microsoft-extensions-dependency-injection/ (all projects)
.claude/skills/microsoft-extensions-dependency-injection/ (one project)
1# Dependency Injection Patterns23## When to Use This Skill45Use this skill when:6- Organizing service registrations in ASP.NET Core applications7- Avoiding massive Program.cs/Startup.cs files with hundreds of registrations8- Making service configuration reusable between production and tests9- Designing libraries that integrate with Microsoft.Extensions.DependencyInjection1011## Reference Files1213- [advanced-patterns.md](advanced-patterns.md): Testing with DI extensions, Akka.NET actor scope management, conditional/factory/keyed registration patterns1415---1617## The Problem1819Without organization, Program.cs becomes unmanageable:2021```csharp22// BAD: 200+ lines of unorganized registrations23var builder = WebApplication.CreateBuilder(args);2425builder.Services.AddScoped<IUserRepository, UserRepository>();26builder.Services.AddScoped<IOrderRepository, OrderRepository>();27builder.Services.AddScoped<IProductRepository, ProductRepository>();28builder.Services.AddScoped<IUserService, UserService>();29// ... 150 more lines ...30```3132Problems: hard to find related registrations, no clear boundaries, can't reuse in tests, merge conflicts.3334---3536## The Solution: Extension Method Composition3738Group related registrations into extension methods:3940```csharp41// GOOD: Clean, composable Program.cs42var builder = WebApplication.CreateBuilder(args);4344builder.Services45 .AddUserServices()46 .AddOrderServices()47 .AddEmailServices()48 .AddPaymentServices()49 .AddValidators();5051var app = builder.Build();52…
Excerpt shown under the repository's MIT license.
More skills in dotnet-skills
Similar skill repositories
An agentic skills framework & software development methodology that works.
Public repository for Agent Skills
Makes your AI agent think like the laziest senior dev in the room. The best code is the code you never wrote.
Production-grade engineering skills for AI coding agents.
The open-source app everyone uses to manage agents at work
