README.md
.codex/skills/compose-kotlin-agent-skills/README.md
1<p align="center">2 <img src="assets/logo.png" width="160" alt="compose-kotlin-agent-skills"/>3</p>45<h1 align="center">compose-kotlin-agent-skills</h1>67<p align="center">8 Make your AI coding agent actually understand <b>Jetpack Compose & Kotlin</b> — on Android, Kotlin Multiplatform, and Compose Multiplatform.<br/>9 Strict MVI · Kotlin 2.x K2 · Compose 2026 · CI-validated · 27 agents supported.10</p>1112<p align="center">13 <a href="#setup"><img src="https://img.shields.io/badge/setup-2%20min-brightgreen" alt="Setup time"/></a>14 <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License"/></a>15 <a href="https://github.com/haidrrrry/compose-kotlin-agent-skills/actions/workflows/skill-lint.yml"><img src="https://github.com/haidrrrry/compose-kotlin-agent-skills/actions/workflows/skill-lint.yml/badge.svg" alt="Skill Lint"/></a>16 <a href="agents/README.md"><img src="https://img.shields.io/badge/agents-27%2B-3DDC84?logo=android&logoColor=white" alt="Agents supported"/></a>17 <a href="SKILL.md"><img src="https://img.shields.io/badge/Kotlin-2.x%20K2-7F52FF?logo=kotlin&logoColor=white" alt="Kotlin"/></a>18 <a href="skills/android-kotlin-compose/SKILL.md"><img src="https://img.shields.io/badge/Jetpack%20Compose-2026-4285F4?logo=jetpackcompose&logoColor=white" alt="Compose"/></a>19 <a href="AGENTS.md"><img src="https://img.shields.io/badge/AGENTS.md-spec-818CF8" alt="AGENTS.md"/></a>20 <a href="https://star-history.com/#haidrrrry/compose-kotlin-agent-skills"><img src="https://api.star-history.com/svg?repos=haidrrrry/compose-kotlin-agent-skills&type=Date" alt="Star History Chart"/></a>21</p>2223---2425## Quick install2627| Agent | Command |28|---|---|29| **Cursor** | `git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git .cursor/skills/compose-kotlin-agent-skills` |30| **Claude Code** | `git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git ~/.claude/skills/compose-kotlin-agent-skills` |31| **Codex CLI** | `git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git` → add block to root `AGENTS.md` ([guide](agents/codex.md)) |32| **Gemini CLI** | `git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git` → add block to `GEMINI.md` ([guide](agents/gemini.md)) |33| **GitHub Copilot** | `git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git .github/skills/compose-kotlin-agent-skills` ([guide](agents/copilot.md)) |3435Per-agent details → [Setup](#setup) · All 27 agents → [`agents/README.md`](agents/README.md)3637## The problem3839AI coding agents generate Kotlin/Compose code that compiles but gets the details wrong:4041- `_state.value = …` instead of atomic `_state.update { }` — race conditions42- `collectAsState()` instead of `collectAsStateWithLifecycle()` — battery drain43- Hardcoded UI strings instead of `stringResource(R.string.…)` — broken localisation44- `LazyColumn` without `key` + `contentType` — broken scroll, recomposition storms45- `GlobalScope.launch { }` inside ViewModels — leaks46- `mutableStateListOf` in ViewModel — survives config change wrong4748This skill kit fixes that by giving your AI agent:49501. **A primary `SKILL.md`** with the 2026 toolchain, strict MVI guardrails, and a dedicated **[banned-antipatterns reference](references/00-banned-antipatterns.md)**.512. **3 modular sub-skills** (architecture, Compose, testing) loaded on demand — Compose sub-skill includes **REVIEW MODE** for screen audits.523. **20 reference modules** (00–19) covering every major Android/Kotlin topic.534. **27 per-agent install guides** so Cursor, Claude Code, Codex, Copilot, Gemini, etc. each load it correctly.545. **CI-validated** — every `SKILL.md` is frontmatter-linted, link-checked, and registered in `api/skills.lock` on every push.5556---5758## What this is NOT5960| Wrong guess | Reality |61|---|---|62| Android library / Gradle dependency | **No** — nothing to `implementation(...)`. Pure markdown. |63| Alexa / Bixby / voice-assistant "skill" | **No** — not a voice platform. The word "skill" here = [agentskills.io](https://agentskills.io) format. |64| On-device LLM runtime / tool-calling SDK | **No** — no model inference, no agent framework. |65| Compose UI library (coachmarks, theming, charts) | **No** — we don't ship Composables; we teach how to write them. |66| Backend or REST API | **No** — markdown files plus a Python validator. |6768**TL;DR:** clone this repo into your agent's skills folder. The agent reads it before writing Kotlin. That's it.6970---7172## What changes when you install it7374| Area | Without the skill | With the skill |75|---|---|---|76| ViewModel state | `_state.value = ...` (race conditions) | Atomic `_state.update { it.copy(...) }` |77| Flow collection | `collectAsState()` (drains battery in background) | `collectAsStateWithLifecycle()` |78| UI text | Hardcoded `"Login"` literals | `stringResource(R.string.login)` |79| Lists | `LazyColumn` with no key | Stable `key` + `contentType` per item |80| Architecture | Mixed MVVM / state in Composable | Strict MVI — `UiState` + `UiEvent` + `UiEffect` |81| DI | `companion object Singleton` | `@HiltViewModel` + constructor injection |82| Navigation | String routes (deprecated) | Navigation 3 type-safe `NavKey` routes |83| Coroutines | `GlobalScope.launch { }` | `viewModelScope` + structured concurrency |84| Compose perf | Unstable params → constant recomposition | `@Stable` / `@Immutable` + deferred reads |85| Edge-to-edge | Status bar overlaps content | `enableEdgeToEdge()` + correct insets |86| Versions | Made up / outdated | Pinned to 2026 stable releases |8788---8990## Platforms9192| | Supported |93|---|---|94| **Target (what the docs teach)** | Android · Kotlin Multiplatform · Compose Multiplatform |95| **Host (where the docs are read)** | macOS · Linux · Windows — anywhere your AI agent runs |96| **Agent compatibility** | 27 install guides (see [`agents/README.md`](agents/README.md)) |97| **Languages taught** | Kotlin 2.x (K2 compiler) |98| **Tooling enforced** | AGP 9, Compose BOM 2026, Navigation 3 |99100---101102## Skill catalog103104| Skill | When the agent loads it |105|---|---|106| [`SKILL.md`](SKILL.md) (root) | Any Android / Kotlin / Compose work — toolchain, MVI guardrails, banned antipatterns |107| [`skills/android-kotlin-architecture/SKILL.md`](skills/android-kotlin-architecture/SKILL.md) | Clean Architecture, MVVM/MVI, modules, UseCases, `UiState` / `UiEvent` / `UiEffect` |108| [`skills/android-kotlin-compose/SKILL.md`](skills/android-kotlin-compose/SKILL.md) | Jetpack Compose UI, recomposition, Material 3, edge-to-edge, **REVIEW MODE audits** |109| [`skills/android-kotlin-testing/SKILL.md`](skills/android-kotlin-testing/SKILL.md) | ViewModel tests, Compose UI tests, Hilt fakes, Turbine |110111Full routing index → [`AGENTS.md`](AGENTS.md)112113---114115## What's covered116117| Topic | Reference | What the agent learns |118|---|---|---|119| **Banned antipatterns** | [`references/00-banned-antipatterns.md`](references/00-banned-antipatterns.md) | Master WRONG/RIGHT lookup — load first for reviews |120| Architecture | [`references/01-architecture.md`](references/01-architecture.md) | Clean Arch, MVVM, MVI, module structure |121| Compose UI | [`references/02-compose-ui.md`](references/02-compose-ui.md) | Composition, stability, Modifier order, theming |122| Animations | [`references/03-animations.md`](references/03-animations.md) | Springs, Canvas, gestures, shared elements |123| Coroutines & Flow | [`references/04-coroutines-flow.md`](references/04-coroutines-flow.md) | `StateFlow`, structured concurrency, error handling |124| Hilt DI | [`references/05-hilt-di.md`](references/05-hilt-di.md) | Scopes, `EntryPoint`, testing |125| Room | [`references/06-room-db.md`](references/06-room-db.md) | Migrations, offline-first, DAOs |126| Navigation | [`references/07-navigation.md`](references/07-navigation.md) | Navigation 3, type-safe routes, deep links |127| KMP / CMP | [`references/08-kmp-cmp.md`](references/08-kmp-cmp.md) | `expect`/`actual`, shared ViewModel, Ktor |128| Networking | [`references/09-networking.md`](references/09-networking.md) | Ktor, JWT, DTO mappers |129| Performance | [`references/10-performance.md`](references/10-performance.md) | Recomposition, `LazyColumn`, baseline profiles |130| Testing | [`references/11-testing.md`](references/11-testing.md) | Turbine, Compose UI tests, Hilt `TestInstallIn` |131| Camera & ML | [`references/12-camera-mlkit.md`](references/12-camera-mlkit.md) | CameraX, ML Kit pose, angle math |132| Release | [`references/13-release-checklist.md`](references/13-release-checklist.md) | Signing, R8, Play Store |133| DataStore | [`references/14-datastore.md`](references/14-datastore.md) | Preferences/Proto DataStore, SP migration, encryption |134| Paging 3 | [`references/15-paging3.md`](references/15-paging3.md) | PagingSource, RemoteMediator, `asState()`, LoadState UI |135| Coil 3 | [`references/16-coil-image.md`](references/16-coil-image.md) | AsyncImage, Coil 3.4 network dep, cache config |136| Accessibility | [`references/17-accessibility.md`](references/17-accessibility.md) | TalkBack, semantics, 48dp targets, WCAG AA |137| Gradle / build | [`references/18-gradle-build-logic.md`](references/18-gradle-build-logic.md) | Convention plugins, KSP, R8, baseline profiles |138| XML → Compose | [`references/19-xml-to-compose-migration.md`](references/19-xml-to-compose-migration.md) | View migration, RxJava → Flow, interop checklist |139140---141142## Review mode143144Ask your agent to **audit** a Composable or screen — triggers the 6-point checklist in [`skills/android-kotlin-compose/SKILL.md`](skills/android-kotlin-compose/SKILL.md):145146> "Review `TodoScreen.kt` in REVIEW MODE" · "Audit this composable for banned antipatterns"147148| # | Check |149|---|---|150| 1 | `modifier: Modifier = Modifier` present and last optional param |151| 2 | State hoisted — no screen state stuck in `@Composable` |152| 3 | `LazyColumn`/`LazyRow` has `key` + `contentType` |153| 4 | `collectAsStateWithLifecycle()` — never `collectAsState()` |154| 5 | No IO/DB/network in composition body |155| 6 | Data params to children are `@Stable` or `@Immutable` |156157Cross-reference hits against [`references/00-banned-antipatterns.md`](references/00-banned-antipatterns.md). Example target: [`examples/todo-mvi/TodoScreen.kt`](examples/todo-mvi/TodoScreen.kt).158159## How it works160161```162You ask about Kotlin / Compose163 |164 v165 AI reads SKILL.md (routing + guardrails + banned antipatterns)166 |167 v168 Loads the right sub-skill169 |170 +-- skills/android-kotlin-architecture/SKILL.md171 +-- skills/android-kotlin-compose/SKILL.md172 +-- skills/android-kotlin-testing/SKILL.md173 |174 v175 Pulls topic reference176 |177 +-- references/00-banned-antipatterns.md178 +-- references/01-architecture.md179 +-- references/02-compose-ui.md180 +-- ... 20 references total (00–19)181 |182 v183 Writes code that follows the guardrails184```185186**Layer 1: root skill** (`SKILL.md`) — single source of truth for toolchain versions, mandatory defaults, and banned antipatterns.187188**Layer 2: sub-skills** (3 files) — focused playbooks loaded only when the task matches the domain.189190**Layer 3: references** (20 files, 00–19) — deep dives with WRONG/RIGHT pairs, decision matrices, pinned versions.191192**Layer 4: validator** (`scripts/validate_skills.py`) — CI enforces frontmatter, link integrity, and skill-registry parity.193194---195196## File structure197198```199compose-kotlin-agent-skills/200├── SKILL.md # Routing hub + MVI guardrails + banned antipatterns201├── AGENTS.md # agentskills.io meta-discovery index202├── CHANGELOG.md # Keep a Changelog · semver203├── ROADMAP.md # Planned milestones204├── api/205│ └── skills.lock # CI-tracked registry of every SKILL.md (md5)206├── skills/207│ ├── android-kotlin-architecture/SKILL.md208│ ├── android-kotlin-compose/SKILL.md209│ └── android-kotlin-testing/SKILL.md210├── references/ # 20 topic deep-dives (00–19)211├── agents/ # 27 per-agent install guides + index212├── examples/213│ ├── todo-mvi/ # MVI todo list reference (VM + Screen + Repository)214│ ├── animated-clock/215│ └── authenticator/216├── assets/217│ └── logo.png218├── scripts/219│ ├── validate_skills.py # Frontmatter + link + lock validator (JUnit XML capable)220│ └── update_lock.sh # Regenerate api/skills.lock after editing any SKILL.md221└── .github/222 ├── workflows/skill-lint.yml # CI: validator + JUnit report223 ├── pull_request_template.md224 └── ISSUE_TEMPLATE/ # bug, feature, new-agent225```226227---228229## Setup {#setup}230231The skill is just markdown. Every agent below reads the same content — pick yours.232233### Cursor234235```bash236git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git \237 .cursor/skills/compose-kotlin-agent-skills238```239240Cursor auto-discovers `.cursor/skills/*/SKILL.md`. For a rules-file alternative see [`agents/cursor.md`](agents/cursor.md).241242### Claude Code243244```bash245# Personal — available in all your projects246git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git \247 ~/.claude/skills/compose-kotlin-agent-skills248249# Project-specific250git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git \251 .claude/skills/compose-kotlin-agent-skills252```253254Add a 5-line block to your project's `CLAUDE.md` — see [`agents/claude.md`](agents/claude.md).255256### Codex CLI (OpenAI)257258```bash259git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git260```261262Then add a reference block to your project's root `AGENTS.md` — see [`agents/codex.md`](agents/codex.md).263264### Gemini CLI265266```bash267git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git268```269270Then add a reference block to `GEMINI.md` — see [`agents/gemini.md`](agents/gemini.md).271272### GitHub Copilot273274Clone into `.github/skills/compose-kotlin-agent-skills/` and add a block to `.github/copilot-instructions.md` — see [`agents/copilot.md`](agents/copilot.md).275276### Other agents (22 more)277278Windsurf · Kimi · DeepSeek · Cline · Aider · Continue.dev · OpenCode · Zed · Amazon Q · JetBrains AI / Junie · Sourcegraph Cody · Replit Agent · Augment · Roo Code · Goose · OpenHands · Qwen Code · Trae · Tabnine · Factory Droid · Devin · Bolt.new279280Full table → [`agents/README.md`](agents/README.md)281Paste-anywhere snippet → [`agents/_shared-snippet.md`](agents/_shared-snippet.md)282283---284285## Quick example286287After setup, talk to your AI agent normally:288289```290"My LazyColumn jank — fix it."291```292293Or run **REVIEW MODE** against the bundled example:294295```296"Review examples/todo-mvi/TodoScreen.kt in REVIEW MODE"297```298299See [`examples/todo-mvi/README.md`](examples/todo-mvi/README.md) for the MVI patterns it demonstrates.300301What happens:3023031. Agent reads `SKILL.md` for the routing rules.3042. Loads `skills/android-kotlin-compose/SKILL.md` and `references/10-performance.md`.3053. Checks your code for missing `key` / `contentType`, unstable items, heavy work in item blocks.3064. Returns a fix that follows the guardrails — `key = { it.id }`, `@Immutable` data class, `derivedStateOf` where appropriate.307308No hallucinated APIs. No `GlobalScope`. No `_state.value = …`.309310---311312## Validate locally313314```bash315python3 scripts/validate_skills.py --strict --lock-check api/skills.lock316```317318CI runs the same command on every push and pull request. If you edit any `SKILL.md`:319320```bash321./scripts/update_lock.sh322```323324Then commit `api/skills.lock` alongside your change.325326---327328## FAQ329330### Best Kotlin / Compose skill for Cursor?331332Clone this repo into `.cursor/skills/compose-kotlin-agent-skills` and point Cursor rules at `SKILL.md`. Covers Compose, MVI, Hilt, Room, Navigation 3, and the banned-antipatterns table.333334### How do I add Kotlin rules to Claude Code?335336```bash337git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git ~/.claude/skills/compose-kotlin-agent-skills338```339340Claude auto-discovers `SKILL.md` in the skills folder.341342### MVVM vs MVI — which does this enforce?343344**MVI** with atomic `StateFlow` updates. `UiState` + `UiEvent` + `UiEffect`. Naked state assignment (`_state.value = ...`) is explicitly banned.345346### Kotlin Multiplatform / Compose Multiplatform?347348See [`references/08-kmp-cmp.md`](references/08-kmp-cmp.md) — shared ViewModel, `expect`/`actual`, Ktor networking, SQLDelight vs Room.349350### Is this a Compose UI library or an Alexa skill?351352**No.** It's markdown instructions for coding AIs — clone with `git`, not `implementation(...)`. The word "skill" follows the [agentskills.io](https://agentskills.io) format, unrelated to voice assistants.353354---355356## Contributing357358PRs welcome — see [`.github/pull_request_template.md`](.github/pull_request_template.md).359360Every new sub-skill must:3613621. Live under `skills/<kebab-case-name>/SKILL.md` with valid frontmatter.3632. Pass `python3 scripts/validate_skills.py --strict`.3643. Be registered in [`AGENTS.md`](AGENTS.md#skill-catalog).3654. Bump [`api/skills.lock`](api/skills.lock) via `./scripts/update_lock.sh`.366367## License368369MIT — see [LICENSE](LICENSE).370371Author: **[haidrrrry](https://github.com/haidrrrry)**372