About android-di-hilt
An Android Hilt dependency-injection skill for agents, covering bindings, component scopes, module boundaries, and test replacements. It is intended for developers working through injection-graph ownership and lifetime decisions.
Key features
- 01Plan components and dependency scopes
- 02Choose binding and injection styles
- 03Configure test replacements and fakes
- 04Review module ownership boundaries
Use cases
- 01Inject repositories into ViewModels
- 02Select suitable Hilt scopes for dependencies
- 03Replace dependencies in tests
- 04Check ownership of cross-module bindings
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ krutikjain/ android-agent-skills --skill android-di-hiltAfter installing, type/android-di-hiltin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/official-links.mdpatterns.mdscenarios.mdscripts/run_examples.shDetails
From the project READMEAndroid DI Hilt
When To Use
- Use this skill when the request is about: android hilt setup, inject viewmodel repository hilt, scope dependency in android.
- Primary outcome: Wire Android dependency injection with Hilt, scopes, testing overrides, and module ownership boundaries.
- Reach for this skill when the hard part is component ownership, bindings, scopes, entry points, or test replacement. If the request is only about networking APIs or reducer design, use the neighboring skill instead.
- Handoff skills when the scope expands:
android-testing-unitandroid-networking-retrofit-okhttp
Workflow
- Identify the injection boundary first: app-wide singleton, activity-retained, ViewModel, worker, service, or entry point from unsupported framework code.
- Decide what should be bound: constructor injection,
@Binds,@Provides, qualifiers, multibindings, or assisted injection. - Match lifetime to scope explicitly so dependencies do not outlive their owner or rebuild too often.
- Verify replacement strategy for tests with Hilt test modules, uninstall modules, or fakes at the right component boundary.
- Hand off API-specific or architectural questions only after the DI graph ownership is correct.
Guardrails
- Prefer constructor injection for app code you own.
- Use qualifiers and scope annotations deliberately; ambiguous bindings are a graph smell, not a convenience.
- Keep Hilt modules close to the ownership boundary they configure.
- Treat test replacement as part of the design, not an afterthought.
Anti-Patterns
- Making everything
@Singletonto silence scope questions. - Hiding business construction logic inside giant
@Providesmethods when constructor injection would suffice. - Using Hilt modules as a dumping ground for unrelated bindings across modules.
- Confusing DI graph ownership with app architecture ownership.
Review Focus
- Component and scope alignment.
- Binding style and qualifier clarity.
- Unsupported-entry-point bridges and test replacement strategy.
- Module ownership boundaries across features and core code.
Examples
Happy path
- Scenario: Inject OrbitTasks repositories and dispatchers with clear Hilt scopes.
- Command:
cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest
Edge case
- Scenario: Swap fake dependencies in the XML fixture for deterministic tests.
- Command:
cd examples/orbittasks-xml && ./gradlew :app:testDebugUnitTest
Failure recovery
- Scenario: Catch DI-specific prompts before they drift into architecture-clean or networking.
- Command:
python3 scripts/eval_triggers.py --skill android-di-hilt
Done Checklist
- Component lifetime matches dependency lifetime.
- Binding style is explicit and testable.
- Test overrides or fakes are planned at the right graph boundary.
- Non-DI work is handed off instead of buried in modules.
Official References
- https://developer.android.com/training/dependency-injection/hilt-android
- https://developer.android.com/training/dependency-injection/hilt-testing
- https://developer.android.com/training/dependency-injection/hilt-multi-module
- https://developer.android.com/topic/libraries/architecture/viewmodel
- https://developer.android.com/training/dependency-injection/manual
Comments
Markdown supported