
Description
This agent skill guides an AI coding agent through dependency injection in .NET 10. It covers service lifetimes, keyed services, the decorator and factory patterns, and common pitfalls. Constructor injection is the default, made tidy with primary constructors, and the agent avoids service locators and property injection. Lifetimes must be matched carefully: a singleton should never depend on a scoped or transient service, which the skill calls the most common DI bug. Services are registered and resolved by interface, for example AddScoped<IOrderService, OrderService>() rather than the concrete type. For choosing between several implementations of one interface, it prefers the keyed services available since .NET 8 over hand-written factories. From the dotnet-claude-kit collection; install with: npx skills add https://github.com/codewithmukesh/dotnet-claude-kit --skill dependency-injection…
Highlights
- Constructor injection with primary constructors
- Rules for matching service lifetimes
- Keyed services for strategy-style selection
- Decorator and factory patterns
Ratings & Reviews
No ratings yet
Be the first to rate dependency-injection.
People also visit
dependency-injection FAQ
What does the dependency-injection skill cover?
Service lifetimes, keyed services, the decorator pattern, the factory pattern and common DI pitfalls in .NET 10.
What is the most common DI bug it warns about?
A singleton depending on a scoped or transient service. The skill says lifetimes must be matched carefully.
When should keyed services be used?
When you need to register and resolve multiple implementations of the same interface; they replace manual factory patterns in .NET 8+.
How do I install it?
Run: npx skills add https://github.com/codewithmukesh/dotnet-claude-kit --skill dependency-injection
What were the security audit results?
On skills.sh: Gen Agent Trust Hub: Pass. Socket: Pass. Snyk: Pass.
What are the best dependency-injection alternatives?
Popular alternatives to dependency-injection include dotnet-patterns, dotnet-backend-patterns and configuration. See all dependency-injection alternatives









