Android DI Hilt
CommunitykrutikJain
Wire Android dependency injection with Hilt, scopes, testing overrides, and module ownership boundaries.
Overview
- Repository
- krutikJain/android-agent-skills
- Publisher
- krutikJain
- Stars
- 14
- Forks
- 5
- Bundled files
- 5
- License
- MIT
- Updated
- Mar 25, 2026
Installation
tmp=$(mktemp -d)
git clone --depth 1 https://github.com/krutikJain/android-agent-skills.git "$tmp"
mkdir -p ~/.claude/skills
cp -R "$tmp/skills/android-di-hilt" ~/.claude/skills/android-di-hilt
rm -rf "$tmp"tmp=$(mktemp -d)
git clone --depth 1 https://github.com/krutikJain/android-agent-skills.git "$tmp"
mkdir -p ~/.codex/skills
cp -R "$tmp/skills/android-di-hilt" ~/.codex/skills/android-di-hilt
rm -rf "$tmp"Install the Android DI Hilt agent skill from https://github.com/krutikJain/android-agent-skills/tree/main/skills/android-di-hilt into this project's skills folder.Instructions
Android 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
Bundled files
FAQ
What does Android DI Hilt do?
Wire Android dependency injection with Hilt, scopes, testing overrides, and module ownership boundaries.
Who made Android DI Hilt?
krutikJain (a community member) publishes it in the krutikJain/android-agent-skills repository on GitHub.
Is Android DI Hilt free?
Yes. Android DI Hilt is open source, published by krutikJain under the MIT license.
What comes with Android DI Hilt?
Its instructions and 5 files the agent reads only when a task needs them, such as references, examples or scripts.
Which agents can use Android DI Hilt?
Any coding agent that reads SKILL.md files, including Claude Code, Codex, Cursor, GitHub Copilot and Gemini CLI. The agent loads the skill when a task matches its description.
What are agent skills?
An agent skill is a folder with a SKILL.md file: instructions that teach a coding agent how to do one kind of task, and optionally files it can read while it works. The agent keeps only the skill's name and description in mind and reads the rest when a task calls for it.
How are agent skills different from MCP servers?
An MCP server gives an agent new tools to call, code that runs somewhere and returns results. A skill gives it knowledge: how to approach a task with the tools it already has. Many agents use both.
How can my agent test my Android app?
Robomori lets coding agents create, start and control Android emulators and devices from one command, so they can install your app, take screenshots and check dark mode, font sizes and languages.