
Golang Dependency Injection
If you're building Go services with more than a handful of dependencies, this walks you through the entire DI spectrum: when manual constructor injection is enough, when to reach for a library, and how to pick between Wire's codegen, Fx's reflection magic, or samber/do's generics approach. The decision table alone is worth it. What I like: it doesn't just show you library syntax, it teaches you to spot global variable anti-patterns and service locator smells, then gives you a three agent refactoring strategy to fix them. Treats DI as an architecture question, not just a framework choice. Written by the author of samber/do but stays honest about the tradeoffs.
- skills.sh installs
- 41K
- GitHub stars
- 3.8K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add samber/cc-skills-golang --skill golang-dependency-injection --agent claude-codeInstalls into .claude/skills of the current project.
Files
Persona: You are a Go software architect. You guide teams toward testable, loosely coupled designs — you choose the simplest DI approach that solves the problem, and you never over-engineer.
Orchestration mode: Fan out the three sub-agents described in Refactor mode (global/init discovery, concrete-dependency mapping, service-locator detection) when refactoring a large coupled codebase toward dependency injection, and consolidate into one migration plan. On Claude Code, use ultracode to opt into multi-agent orchestration explicitly.
Modes:
- Design mode (new project, new service, or adding a service to an existing DI setup): assess the existing dependency graph and lifecycle needs; recommend manual injection or a library from the decision table; then generate the wiring code.
- Refactor mode (existing coupled code): use up to 3 parallel sub-agents — Agent 1 identifies global variables and
init()service setup, Agent 2 maps concrete type dependencies that should become interfaces, Agent 3 locates service-locator anti-patterns (container passed as argument) — then consolidate findings and propose a migration plan.
Sponsors
Details
- Repository
- github.com/samber/cc-skills-golang
- Categories
- Documentation, Code Review & Quality, Go
- First seen
- Apr 16, 2026
More from samber/cc-skills-golang
All 47- Golang Popular Libraries41K
- Golang Stretchr Testify40.9K
- Golang Continuous Integration40.9K
- Golang Grpc40.7K
- Golang Samber Lo40K
- Golang Stay Updated40K
- Golang Samber Do39.8K
- Golang Samber Slog39.8K
- Golang Samber Oops39.7K
- Golang Samber Mo39.7K
- Golang Samber Hot39.7K
- Golang Samber Ro39.6K
- Golang Spf13 Cobra38.6K
- Golang Swagger38.6K
- Golang Graphql38.5K
- Golang Google Wire38.3K
- Golang Spf13 Viper38.3K
- Golang Uber Fx38.1K
- Golang Uber Dig38K
- Golang How To37.9K
- Golang Linter26.5K
- Golang Pkg Go Dev13.3K
- Golang Refactoring12.9K
- Golang Gopls12.5K