dependency-injection-patterns

Community

Efficient DI with composable Add* methods.

AuthorAaronontheweb
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill helps teams organize and reuse dependency injection registrations in ASP.NET Core applications by encapsulating related registrations inside small composable extension methods, keeping Program.cs clean and tests easily configurable.

Core Features & Use Cases

  • Encapsulated Add*Methods: Create extension methods like AddUserServices(), AddOrderServices(), and AddEmailServices() to group related registrations and improve readability.
  • Test-time configurability: Allow tests to override specific services while reusing production registrations, improving maintainability and resilience.
  • Lifetime and configuration cohesion: Centralize configuration and lifetimes in one place, reducing duplication and ensuring consistent behavior across environments.
  • Use Case: In a large web app, split registrations into modular areas (Users, Orders, Payments) and compose them in the top-level AppServiceCollectionExtensions.

Quick Start

Create extension methods on IServiceCollection (e.g., AddUserServices, AddOrderServices) that register related services and return IServiceCollection. Then, in your Program.cs, call services.AddUserServices().AddOrderServices() as part of app startup.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: dependency-injection-patterns
Download link: https://github.com/Aaronontheweb/dotnet-skills/archive/main.zip#dependency-injection-patterns

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.