home / skills / shotaiuchi / dotclaude / android-architecture

android-architecture skill

/dotclaude/skills/android-architecture

This skill helps you implement Android MVVM and Repository patterns by applying Google's architecture guides across ViewModels, Repositories, and Compose.

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

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

Files (1)
SKILL.md
1.4 KB
---
name: Android Architecture
description: This skill should be used when implementing Android features, creating ViewModels, setting up Repositories, using Hilt, implementing Jetpack Compose, or following MVVM/UDF patterns on Android.
references:
  - path: ../../references/common/clean-architecture.md
  - path: ../../references/common/testing-strategy.md
  - path: ../../references/platforms/android/conventions.md
  - path: ../../references/platforms/android/architecture-patterns.md
external:
  # External IDs are resolved via ~/.claude/references/external-links.yaml
  # or project-specific dotclaude/references/external-links.yaml
  - id: android-arch-guide    # https://developer.android.com/topic/architecture
  - id: jetpack-compose-docs  # https://developer.android.com/jetpack/compose
  - id: hilt-docs             # https://developer.android.com/training/dependency-injection/hilt-android
---

**Always respond in Japanese.**

# Android Architecture

MVVM / UDF / Repository patterns based on Google's official Android Architecture Guide.

Read and apply the patterns from the referenced documents to the user's implementation task.

## Reference Documents

- [Clean Architecture Guide](../../references/common/clean-architecture.md)
- [Testing Strategy Guide](../../references/common/testing-strategy.md)
- [Android Conventions](../../references/platforms/android/conventions.md)
- [Architecture Patterns](../../references/platforms/android/architecture-patterns.md)

Overview

This skill helps implement Android features using recommended architecture patterns like MVVM, UDF, Repository, and Clean Architecture. It guides creation of ViewModels, Repositories, dependency injection with Hilt, and Jetpack Compose integration to produce testable, maintainable apps. Use it to align code with Google’s Android Architecture guidance and established best practices.

How this skill works

The skill inspects feature designs and code structure to recommend pattern-aligned implementations: where to place UI state in ViewModels, how to define repositories and data sources, and how to wire dependencies with Hilt. It suggests Compose-friendly state flows, unidirectional data flow (UDF) event handling, and boundaries between layers to make testing and evolution easier.

When to use it

  • Implementing new screens with Jetpack Compose and ViewModel-driven state
  • Designing data access with Repository and data source separation
  • Setting up Hilt for scoped dependency injection in features
  • Applying UDF for predictable UI events and state transitions
  • Refactoring legacy code toward MVVM or Clean Architecture

Best practices

  • Keep UI logic in ViewModel; UI only renders state and emits user intents
  • Expose immutable state (e.g., StateFlow) from ViewModels and accept intents via functions
  • Define Repository interfaces for domain-facing operations and separate local/remote data sources
  • Use Hilt to provide scoped dependencies and avoid service locators or static singletons
  • Model side effects explicitly (events) and process them in a single, testable coordinator

Example use cases

  • Create a Compose screen: View emits intents, ViewModel updates StateFlow, Repository fetches data and maps to UI models
  • Add a Repository abstraction to enable unit testing of ViewModel logic without network/database dependencies
  • Introduce Hilt modules to inject feature-scoped use cases and repositories into ViewModels
  • Refactor a Presenter-based screen to MVVM: move presentation state and business logic into a ViewModel and keep UI stateless

FAQ

Should I put business rules in ViewModel or Repository?

Place domain and business rules in use-case or domain-layer components (Repository or dedicated use-case classes). ViewModels should orchestrate and adapt domain outputs for the UI, not contain core business logic.

How do I test Compose UIs with UDF?

Keep UI deterministic by exposing StateFlows and one-way event channels. Write unit tests for ViewModel behavior and use Compose testing APIs to assert UI rendering from controlled states and simulated events.