Controls ABP's advanced dependency injection: conventional exposure, lifetime rules, service replacement, registration callbacks, lazy resolution, keyed services, and decoration while preserving lifetimes.
Ships in abp-module-development. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
ABP builds on IServiceCollection: conventional registrars choose a lifetime and exposed service types, while attributes and registration callbacks let a module change those choices. Use constructor injection for normal dependencies; use the advanced mechanisms here only when exposure, replacement, late resolution, keys, activation hooks, or decoration requires them.
IObjectAccessor<T>.ITransientDependency, IScopedDependency, and ISingletonDependency select the lifetime. Without an explicit exposure provider, ABP exposes the implementation type itself plus matching default interfaces. A default interface is one whose name matches the implementation suffix, ignoring an initial I and generic arity.
public interface IInvoiceCalculator
{
decimal Calculate(decimal netAmount);
}
public class InvoiceCalculator : IInvoiceCalculator, ITransientDependency
{
public decimal Calculate(decimal netAmount) => netAmount;
}
This exposes InvoiceCalculator and IInvoiceCalculator. An unrelated implemented interface is not a default service unless explicitly exposed.
[ExposeServices][ExposeServices(typeof(IInvoiceCalculator))]
public class InvoiceCalculator : IInvoiceCalculator, ITransientDependency
{
public decimal Calculate(decimal netAmount) => netAmount;
}
An explicit [ExposeServices] replaces default exposure unless IncludeDefaults = true; set IncludeSelf = true when the concrete class must also resolve. Multiple attributes are allowed.
[Dependency] has Lifetime, TryRegister, and ReplaceServices. The conventional registrar applies them in this order: replace, try-add, otherwise add.
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IInvoiceCalculator))]
public class DiscountInvoiceCalculator : IInvoiceCalculator, ITransientDependency
{
public decimal Calculate(decimal netAmount) => netAmount * 0.9m;
}
The imperative equivalent is useful when the replacement is selected by configuration:
context.Services.Replace(
ServiceDescriptor.Transient<IInvoiceCalculator, DiscountInvoiceCalculator>());
Match the old lifetime unless there is a reviewed reason to change it. Replace replaces the first descriptor with the same service type; inspect the collection when multiple registrations are intentional.
Install callbacks in PreConfigureServices so they observe conventionally scanned services.
public override void PreConfigureServices(ServiceConfigurationContext context)
{
context.Services.OnExposing(exposingContext =>
{
if (typeof(IInternalService).IsAssignableFrom(exposingContext.ImplementationType))
{
exposingContext.ExposedTypes.RemoveAll(
service => service.ServiceType == exposingContext.ImplementationType);
}
});
context.Services.OnRegistered(registrationContext =>
{
// Inspect ImplementationType and ServiceKey here.
// Add IAbpInterceptor types only when method interception is intended.
});
}
OnExposing runs while conventional exposure is being built; its mutable ExposedTypes contains ServiceIdentifier entries.OnRegistered receives ImplementationType, ServiceKey, and the interceptor type list. Use use-interceptors-and-dynamic-proxy before adding interceptors.OnActivated(descriptor, callback) is descriptor-specific. With the Autofac integration, its callback receives the created Instance; it observes activation but does not replace that instance.ABP has no ILazyServiceProvider type. ABP base classes expose a property named LazyServiceProvider whose type is IAbpLazyServiceProvider:
var clock = LazyServiceProvider.LazyGetRequiredService<IClock>();
IAbpLazyServiceProvider remains for compatibility; its own source recommends ITransientCachedServiceProvider for new code. Both are cached service providers: the first resolution is stored, including transient services, for that provider instance.
public class ReportBuilder : ITransientDependency
{
private readonly ITransientCachedServiceProvider _services;
public ReportBuilder(ITransientCachedServiceProvider services)
{
_services = services;
}
public IOptionalFormatter? GetFormatter()
{
return _services.GetService<IOptionalFormatter>();
}
}
Prefer constructor injection when the dependency is required. Lazy lookup hides dependencies and can defer lifetime/cycle failures until runtime.
A transient service is built again on every path that reaches it, together with its own constructor dependencies. When application services, managers, and registries inject each other, one request can build the same services many times over. Under load that can show up as high allocation and garbage-collection pauses that slow every endpoint at once, rather than as one slow query.
UseAutofac()), a Lazy<T> constructor parameter builds T on the first .Value, and later reads on the same holder reuse that instance. For a transient T, another holder builds its own; a scoped or singleton T keeps its registered sharing.IEnumerable<T> has already built every implementation before the constructor runs; enumerating it later saves nothing. Inject Lazy<IEnumerable<T>> when the collection is only needed on some paths.public class InvoiceAppService : ApplicationService, IInvoiceAppService
{
private readonly IRepository<Invoice, Guid> _invoices;
private readonly Lazy<IInvoicePdfRenderer> _pdfRenderer; // only ExportAsync needs it
public InvoiceAppService(IRepository<Invoice, Guid> invoices, Lazy<IInvoicePdfRenderer> pdfRenderer)
{
_invoices = invoices;
_pdfRenderer = pdfRenderer;
}
public async Task<byte[]> ExportAsync(Guid id)
{
return await _pdfRenderer.Value.RenderAsync(await _invoices.GetAsync(id));
}
}
A lazy dependency resolves from the scope that built its holder. Read it while that scope is still alive; see manage-units-of-work for callbacks that run after commit.
IObjectAccessor<T>var accessor = context.Services.AddObjectAccessor(new StartupState());
accessor.Value.IsConfigured = true;
AddObjectAccessor inserts the same ObjectAccessor<T> instance as singleton registrations for both ObjectAccessor<T> and IObjectAccessor<T>. It throws if one was already registered; TryAddObjectAccessor<T>() returns the existing accessor instead. During configuration, GetObject<T>() / GetObjectOrNull<T>() retrieves a previously registered accessor value from the service collection.
ABP supports .NET keyed services in conventional registration:
[ExposeKeyedService<IInvoiceCalculator>("standard")]
public class StandardInvoiceCalculator : IInvoiceCalculator, ITransientDependency
{
public decimal Calculate(decimal netAmount) => netAmount;
}
public class CheckoutService
{
private readonly IInvoiceCalculator _calculator;
public CheckoutService(
[FromKeyedServices("standard")] IInvoiceCalculator calculator)
{
_calculator = calculator;
}
}
Resolve imperatively with GetRequiredKeyedService<T>(key). A string key is the named-service pattern in this version; there is no separate ABP INamedServiceProvider abstraction in the verified dependency-injection sources. If a class has only [ExposeKeyedService] and no [ExposeServices], ABP does not add its default unkeyed services.
ABP core provides no general Decorate<T> extension. The descriptor-wrapping pattern below preserves only the original lifetime value — it does not preserve the original ABP registration. The inner service is rebuilt with ActivatorUtilities.CreateInstance, which bypasses the Autofac/ABP registration pipeline, so that inner instance loses ABP's dynamic-proxy interceptors (validation, unit of work, authorization, auditing, feature checks), convention-based property injection, and OnActivated callbacks. It also breaks the shared-instance identity when the type is exposed as both its concrete type and its interface (ConventionalRegistrarBase normally redirects those to one instance).
So use this pattern only for a simple implementation-type service that does not rely on any of those ABP behaviors. When you need to decorate a service that keeps ABP interception/property injection, use container-specific decoration (Autofac's RegisterDecorator) instead:
var descriptor = context.Services.LastOrDefault(
service => service.ServiceType == typeof(IInvoiceCalculator));
if (descriptor?.ImplementationType == null)
{
throw new InvalidOperationException(
"IInvoiceCalculator must use an implementation-type registration.");
}
context.Services.Replace(ServiceDescriptor.Describe(
typeof(IInvoiceCalculator),
serviceProvider => new LoggingInvoiceCalculator(
(IInvoiceCalculator)ActivatorUtilities.CreateInstance(
serviceProvider,
descriptor.ImplementationType)),
descriptor.Lifetime));
Do not apply this exact pattern to factory, instance, or keyed descriptors; their implementation data lives in different ServiceDescriptor properties.
IServiceCollection after configuration to confirm replacement count and lifetime.Lazy<T> dependency, count constructions in a test: resolving the holder and calling methods that do not need it build nothing, and the first method that needs it builds it once.[ExposeServices] for unrelated interfaces.IncludeSelf — explicit exposure can make the concrete class unresolvable.IAbpLazyServiceProvider as a fresh resolve each time — it caches resolved services, including transients.Lazy<T>.IEnumerable<T> to defer construction — the container builds every element when it builds the holder; use Lazy<IEnumerable<T>>.[ExposeServices] explicitly if both forms are required.ImplementationType — branch by descriptor shape or use container-specific decoration.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
13 skills in this plugin
/application-servicesWrites or reviews an ABP application service — the DTO-taking, DTO-returning boundary between the domain and the presentation/API layer. USE FOR: implementing IApplicationService/ApplicationService for non-CRUD use cases, using AbstractKeyCrudAppService for composite or non-standard keys, and unit-of-work basics. DO NOT USE FOR: exposing application services as auto/conventional API controllers, routes, verbs or [RemoteService] (use expose-http-apis); a complete standard-key CrudAppService workflow (use build-crud-application-services); detailed object-to-DTO mapping mechanics/profiles (use map-objects-and-dtos); DTO validation attributes and business exceptions (use handle-validation-and-errors); permission definitions and authorization policy (use permissions-and-authorization); the overall layered project structure (use layered-architecture).
/build-crud-application-servicesBuilds or reviews a complete ABP CRUD application-service contract and implementation with the CrudAppService APIs. USE FOR: choosing ICrudAppService/CrudAppService generic overloads, separating get/list/create/update DTOs, wiring IRepository, object mappings and five policy properties, adding list filters without breaking count/sort/page order, and validating all five CRUD operations. DO NOT USE FOR: a non-CRUD use case or general ApplicationService orchestration (use application-services); composite or non-standard keys with AbstractKeyCrudAppService (use application-services); mapping-provider configuration details (use map-objects-and-dtos); permission definitions (use permissions-and-authorization); optimistic concurrency (use handle-optimistic-concurrency); HTTP endpoint conventions (use expose-http-apis); integration-test infrastructure (use test-abp-applications).
/create-plugin-modulesLoad ABP modules at runtime as plug-ins instead of referencing their assemblies directly, via AbpApplicationCreationOptions.PlugInSources. USE FOR: configuring options.PlugInSources with AddFolder / AddFiles / AddTypes (or a custom IPlugInSource), building a class-library plug-in module deriving from AbpModule, wiring MVC/Razor Pages plug-ins with AssemblyPart / CompiledRazorAssemblyPart application parts. DO NOT USE FOR: defining ordinary referenced modules, [DependsOn], or DI registration (use define-application-modules); overall solution layering (use layered-architecture); building the actual UI pages inside a plug-in (use blazor-ui, mvc-razor-ui, or angular-ui).
/customize-application-modulesExtends or customizes a pre-built ABP module (Identity, Account, etc.) referenced as NuGet packages without editing its source. USE FOR: adding extra entity/DTO properties via the module extension system, mapping extra properties to real EF Core columns, replacing/overriding module services, repositories, domain services, and controllers, overriding module UI. DO NOT USE FOR: defining your own new application module from scratch (use define-application-modules); modeling your own aggregates/entities (use model-domain-aggregates); general object-to-DTO mapping mechanics (use map-objects-and-dtos).
/define-application-modulesDefine and wire up an ABP module: the AbpModule class, [DependsOn] dependencies, service registration, options configuration, lifecycle hooks, and conventional DI. USE FOR: creating an AbpModule class, declaring [DependsOn] dependencies, registering services in ConfigureServices / PreConfigureServices / PostConfigureServices, configuring options with Configure for an options class, adding startup/shutdown lifecycle hooks (OnApplicationInitialization / OnApplicationShutdown), relying on ITransientDependency/IScopedDependency/ISingletonDependency conventional DI. DO NOT USE FOR: deciding which project a class belongs in or the overall solution layering (use layered-architecture); modeling entities/aggregates/value objects/domain services (use model-domain-aggregates); loading modules at runtime as plug-ins (use create-plugin-modules); writing application service implementations (use application-services).
/extend-objects-with-extra-propertiesAdd framework-level dynamic properties to any ABP entity or DTO that implements IHasExtraProperties. USE FOR: IHasExtraProperties and ExtraPropertyDictionary; ExtensibleObject and extensible aggregate roots/DTOs; ObjectExtensionManager definitions; GetProperty/SetProperty; EF Core JSON or dedicated-column persistence; MongoDB extra elements; mapping extra properties between entities and DTOs. DO NOT USE FOR: extending an installed Identity, Account, or other pre-built module through its module-specific extension configurator (use customize-application-modules); ordinary object mapping without extra properties (use map-objects-and-dtos); designing aggregate invariants and entity relationships (use model-domain-aggregates).
/abp-module-development:register-and-replace-servicesfrom abp-module-development
npx claudepluginhub abpframework/abp-skills --plugin abp-module-developmentOther plugins' skills for the same job