From ioc-dev
go-kid/ioc framework dependency injection debugging guide. ALWAYS use this skill when the user encounters ANY errors, failures, or issues with go-kid/ioc, especially: injection errors, component not found, circular dependency, startup panics, wire tag not working, nil dependencies, missing components, constructor parameter resolution failures, config values not injected, or post-processor not applied. Also use for debugging questions like 'why is my component nil', 'injection failed error', 'component X not found', 'how to enable debug mode', 'how to trace dependency resolution', 'my IoC app won't start', 'panic in ioc.Run', 'circular reference error', or ANY go-kid/ioc troubleshooting and error diagnosis. Triggers on: error, failed, panic, not found, nil, not working, missing, debug, debugging, trace, app.LogTrace, RunDebug, injection failed, component not found, circular dependency, dependency resolution failed, wire tag not working, required property empty, constructor parameter not resolved.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ioc-dev:ioc-debugThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Guide for diagnosing and fixing dependency injection issues in the go-kid/ioc framework.
Guide for diagnosing and fixing dependency injection issues in the go-kid/ioc framework.
Add app.LogTrace to the Run call to see the full container lifecycle:
ioc.Run(app.LogTrace, ...)
// or in tests
ioc.RunTest(t, app.LogTrace, app.SetComponents(...))
Trace output shows: component registration, definition scanning, dependency resolution order, and injection details.
The framework provides dependency chain formatting in errors:
dependency resolution failed:
ComponentA
-> ComponentB
-> ComponentC (not found or creation failed)
This trace shows the full dependency path that led to the failure.
Cause: A dependency is declared via wire tag but the component is not registered.
Checklist:
ioc.Register() or app.SetComponents()&MyService{}, not MyService{})ioc.Register(NewService))Cause: Dependency fields must be exported (start with uppercase).
// WRONG - field is unexported, silently ignored
type App struct {
service *Service `wire:""` // lowercase 's' — won't be injected
}
// CORRECT
type App struct {
Service *Service `wire:""` // uppercase 'S'
}
Cause: Multiple implementations registered; selection order unclear.
Solutions (in priority order):
WirePrimary on the preferred component: func (s *Preferred) Primary() {}wire:",qualifier=specific-name" + implement Qualifier() stringwire:"component-name" + implement Naming() stringCause: Component A depends on B which depends on A (directly or transitively).
The framework supports circular references for singletons via early singleton exposure (three-level cache). If it still fails:
SmartInstantiationAwareBeanPostProcessor is wrapping a component involved in the cycle — the wrapped version might not matchCause 1: Trying to directly inject or access configure.Configure object.
// ❌ WRONG - Don't inject configure directly
type Service struct {
Config configure.Configure `wire:""` // This is wrong!
}
// ❌ WRONG - Don't access configure directly
func (s *Service) Init() {
host := s.Config.Get("db.host") // This won't work as expected
}
Solution: Use proper config injection mechanisms:
// ✅ CORRECT - Use prop/value/prefix tags
type Service struct {
Host string `prop:"db.host"`
Port int `value:"${db.port:3306}"`
DB *DBConfig `prefix:"database"`
}
// ✅ CORRECT - Implement ConfigurationProperties
type DBConfig struct {
Host string `yaml:"host"`
}
func (c *DBConfig) Prefix() string { return "database" }
Cause 2: Config placeholder ${key} resolved to empty and the field is required by default.
Solutions:
value:"${key:defaultValue}"value:"${key},required=false"app.SetConfigLoader(loader.NewFileLoader("config.yaml"))Cause: app.NewApp() was not used, or critical app fields were overwritten to nil.
Solution: Use ioc.Run() or app.NewApp() — they properly initialize all defaults.
Cause: Constructor function parameter type not found in container.
Check:
ConfigurationProperties parameters, ensure the struct implements Prefix() string and config is loadedCause: Post-processor registered but not taking effect.
Check:
ComponentPostProcessor, InstantiationAwareComponentPostProcessor, etc.)Order() return value — it might be running before dependencies are readyLazyInit marker (lazy components skip the initial Refresh)Run with debug flag to start a web-based debug server:
ioc.RunDebug(...)
// or
ioc.RunDebugWithContext(ctx, ...)
The debug server provides a web UI for inspecting component states, factory events, and the dependency graph.
| Log Message | Meaning |
|---|---|
"refresh component with name 'X'" | Component X is being resolved |
"eagerly caching bean 'X'" | Circular reference handling active |
"returning eagerly cached instance" | Using cached early reference |
"component 'X' population finished" | All dependencies injected for X |
"skip conditional component 'X'" | ConditionalComponent returned false |
"creating new prototype instance" | Prototype scope creating new instance |
"invoking constructor X for component 'Y'" | Constructor being called |
// Minimal reproduction test
func TestDebugIssue(t *testing.T) {
tApp := &struct {
// Put the failing injection here
Problem *MyService `wire:""`
}{}
ioc.RunTest(t,
app.LogTrace, // full trace logging
app.SetComponents(
tApp,
// Register all required components
),
)
}
npx claudepluginhub go-kid/ioc --plugin iocWires Go dependency injection graphs with uber-go/dig: provides Provide/Invoke, In/Out structs, named values, value groups, optional dependencies, scopes, and Decorate. Apply when importing go.uber.org/dig or wiring containers at startup.
Systematically debugs Go code by reproducing issues with tests and race detector, tracing with git blame and Delve, analyzing stack traces before fixes. For bugs, panics, flaky tests, deadlocks.
Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.