home / skills / shotaiuchi / dotclaude / context-android

context-android skill

/dotclaude/skills/context-android

This skill helps you implement Android features, compose UI, and apply MVVM/UDF patterns with Hilt and clean architecture guidance.

npx playbooks add skill shotaiuchi/dotclaude --skill context-android

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.3 KB
---
name: context-android
description: >-
  Android development context. Apply when working with Android modules,
  .kt files under android/, build.gradle.kts with Hilt/Compose dependencies,
  ViewModel, Jetpack Compose, MVVM/UDF patterns.
user-invocable: false
---

# Android Context Rule

Auto-applied context when working on Android development tasks.

## When to Apply

Apply this context when:
- Implementing Android features (ViewModel, Repository, UseCase)
- Creating Jetpack Compose UI
- Setting up Hilt dependency injection
- Applying MVVM/UDF patterns

## Reference Documents

Read and apply patterns from:

| Document | Purpose |
|----------|---------|
| [Clean Architecture](../../references/common/clean-architecture.md) | Layer separation principles |
| [Testing Strategy](../../references/common/testing-strategy.md) | Test patterns and coverage |
| [Android Conventions](../../references/platforms/android/conventions.md) | Naming, structure, idioms |
| [Architecture Patterns](../../references/platforms/android/architecture-patterns.md) | MVVM/UDF implementation |

## External References

| Resource | URL |
|----------|-----|
| Android Architecture Guide | https://developer.android.com/topic/architecture |
| Jetpack Compose | https://developer.android.com/jetpack/compose |
| Hilt | https://developer.android.com/training/dependency-injection/hilt-android |

Overview

This skill provides Android development context for code review, feature implementation, and architecture guidance when working inside the android/ module. It applies to Kotlin (.kt) source, build.gradle.kts with Hilt/Compose dependencies, and common Android patterns like ViewModel, Jetpack Compose, and MVVM/UDF. Use it to align code with established Android conventions, dependency injection setups, and Clean Architecture layering.

How this skill works

When active, the skill inspects project structure, Kotlin files, and Gradle configuration to identify Android-specific concerns: DI setup (Hilt), Compose UI components, ViewModel and state flows, and repository/use-case boundaries. It suggests patterns and fixes that match Clean Architecture, MVVM or UDF idioms, and the Android conventions referenced. The skill also highlights testing and module boundaries to keep logic testable and well-separated.

When to use it

  • Implementing new features using ViewModel, Repositories, or UseCase classes.
  • Creating or updating Jetpack Compose UI components and state handling.
  • Setting up or modifying Hilt dependency injection and component scopes.
  • Refactoring code toward MVVM or UDF patterns and Clean Architecture layers.
  • Reviewing android/ Kotlin files or build.gradle.kts for Android-specific issues.

Best practices

  • Keep UI stateless where possible and manage state in ViewModel using flows or LiveData.
  • Define clear layer boundaries: UI -> ViewModel -> UseCase -> Repository -> DataSource.
  • Use Hilt scopes appropriately (Activity, ViewModel, Singleton) and prefer constructor injection.
  • Favor Compose previews and small, testable composables; separate UI logic from side effects.
  • Write unit tests for ViewModel/use-cases and instrumented tests for integration points.

Example use cases

  • Convert a screen from XML-based layout to Jetpack Compose with proper state hoisting.
  • Add a Hilt module to provide networking and repository bindings with scoped components.
  • Refactor a bloated Activity by extracting logic into a ViewModel and UseCase classes.
  • Create unit tests for a ViewModel that exposes StateFlow and depends on a repository interface.
  • Audit build.gradle.kts for missing Compose compiler flags or incorrect Hilt dependencies.

FAQ

When should I prefer UDF over MVVM?

Use UDF when you want predictable, event-driven state updates and unidirectional flows; prefer MVVM for simpler two-way bindings and classic Android patterns.

How do I scope Hilt bindings for ViewModel dependencies?

Provide repository and data-source bindings with @Singleton or @Provides in modules, and use @HiltViewModel with constructor injection for ViewModels; rely on Activity/Fragment scopes for UI-scoped dependencies.