Agent Skillsmidudev/autoskills › android-di-hilt

android-di-hilt

GitHub

用于在Android项目中配置Hilt依赖注入,涵盖作用域、测试覆盖及模块边界。解决组件所有权、绑定策略及测试替换等难题,确保依赖生命周期与组件对齐,避免滥用单例和巨型Provide方法。

packages/autoskills/skills-registry/android-di-hilt/SKILL.md midudev/autoskills

Trigger Scenarios

Android Hilt 设置与配置 ViewModel/Repository 依赖注入 定义 Android 依赖作用域 处理 DI 图所有权与模块边界

Install

npx skills add midudev/autoskills --skill android-di-hilt -g -y
More Options

Non-standard path

npx skills add https://github.com/midudev/autoskills/tree/main/packages/autoskills/skills-registry/android-di-hilt -g -y

Use without installing

npx skills use midudev/autoskills@android-di-hilt

指定 Agent (Claude Code)

npx skills add midudev/autoskills --skill android-di-hilt -a claude-code -g -y

安装 repo 全部 skill

npx skills add midudev/autoskills --all -g -y

预览 repo 内 skill

npx skills add midudev/autoskills --list

SKILL.md

Frontmatter
{
    "name": "android-di-hilt",
    "metadata": {
        "tags": [
            "android",
            "hilt",
            "dependency-injection",
            "testing"
        ],
        "owners": [
            "@android-agent-skills\/maintainers"
        ],
        "version": "0.1.0",
        "category": "foundations",
        "triggers": {
            "exclude": [
                "retrofit serialization only",
                "compose typography only",
                "gradle wrapper upgrade",
                "collect flow in compose screen",
                "state matrix before release"
            ],
            "include": [
                "android hilt setup",
                "inject viewmodel repository hilt",
                "scope dependency in android",
                "replace manual service locator",
                "hilt testing override",
                "android-di-hilt skill",
                "scope dependency in android hilt",
                "hilt component scope mismatch",
                "hilt entry point android"
            ]
        },
        "test_targets": [
            "examples\/orbittasks-compose",
            "examples\/orbittasks-xml",
            "benchmarks\/triggers.jsonl"
        ]
    },
    "description": "Wire Android dependency injection with Hilt, scopes, testing overrides, and module ownership boundaries."
}

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

Version History

  • 0ec7253 Current 2026-07-24 20:51

Same Skill Collection

packages/autoskills/skills-registry/accessibility/SKILL.md
packages/autoskills/skills-registry/adev-writing-guide/SKILL.md
packages/autoskills/skills-registry/agents-sdk/SKILL.md
packages/autoskills/skills-registry/android-architecture-clean/SKILL.md
packages/autoskills/skills-registry/android-compose-foundations/SKILL.md
packages/autoskills/skills-registry/android-coroutines-flow/SKILL.md
packages/autoskills/skills-registry/android-gradle-build-logic/SKILL.md
packages/autoskills/skills-registry/android-kotlin-core/SKILL.md
packages/autoskills/skills-registry/android-networking-retrofit-okhttp/SKILL.md
packages/autoskills/skills-registry/android-testing-unit/SKILL.md
packages/autoskills/skills-registry/angular-developer/SKILL.md
packages/autoskills/skills-registry/aspnet-core/SKILL.md
packages/autoskills/skills-registry/aspnet-minimal-api-openapi/SKILL.md
packages/autoskills/skills-registry/astro/SKILL.md
packages/autoskills/skills-registry/azure-ai/SKILL.md
packages/autoskills/skills-registry/bash-defensive-patterns/SKILL.md
packages/autoskills/skills-registry/best-practices/SKILL.md
packages/autoskills/skills-registry/building-native-ui/SKILL.md
packages/autoskills/skills-registry/bun/SKILL.md
packages/autoskills/skills-registry/chrome-extension-development/SKILL.md
packages/autoskills/skills-registry/clerk-android/SKILL.md
packages/autoskills/skills-registry/clerk-astro-patterns/SKILL.md
packages/autoskills/skills-registry/clerk-backend-api/SKILL.md
packages/autoskills/skills-registry/clerk-chrome-extension-patterns/SKILL.md
packages/autoskills/skills-registry/clerk-custom-ui/SKILL.md
packages/autoskills/skills-registry/clerk-expo-patterns/SKILL.md
packages/autoskills/skills-registry/clerk-nextjs-patterns/SKILL.md
packages/autoskills/skills-registry/clerk-nuxt-patterns/SKILL.md
packages/autoskills/skills-registry/clerk-orgs/SKILL.md
packages/autoskills/skills-registry/clerk-react-patterns/SKILL.md
packages/autoskills/skills-registry/clerk-react-router-patterns/SKILL.md
packages/autoskills/skills-registry/clerk-setup/SKILL.md
packages/autoskills/skills-registry/clerk-swift/SKILL.md
packages/autoskills/skills-registry/clerk-tanstack-patterns/SKILL.md
packages/autoskills/skills-registry/clerk-testing/SKILL.md
packages/autoskills/skills-registry/clerk-vue-patterns/SKILL.md
packages/autoskills/skills-registry/clerk-webhooks/SKILL.md
packages/autoskills/skills-registry/cloudflare-deploy/SKILL.md
packages/autoskills/skills-registry/cloudflare/SKILL.md
packages/autoskills/skills-registry/composition-patterns/SKILL.md
packages/autoskills/skills-registry/containerize-aspnetcore/SKILL.md
packages/autoskills/skills-registry/core-data-expert/SKILL.md
packages/autoskills/skills-registry/csharp-docs/SKILL.md
packages/autoskills/skills-registry/csharp-mstest/SKILL.md
packages/autoskills/skills-registry/csharp-nunit/SKILL.md
packages/autoskills/skills-registry/csharp-tunit/SKILL.md
packages/autoskills/skills-registry/csharp-xunit/SKILL.md
packages/autoskills/skills-registry/dart-best-practices/SKILL.md
packages/autoskills/skills-registry/deno-deploy/SKILL.md

Metadata

Files
0
Version
0ec7253
Hash
9e4d46ab
Indexed
2026-07-24 20:51

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-08 01:18
浙ICP备14020137号-1 $방문자$