# Android Di Hilt

> Wire Android dependency injection with Hilt, scopes, testing overrides, and module ownership boundaries.

- **Type:** Skill
- **Install:** `agentstack add skill-krutikjain-android-agent-skills-android-di-hilt`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [krutikJain](https://agentstack.voostack.com/s/krutikjain)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [krutikJain](https://github.com/krutikJain)
- **Source:** https://github.com/krutikJain/android-agent-skills/tree/main/skills/android-di-hilt

## Install

```sh
agentstack add skill-krutikjain-android-agent-skills-android-di-hilt
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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-unit`
- `android-networking-retrofit-okhttp`

## Workflow
1. Identify the injection boundary first: app-wide singleton, activity-retained, ViewModel, worker, service, or entry point from unsupported framework code.
2. Decide what should be bound: constructor injection, `@Binds`, `@Provides`, qualifiers, multibindings, or assisted injection.
3. Match lifetime to scope explicitly so dependencies do not outlive their owner or rebuild too often.
4. Verify replacement strategy for tests with Hilt test modules, uninstall modules, or fakes at the right component boundary.
5. 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 `@Singleton` to silence scope questions.
- Hiding business construction logic inside giant `@Provides` methods 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-android)
- [https://developer.android.com/training/dependency-injection/hilt-testing](https://developer.android.com/training/dependency-injection/hilt-testing)
- [https://developer.android.com/training/dependency-injection/hilt-multi-module](https://developer.android.com/training/dependency-injection/hilt-multi-module)
- [https://developer.android.com/topic/libraries/architecture/viewmodel](https://developer.android.com/topic/libraries/architecture/viewmodel)
- [https://developer.android.com/training/dependency-injection/manual](https://developer.android.com/training/dependency-injection/manual)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [krutikJain](https://github.com/krutikJain)
- **Source:** [krutikJain/android-agent-skills](https://github.com/krutikJain/android-agent-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-krutikjain-android-agent-skills-android-di-hilt
- Seller: https://agentstack.voostack.com/s/krutikjain
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
