Claude Code android-patterns for Kotlin StateFlow screens
Organize a Kotlin ViewModel and coroutines around observable loading, success, and error states and collect them with the Compose lifecycle.
中文Install in Claude Code
Open a Kotlin Android project in Claude Code. A Compose implementation uses the project’s lifecycle integration and coroutine dependencies.
- Review `.claude/skills/android-patterns/SKILL.md` and its requirements at the pinned GitHub commit.
- Create `.claude/skills/android-patterns/` in your project and save the reviewed file as `.claude/skills/android-patterns/SKILL.md`.
- Start Claude Code from that project's root, then select `/android-patterns` in the slash menu.
Example task
In gallery-08, the album has no photos before reloading. Its repository returns {count: 3, album: 'Spring'}. The screen shows loading first.What to check
The ViewModel yields {loading: false, count: 3, album: 'Spring'} and Compose presents the album after the observable state changes. The state transition is testable.
Original SKILL.md on GitHub · Updated
Frequently asked question
Should the screen access mutable StateFlow directly?
Keep mutable state private and expose a read-only StateFlow. Updates stay in the ViewModel and the screen collects them in a lifecycle-aware manner.