Claude-skill-registry Dependency Injection Setup
Add new services to DIContainer, create protocol-based implementations, set up singletons or factories for Leavn app dependency injection
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/dependency-injection-setup" ~/.claude/skills/majiayu000-claude-skill-registry-dependency-injection-setup && rm -rf "$T"
manifest:
skills/data/dependency-injection-setup/SKILL.mdsource content
Dependency Injection Setup
Instructions
Add new services to Leavn's DIContainer:
-
Create service protocol:
// Services/MyDomain/MyServiceProtocol.swift public protocol MyServiceProtocol { func doSomething() async throws -> Result } -
Create implementation:
// Services/MyDomain/MyServiceLive.swift public final class MyServiceLive: MyServiceProtocol { public init() { } public func doSomething() async throws -> Result { // Implementation } } -
Register in DIContainer:
// For singletons (stateful services): private lazy var _myService = MyServiceLive() var myService: MyServiceProtocol { _myService } // For factories (stateless services): var myService: MyServiceProtocol { MyServiceLive() } -
Use in ViewModels:
let service = DIContainer.shared.myService
Use this skill when: Creating new service, adding dependency, setting up DI, refactoring to protocol-oriented design