cck-dependency-injection

Diagnose dependency injection lifetime and registration issues in .NET applications.

2|Updated Mar 31, 2026
One-click install
npx skills add https://github.com/s205109/AHKFlowApp --skill cck-dependency-injection
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cck-dependency-injection
Source: https://github.com/s205109/AHKFlowApp/tree/main/.claude/skills/cck-dependency-injection
Command: npx skills add https://github.com/s205109/AHKFlowApp --skill cck-dependency-injection

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Dependency injection misconfiguration causes subtle runtime failures, memory leaks, and stale data when service lifetimes and registrations are incorrect. This Skill helps teams diagnose lifetime mismatches, avoid captive dependencies, and choose correct registration and composition patterns so services behave reliably in production.

Core Features & Use Cases

  • Lifetime guidance: Match singleton, scoped, and transient lifetimes to avoid captured scoped services and memory leaks.
  • Composition patterns: Recommendations for keyed services, decorator pattern, factory delegates, and Scrutor convention-based registration to select implementations safely.
  • Configuration and options: Best practices for strongly-typed options, validate-on-start, and injecting configuration without leaking mutable state.
  • Use Case: Fix a bug where a singleton cache captures a scoped DbContext, implement multiple notification channels using keyed services, or refactor service registrations to follow convention-based scans.

Quick Start

Ask the AI to review your IServiceCollection registrations and identify lifetime mismatches, captive dependencies, and suggested refactorings.

Frequently Asked Questions about cck-dependency-injection

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

FAQPage Schema
How do I fix a captive dependency bug in .NET dependency injection?

To fix a captive dependency in .NET dependency injection, resolve lifetime mismatches where a singleton service captures a scoped service. Refactoring service registrations ensures correct lifetimes and prevents memory leaks.

What is the best way to register decorators with Scrutor in .NET?

The best way to register decorators with Scrutor in .NET is using convention-based registration to safely select implementations. This composition pattern ensures correct service lifetimes and prevents stale data in production.

How do I use keyed services to select implementations in .NET 8?

You can use keyed services in .NET 8 to select specific implementations during dependency injection registration. This composition pattern allows safe resolution of multiple service variants without causing lifetime conflicts.

Why does my .NET singleton cache capture a scoped DbContext and leak memory?

A singleton cache captures a scoped DbContext because dependency injection lifetime mismatches force the scoped service to live as long as the singleton. Correcting service registrations prevents this captive dependency and memory leak.

Can I use factory delegates for dependency injection in .NET backend services?

Yes, you can use factory delegates for dependency injection in .NET backend services to safely construct implementations. This pattern supports correct service lifetimes and prevents captive dependency anti-patterns.

Does this dependency injection guidance apply to .NET 10 applications?

Yes, this dependency injection guidance applies to backend services and libraries targeting .NET 8 through .NET 10. It ensures correct service lifetimes and safe registration patterns across these framework versions.