dimitriremoiville/cc-mobile/hilt-di
Claude Code and agent skill by dimitriremoiville/cc-mobile
- community
Checking that the SKILL.md file is still in the repository.
Project-specific Hilt conventions — feature-first module locations, `hiltViewModel()`-in-Route-only rule, KSP-only compiler, single shared `OkHttpClient` between Retrofit and Coil, and the test-time `@BindValue` shortcut. Load when adding a new injectable, creating a Hilt module, setting up a new ViewModel, wiring a repository, writing Hilt-aware tests, or debugging a DI error.
Install
npx vskill@latest install dimitriremoiville/cc-mobile/hilt-diSKILL.md
The same SKILL.md was published earlier as dimitriremoiville/cc-mobile/hilt-di.
Hilt (project delta)
For Hilt fundamentals — @HiltAndroidApp, @AndroidEntryPoint, @HiltViewModel, component scopes, @Provides vs @Binds, qualifiers, Provider<T> / Lazy<T> — read the official Hilt guide. The canonical NetworkModule / PersistenceModule / DataStoreModule / AnalyticsModule templates live in ${CLAUDE_PLUGIN_ROOT}/skills/android-app-skeleton/references/core-data.md (and the optional-room / optional-datastore references). This file documents only the project's specific decisions.
When this applies
Hilt with KSP. On an existing app:
- Koin (
org.koin.*,koinViewModel(...),module { ... }) → skip this skill entirely; Koin's runtime DSL is incompatible with Hilt's compile-time graph. Apply only stack-agnostic principles (constructor injection, no service locator). - Plain Dagger 2 (no
@HiltAndroidApp, manual@Component) → many idioms transfer, but Hilt's component hierarchy and@HiltViewModelshortcut don't exist. Don't push Hilt-specific patterns. - Manual constructor wiring / no DI framework → don't refactor unless asked.
- kapt instead of KSP → it works; flag the build-time cost only when discussing the build, not as a correctness issue.
Project rules
- KSP-only.
ksp(libs.hilt.compiler). The reviewer rejectskapt(libs.hilt.compiler)and anykaptplugin inapp/build.gradle.kts. - `hiltViewModel()` is called only in the Route composable. Never in child composables, never passed down the tree. The Route owns the VM; the Screen takes state + callbacks. See
compose-uifor the Route/Screen split. - Default to `SingletonComponent`. Reach for
ViewModelComponent/ActivityRetainedComponentonly when you have a concrete reason (short-lived helpers, things that must die with the ViewModel). - One shared `OkHttpClient` between Retrofit and Coil. Coil's network fetcher reuses it via
{{APP_CLASS}}.newImageLoader. Don't `@Provides` a second `OkHttpClient` for images.
Where modules live (feature-first)
Co-locate modules with the implementations they bind:
core/data/network/di/ is correct because network providers belong to the data layer's networking subpackage. Reach for core/di/ only for things that don't belong to a single layer. Avoid a single `AppModule` that knows about everything.
Testing — @BindValue over test modules
Unit tests don't involve Hilt. Construct the class manually and pass fakes / mocks to the constructor. The scaffold's FeedViewModelTest (in ${CLAUDE_PLUGIN_ROOT}/skills/android-app-skeleton/references/tests.md) is the canonical example.
Hilt-aware integration / Compose tests use the Hilt test rule and `@BindValue` to swap one binding per test:
@BindValue is far simpler than writing a `@TestInstallIn` test module for one-off replacements. Use it for AnalyticsTracker, fake repositories, and any other singleton you want to control per-test. The custom CustomTestRunner + HiltTestApplication are set up by the scaffold's app/build.gradle.kts.
Common error pointers (project-specific only)
- "No binding found for X" on a third-party type (e.g.
OkHttpClient,Json) — it lives incore/data/network/di/NetworkModule.kt. Don't@Providesit locally. - ViewModel fails to inject in a composable — most common cause is
viewModel()instead ofhiltViewModel()in the Route. Second most common: missing@AndroidEntryPointon the host Activity. - AGP 9 + Hilt version mismatch (
Cannot add extension with name 'kotlin'/Could not find AGP base extension) — see${CLAUDE_PLUGIN_ROOT}/skills/android-app-skeleton/references/root-files.md→ "Compatibility traps."
For generic Hilt error messages ("Found a dependency cycle", "X is already bound"), the official guide's troubleshooting section is more thorough than restating it here.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/cc-mobile-android/skills/hilt-di/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dimitriremoiville/cc-mobile/hilt-di)