Skip to content
Back to skills

Android Compose

ASecurity

Build a Jetpack Compose screen with hoisted state and a ViewModel

  • 3 stars
  • 0 votes
  • 0 copies
  • 8 views
  • Added September 3, 2026
ai-agentsgonode

Works with

  • cli

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add black141312/ada --skill android-compose --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Android Compose?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Android Compose
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/black141312-android-compose/badge)](https://www.skillsdirectory.com/skills/black141312-android-compose)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: android-compose
description: Build a Jetpack Compose screen with hoisted state and a ViewModel
category: mobile
---

# Android Compose

Use this when building a screen in Jetpack Compose, separating stateless composables from the state held in a `ViewModel` and exposed as `StateFlow`.

1. Write the screen as a `@Composable` function in PascalCase that takes its state and event lambdas as parameters (state hoisting), keeping it stateless and previewable.
2. Hold real state in a `ViewModel` exposed via `StateFlow`/`MutableStateFlow`, and collect it with `collectAsStateWithLifecycle()`.
3. For purely local UI state (expanded, text input) use `remember { mutableStateOf(...) }`, and `rememberSaveable` for state that must survive config changes.
4. Provide a route composable that pulls the `ViewModel` (`viewModel()` / Hilt) and passes state + callbacks down into the stateless screen.
5. Use `Modifier` for layout/styling, scaffold structure with `Scaffold`/`Column`/`LazyColumn`, and pull colors from `MaterialTheme`.
6. Add an `@Preview` composable with sample state, then verify recomposition and clicks with a Compose UI test (`createComposeRule`, `onNodeWithText`).

## Rules
- Hoist state up and keep leaf composables stateless so they're easy to preview and test.
- Never read or mutate `mutableStateOf` outside composition without `remember` — it resets every recomposition.
- Keep composables side-effect free; launch coroutines via `LaunchedEffect`/`rememberCoroutineScope`, not inline in the body.
- Pass stable types and lambdas to avoid needless recomposition; use `key` in lazy lists.
- Don't hold Android `Context`/`Activity` references in a `ViewModel`; survive rotation via the ViewModel, not the composable.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…