android-di-hilt
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
More from midudev/autoskills
bun
Use when building, testing, and deploying JavaScript/TypeScript applications. Reach for Bun when you need to run scripts, manage dependencies, bundle code, or test applications with a single unified tool.
14pydantic
Python data validation using type hints and runtime type checking with Pydantic v2's Rust-powered core for high-performance validation in FastAPI, Django, and configuration management.
11react-hook-form
React Hook Form performance optimization for client-side form validation using useForm, useWatch, useController, and useFieldArray. This skill should be used when building client-side controlled forms with React Hook Form library. This skill does NOT cover React 19 Server Actions, useActionState, or server-side form handling (use react-19 skill for those).
10azure-deploy
Execute Azure deployments for ALREADY-PREPARED applications that have existing .azure/deployment-plan.md and infrastructure files. DO NOT use this skill when the user asks to CREATE a new application — use azure-prepare instead. This skill runs azd up, azd deploy, terraform apply, and az deployment commands with built-in error recovery. Requires .azure/deployment-plan.md from azure-prepare and validated status from azure-validate. WHEN: \"run azd up\", \"run azd deploy\", \"execute deployment\", \"push to production\", \"push to cloud\", \"go live\", \"ship it\", \"bicep deploy\", \"terraform apply\", \"publish to Azure\", \"launch on Azure\". DO NOT USE WHEN: \"create and deploy\", \"build and deploy\", \"create a new app\", \"set up infrastructure\", \"create and deploy to Azure using Terraform\" — use azure-prepare for these.
8sqlalchemy-orm
SQLAlchemy Python SQL toolkit and ORM with powerful query builder, relationship mapping, and database migrations via Alembic
8clerk
Clerk authentication router. Use when user asks about adding authentication,
8