Agent skill
Dependency Injection Setup
Add new services to DIContainer, create protocol-based implementations, set up singletons or factories for Leavn app dependency injection
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/dependency-injection-setup
SKILL.md
Dependency Injection Setup
Instructions
Add new services to Leavn's DIContainer:
-
Create service protocol:
swift// Services/MyDomain/MyServiceProtocol.swift public protocol MyServiceProtocol { func doSomething() async throws -> Result } -
Create implementation:
swift// Services/MyDomain/MyServiceLive.swift public final class MyServiceLive: MyServiceProtocol { public init() { } public func doSomething() async throws -> Result { // Implementation } } -
Register in DIContainer:
swift// For singletons (stateful services): private lazy var _myService = MyServiceLive() var myService: MyServiceProtocol { _myService } // For factories (stateless services): var myService: MyServiceProtocol { MyServiceLive() } -
Use in ViewModels:
swiftlet service = DIContainer.shared.myService
Use this skill when: Creating new service, adding dependency, setting up DI, refactoring to protocol-oriented design
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?