Home › Android / Kotlin › Android Jetpack Compose AGENTS.md
Android Jetpack Compose AGENTS.md
AGENTS.md for Android apps in Kotlin 2 with Jetpack Compose, ViewModel + StateFlow, Hilt, and Room.
AGENTS.mdAndroid / Kotlin
How to use
Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.
AGENTS.mdDownload # AGENTS.md: Android (Kotlin + Compose)
## Commands
`./gradlew assembleDebug` · `./gradlew testDebugUnitTest` · `./gradlew lint` · `./gradlew ktlintCheck` (or `detekt`, whichever exists)
## Architecture
- UI in Compose only; no new XML layouts or Fragments.
- Each screen: `FooScreen` (stateless composable taking state + lambdas) and `FooRoute` that gets the `FooViewModel` via `hiltViewModel()`.
- ViewModels expose one `StateFlow<FooUiState>` (immutable data class) and accept events as functions. Collect with `collectAsStateWithLifecycle()`.
- Data flows Repository -> ViewModel -> UI. Repositories return `Flow` or `suspend` results and own the Room DAO and Retrofit/Ktor service.
- Coroutines: `viewModelScope`, inject dispatchers, never `GlobalScope` or `runBlocking` in app code.
- Dependency injection with Hilt (`@HiltViewModel`, `@Inject constructor`).
- Navigation Compose with type-safe `@Serializable` routes.
- Dependencies go in `gradle/libs.versions.toml` (version catalog), not hard-coded versions.
## Compose rules
- Hoist state; pass `Modifier` as the first optional parameter.
- Use `remember`/`derivedStateOf` for expensive calculations; stable keys in `LazyColumn` `items(key = { it.id })`.
- Strings in `strings.xml`, colors from `MaterialTheme`. Content descriptions on icons.
## Done
Build, unit tests, and lint pass. Add `@Preview` for new composables.