medium-post.md
.codex/skills/compose-kotlin-agent-skills/marketing/medium-post.md
1# Medium Article Draft23Long-form, SEO-friendly, 8-minute read. Copy-paste into Medium editor.4Add the logo (`assets/logo.png`) as the cover image. Tag with: **Android, Kotlin, Jetpack Compose, AI, Cursor, Claude.**56---78# I Stopped Letting AI Agents Write Broken Kotlin — Here's the Skill Kit That Fixed It910**Strict MVI, banned antipatterns, and 27 agent install guides — all in one markdown kit you clone into `.cursor/skills/` or `.claude/skills/`.**1112---1314## The problem nobody talks about1516Cursor, Claude Code, Codex, Gemini, Copilot — they all write Kotlin/Compose code that **compiles** but ships bugs you only catch in production.1718Here is the list I kept reverting on every PR:1920- `_state.value = newState` — race condition, lost updates under concurrency.21- `collectAsState()` on a screen — keeps the Flow collector alive in the background and drains battery.22- Hardcoded `"Login"` literals — breaks localisation the moment QA opens a non-English build.23- `LazyColumn(items)` without `key { it.id }` — broken scroll position, recomposition storms, focus loss.24- `GlobalScope.launch { }` inside a ViewModel — leaks the coroutine past the screen lifecycle.25- `mutableStateListOf` as ViewModel state — survives config changes incorrectly.26- String-based `NavHost(route = "home/{id}")` — deprecated by Navigation 3.2728Every Android engineer reading this is nodding. AI agents have read the same shallow blog posts you and I read in 2021, and they regurgitate the same broken patterns five years later.2930I shipped three Android apps in the last year — [AnimatedClockJetpacl](https://github.com/haidrrrry/AnimatedClockJetpacl), [Authenticator](https://github.com/haidrrrry/Authenticator), and [RepLock](https://github.com/haidrrrry/RepLockPushupAppBlocker) — and I spent more time fixing my agent's Kotlin than writing my own.3132So I built a fix.3334---3536## Introducing `compose-kotlin-agent-skills`3738A markdown-only skill kit your AI coding agent reads **before** writing a single line of Kotlin.3940**Repo:** https://github.com/haidrrrry/compose-kotlin-agent-skills41**License:** MIT42**Install:** one `git clone` into your agent's skills folder.4344It teaches your agent:45461. **The 2026 Android toolchain** — Kotlin 2.x K2 compiler, AGP 9, Compose BOM 2026, Navigation 3, edge-to-edge by default.472. **Strict MVI** — atomic `_state.update { it.copy(...) }`, `UiState` + `UiEvent` + `UiEffect`. Naked state assignment is explicitly banned.483. **A banned-antipatterns table** — every wrong pattern paired with the correct fix in a side-by-side block.494. **Decision matrices** — `StateFlow` vs `SharedFlow` vs `Channel`, Hilt vs Koin, Room vs DataStore, Compose Navigation vs Nav 3.505. **Production gotchas** — bugs that only appear after Play Store rollout (R8 reflection, baseline profile drift, recomposition storms).5152---5354## How it works5556Three layers, loaded on demand:5758```59SKILL.md (routing hub + guardrails)60 |61 v62sub-skills/63 ├── architecture (Clean Arch, MVI, modules)64 ├── compose (UI, recomposition, M3, edge-to-edge)65 └── testing (Turbine, Hilt fakes, Compose UI tests)66 |67 v68references/ (13 deep dives)69 ├── 01-architecture.md70 ├── 02-compose-ui.md71 ├── 03-animations.md72 ├── 04-coroutines-flow.md73 ├── 05-hilt-di.md74 ├── 06-room-db.md75 ├── 07-navigation.md76 ├── 08-kmp-cmp.md77 ├── 09-networking.md78 ├── 10-performance.md79 ├── 11-testing.md80 ├── 12-camera-mlkit.md81 └── 13-release-checklist.md82```8384When you ask Cursor or Claude Code _"how should I structure this ViewModel?"_, the agent reads `SKILL.md`, follows the routing rules, loads the architecture sub-skill, and pulls `references/01-architecture.md` for the deep dive.8586It then writes Kotlin that looks like this:8788```kotlin89@Immutable90data class FeatureUiState(91 val items: List<ItemUi> = emptyList(),92 val isLoading: Boolean = false,93 val error: UiError? = null94)9596sealed interface FeatureUiEvent {97 data object Refresh : FeatureUiEvent98 data class SearchChanged(val query: String) : FeatureUiEvent99}100101@HiltViewModel102class FeatureViewModel @Inject constructor(103 private val repository: FeatureRepository104) : ViewModel() {105 private val _state = MutableStateFlow(FeatureUiState())106 val state: StateFlow<FeatureUiState> = _state.asStateFlow()107108 fun onEvent(event: FeatureUiEvent) {109 when (event) {110 FeatureUiEvent.Refresh -> refresh()111 is FeatureUiEvent.SearchChanged -> _state.update {112 it.copy(query = event.query)113 }114 }115 }116117 private fun refresh() {118 viewModelScope.launch {119 _state.update { it.copy(isLoading = true) }120 runCatching { repository.fetch() }121 .onSuccess { items -> _state.update { it.copy(items = items, isLoading = false) } }122 .onFailure { e -> _state.update { it.copy(error = UiError.from(e), isLoading = false) } }123 }124 }125}126```127128Not `_state.value = …`. Not `GlobalScope`. Not `collectAsState()` on the Composable. Every piece follows the guardrails.129130---131132## What changes when you install it133134| Area | Without the kit | With the kit |135|---|---|---|136| ViewModel state | `_state.value = ...` | Atomic `_state.update { it.copy(...) }` |137| Flow collection | `collectAsState()` | `collectAsStateWithLifecycle()` |138| UI text | Hardcoded `"Login"` | `stringResource(R.string.login)` |139| Lists | `LazyColumn` no key | Stable `key` + `contentType` per item |140| Architecture | Mixed MVVM, state in Composable | Strict MVI — `UiState` / `UiEvent` / `UiEffect` |141| DI | `companion object Singleton` | `@HiltViewModel` + constructor injection |142| Navigation | String routes | Navigation 3 `NavKey` types |143| Coroutines | `GlobalScope.launch { }` | `viewModelScope` + structured concurrency |144| Edge-to-edge | Status bar overlap | `enableEdgeToEdge()` + correct insets |145146---147148## Install in 30 seconds149150### Cursor151152```bash153git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git \154 .cursor/skills/compose-kotlin-agent-skills155```156157Cursor auto-discovers `.cursor/skills/*/SKILL.md`.158159### Claude Code160161```bash162git clone https://github.com/haidrrrry/compose-kotlin-agent-skills.git \163 ~/.claude/skills/compose-kotlin-agent-skills164```165166Then add a five-line block to your `CLAUDE.md` — example in `agents/claude.md`.167168### Codex CLI / Gemini CLI / Copilot / Windsurf / Kimi / DeepSeek / 21 more169170Every agent gets a dedicated install guide in [`agents/`](https://github.com/haidrrrry/compose-kotlin-agent-skills/tree/main/agents). 27 total at time of writing.171172---173174## CI-validated, so the rules stay honest175176A markdown skill kit that lies to your agent is worse than no skill kit. So the repo ships:177178- `scripts/validate_skills.py` — frontmatter linter + internal link checker + md5 registry.179- `api/skills.lock` — every `SKILL.md` registered with its hash. CI fails on undocumented add / remove / edit.180- `.github/workflows/skill-lint.yml` — runs on every push and pull request, uploads JUnit XML, prints fix hints on failure.181182Editing any `SKILL.md` is one helper script:183184```bash185./scripts/update_lock.sh186```187188Commit the lock file with your change. CI stays green.189190---191192## What this is NOT193194I get DMs asking "is this a Compose UI library?" — no.195196| Wrong guess | Reality |197|---|---|198| Android library you `implementation(...)` in Gradle | No. Nothing to import. Pure markdown. |199| Alexa / Bixby "skill" | No. The word "skill" follows the [agentskills.io](https://agentskills.io) format, not voice assistants. |200| On-device LLM SDK | No. Zero model inference, zero agent framework code. |201| Compose UI library (coachmarks, theming, charts) | No. We do not ship Composables. We teach how to write them. |202203**TL;DR:** clone the repo into your agent's skills folder. The agent reads it before writing Kotlin. That is the entire product.204205---206207## What's next208209Q3 2026 plans:210211- Split `references/08-kmp-cmp.md` into its own sub-skill with a Ktor + SQLDelight matrix.212- Pull `references/12-camera-mlkit.md` into a dedicated CameraX/ML Kit sub-skill.213- Auto-extract every code block in `references/` into a Gradle project that compiles in CI.214- A "self-test" prompt suite — golden agent transcripts replayed against a frozen model.215216Full roadmap → [`ROADMAP.md`](https://github.com/haidrrrry/compose-kotlin-agent-skills/blob/main/ROADMAP.md)217218---219220## Contributing221222PRs welcome — especially new banned antipatterns you have caught your agent doing.223224Every new sub-skill must:2252261. Live under `skills/<kebab-name>/SKILL.md` with valid frontmatter.2272. Pass `python3 scripts/validate_skills.py --strict`.2283. Be registered in `AGENTS.md`.2294. Bump `api/skills.lock` via `./scripts/update_lock.sh`.230231PR template enforces all four.232233---234235## Closing236237Your AI agent is going to keep shipping `GlobalScope.launch { }` until you give it a playbook that says no. This is mine. Clone it, fork it, ship better Kotlin.238239⭐ **Star on GitHub:** https://github.com/haidrrrry/compose-kotlin-agent-skills240241If your agent has invented a new way to break MVI that I have not banned yet, open an issue. Genuinely curious.242243— [Haider Ali Khan](https://github.com/haidrrrry)244245---246247**Tags (paste these on Medium):** Android, Kotlin, Jetpack Compose, Cursor, Claude AI, AI Coding, Software Engineering, Mobile Development248249---250251## Distribution checklist252253- [ ] Cover image set to `assets/logo.png`254- [ ] Subtitle filled in (Medium prompts for one)255- [ ] Tags: Android, Kotlin, Jetpack Compose, Cursor, Claude256- [ ] Publish to a Medium publication if you have one (Better Programming, Android Bits, Proandroiddev) — 10x reach vs personal blog257- [ ] After publishing, tweet the URL with the cover image258- [ ] Cross-post the same draft on dev.to with `#android #kotlin #jetpackcompose #ai`259- [ ] Submit to https://androidweekly.net/issues — free curated newsletter, 90k+ Android devs260- [ ] Submit to https://kotlinweekly.net/ — 30k+ Kotlin devs261