create-di-extension

Generates dependency injection extension classes for bounded contexts in ASP.NET Core applications.

Updated Nov 19, 2020
One-click install
npx skills add https://github.com/kwojtasinski-repo/ECommerceApp --skill create-di-extension-kwojtasinski-repo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-di-extension
Source: https://github.com/kwojtasinski-repo/ECommerceApp/tree/main/.github/skills/create-di-extension
Command: npx skills add https://github.com/kwojtasinski-repo/ECommerceApp --skill create-di-extension-kwojtasinski-repo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Manually writing DI registration extension classes for each bounded context is repetitive and error-prone, especially when keeping Application and Infrastructure layers consistent with project conventions. This Skill scaffolds the correct extension classes following the project's internal static extension method pattern. ## Core Features & Use Cases - Application-layer scaffolding: Generates an extension class registering services, message handlers, and scheduled tasks for a bounded context. - Infrastructure-layer scaffolding: Generates an extension class registering the DbContext, migrator, repositories, and adapters with EF Core and SQL Server. - Wiring guidance: Provides manual steps to hook the new extensions into the central DependencyInjection.cs files and verify with a build. - Use Case: When adding a new Payments bounded context, run the skill with 'both' mode to generate PaymentsExtensions.cs and PaymentsInfraExtensions.cs, then wire them into AddApplication() and AddInfrastructure(). ## Quick Start Ask the AI to create DI extension classes for the Payments bounded context in both application and infrastructure modes.

Frequently Asked Questions about create-di-extension

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

FAQPage Schema
How do I create a DI extension class for a new bounded context in ASP.NET Core?

Invoke the skill with the bounded context name and a mode: application, infrastructure, or both. It generates an internal static extension class with scoped IServiceCollection registrations, which you then call from the central DependencyInjection.cs files.

What is the difference between application and infrastructure DI registration modes?

Application mode registers services, message handlers, and scheduled tasks. Infrastructure mode registers the EF Core DbContext with SQL Server, a DbContextMigrator, repositories, and cross-context adapters. Use 'both' to generate the two files together.

Does this work with Entity Framework Core and SQL Server?

Yes. The infrastructure template calls AddDbContext with UseSqlServer and reads the DefaultConnection string from IConfiguration. All registrations use Scoped lifetime to match the EF Core DbContext lifetime.

Why are all services registered as Scoped instead of Singleton or Transient?

Scoped lifetime matches the EF Core DbContext lifetime, which is the project's convention. Registering repositories or services as Singleton would cause captive-dependency issues with the scoped DbContext.

What manual steps are needed after generating the DI extension classes?

Call Add{Bc}Services() from the Application project's DependencyInjection.cs and Add{Bc}Infrastructure(configuration) from the Infrastructure project's DependencyInjection.cs. Then verify everything compiles with dotnet build.