Dependency Injection
Designing loosely coupled code through dependency injection, reducing testability barriers and hidden dependencies.
Install
/plugin marketplace add sethdford/claude-skillsThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add sethdford/claude-skills --skill dependency-injectiongit clone --depth 1 https://github.com/sethdford/claude-skills.git /tmp/claude-skills
mkdir -p ~/.claude/skills
cp -r /tmp/claude-skills/engineer/code-quality/skills/dependency-injection ~/.claude/skills/dependency-injectionPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Dependency Injection Fundamental pattern for loose coupling and testability. ## Context You are helping the engineer apply dependency injection. If code is provided, identify tightly coupled dependencies and suggest injection patterns. DI is not optional for testable, maintainable code. ## Domain Context - **Loose Coupling**: Dependencies are explicit parameters, not hidden inside the class - **Testability**: You can inject mocks, stubs, or fakes for testing without modification - **Inversion of Control**: Class doesn't create its dependencies; they're provided - **Three Patterns**: Constructor Injection (preferred), Setter Injection, Interface Injection - **Container**: Optional; frameworks like Spring, Guice manage dependency graphs ## Instructions 1. **Identify Hard Dependencies**: What does the class create or reference? httpClient, database, logger? 2. **Declare Dependencies**: Add constructor parameters for each dependency (prefer constructor over setter) 3. **Make Testable**: Can you pass in a mock? If not, you're still too tightly coupled 4. **Use Interfaces**: Depend on abstractions (Logger), not concrete implementations (ConsoleLogger) 5. **Avoid Service Locator**: Don't pass in a container or factory; too implicit 6. **Document Contracts**: Make it clear which dependencies are required vs. optional 7. **Keep Constructors Simple**: Only assign fields; avoid logic or other dependencies
Details
- Skill name
dependency-injection- Repository
- sethdford/claude-skills
- Path
engineer/code-quality/skills/dependency-injection/SKILL.md- License
- MIT
- Repo updated
- 11 March 2026
FAQ
What does the Dependency Injection skill do?
Designing loosely coupled code through dependency injection, reducing testability barriers and hidden dependencies.
How do I install the Dependency Injection skill?
Claude Code plugin: /plugin marketplace add sethdford/claude-skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Dependency Injection popular?
It lives in sethdford/claude-skills, which has 48 GitHub stars and 10 forks.
Related skills
A B Test Design
48sethdford/claude-skills
Design rigorous A/B tests with hypotheses, variants, metrics, and sample size calculations.
A B Test Design Pm
48sethdford/claude-skills
Analytics and experimentation skill for product managers.
Abuse Case Design
48sethdford/claude-skills
Design abuse cases (negative use cases) showing how attackers misuse system features. Use when identifying attacks that exploit intended functionality or business logic flaws.
Design Critique
48sethdford/claude-skills
Facilitate structured design critiques with clear feedback frameworks and actionable outcomes.
Containment Strategy
48sethdford/claude-skills
Develop containment strategies to isolate compromised systems, prevent lateral movement, and stop ongoing attacks.
Event Driven Architecture
48sethdford/claude-skills
Design systems that communicate through events instead of direct service calls. Use when building loosely-coupled, scalable, and resilient architectures.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.