dependency-injection-patterns

Organize ASP.NET Core DI registrations into composable Add* extension methods.

Updated Feb 10, 2026
One-click install
npx skills add https://github.com/tientt010/Dotnet-JiraLite-Microservices --skill dependency-injection-patterns-tientt010
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dependency-injection-patterns
Source: https://github.com/tientt010/Dotnet-JiraLite-Microservices/tree/main/.github/skills/microsoft-extensions-dependency-injection
Command: npx skills add https://github.com/tientt010/Dotnet-JiraLite-Microservices --skill dependency-injection-patterns-tientt010

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill organizes sprawling DI registrations by introducing feature-scoped extension methods, keeping Program.cs/Startup.cs small and maintainable, and enabling reuse of production registrations in tests.

Core Features & Use Cases

  • Extension Method Pattern: Create Add{Feature}Services extensions that group related registrations and return IServiceCollection.
  • With Configuration: Parameterize extension methods to configure options and services together for flexibility.
  • Layered Extensions & Testing Benefits: Compose services across domains and reuse production registrations in tests; easier to override dependencies.
  • Akka.Hosting Integration: Provides patterns for integrating DI with Akka.NET actors (where applicable).

Quick Start

Create feature-specific Add* extension methods and wire them into your Program.cs to compose the DI configuration.

Frequently Asked Questions about dependency-injection-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I organize sprawling dependency injection registrations in ASP.NET Core?

Create feature-scoped Add{Feature}Services extension methods that group related services and return IServiceCollection, keeping your ASP.NET Core Program.cs or Startup.cs clean and maintainable.

Can I reuse production DI registrations in tests with Microsoft.Extensions.DependencyInjection?

Yes, you can reuse production DI registrations in tests by composing services through layered extension methods, which makes it easier to override specific dependencies during testing without rewriting the service collection.

What is the best way to parameterize dependency injection extensions with configuration in dotnet?

The best way to parameterize DI extensions is by passing configuration parameters into your Add{Feature}Services extension methods, allowing you to configure options and services together for greater flexibility.

Does this dependency injection pattern work with Akka.NET actors?

Yes, the dependency injection patterns support Akka.Hosting integration, providing specific patterns for wiring DI with Akka.NET actors when applicable to your application architecture.

When should I use composable Add* methods for service collection registration?

Use composable Add* methods for service collection registration when your application spans multiple domains, requires layering of services, or needs to cleanly separate feature registrations to improve maintainability.