Automated summary
Best-practices guide for writing and refactoring Jetpack Compose Composables, covering state hoisting, performance optimization and Material theming.
Strengths
- Provides a concrete Composable signature pattern with state hoisting and a modifier parameter
- Explains specific optimizations such as derivedStateOf and lambda stability
- Covers ViewModel integration via collectAsStateWithLifecycle plus Light/Dark previews
Limitations
- Does not address navigation, animations or Compose UI testing
- Assumes prior familiarity with Kotlin and the Android ecosystem
- Modifier-ordering advice stays brief and lacks worked examples
Use it when writing a new Composable or refactoring an existing Compose screen to be more testable and performant.
Skip it for non-UI architecture concerns such as networking, persistence or ViewModel unit testing.
Security analysis
SafeThe skill is purely instructional documentation about Jetpack Compose UI patterns. It declares no tools, contains no executable commands, no network/curl/fetch operations, no file deletion, and no credential or environment handling. There is no obfuscated payload or instruction to bypass safety mechanisms, so listing it carries no meaningful execution risk.
No concerns found
How this analysis is madeExamples
Refactor this Composable so it is stateless: hoist its internal state into the caller and add a modifier parameter applied to the root layout.My list recomposes on every scroll frame; use derivedStateOf so the 'Jump to top' button only reacts when the first visible item changes from 0.Add a private @Preview for this public Composable with dummy data, including a dark-mode preview.name: compose-ui description: Best practices for building UI with Jetpack Compose, focusing on state hoisting, detailed performance optimizations, and theming. Use this when writing or refactoring Composable functions.
Jetpack Compose Best Practices
Instructions
Follow these guidelines to create performant, reusable, and testable Composables.
1. State Hoisting (Unidirectional Data Flow)
Make Composables stateless whenever possible by moving state to the caller.
- Pattern: Function signature should usually look like:
@Composable fun MyComponent( value: String, // State flows down onValueChange: (String) -> Unit, // Events flow up modifier: Modifier = Modifier // Standard modifier parameter ) - Benefit: Decouples the UI from simple state storage, making it easier to preview and test.
- ViewModel Integration: The screen-level Composable retrieves state from the ViewModel (
viewModel.uiState.collectAsStateWithLifecycle()) and passes it down.
2. Modifiers
- Default Parameter: Always provide a
modifier: Modifier = Modifieras the first optional parameter. - Application: Apply this
modifierto the root layout element of your Composable. - Ordering matters:
padding().clickable()is different fromclickable().padding(). Generally apply layout-affecting modifiers (like padding) after click listeners if you want the padding to be clickable.
3. Performance Optimization
remember: Useremember { ... }to cache expensive calculations across recompositions.derivedStateOf: UsederivedStateOf { ... }when a state changes frequently (like scroll position) but the UI only needs to react to a threshold or summary (e.g., show "Jump to Top" button). This prevents unnecessary recompositions.val showButton by remember { derivedStateOf { listState.firstVisibleItemIndex > 0 } }- Lambda Stability: Prefer method references (e.g.,
viewModel::onEvent) or remembered lambdas to prevent unstable types from triggering recomposition of children.
4. Theming and Resources
- Use
MaterialTheme.colorSchemeandMaterialTheme.typographyinstead of hardcoded colors or text styles. - Organize simple UI components into specific files (e.g.,
DesignSystem.ktorComponents.kt) if they are shared across features.
5. Previews
- Create a private preview function for every public Composable.
- Use
@Preview(showBackground = true)and include Light/Dark mode previews if applicable. - Pass dummy data (static) to the stateless Composable for the preview.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/jetpack-compose-best-practices-msv9axca' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/jetpack-compose-best-practices-msv9axca/download' --output '.skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md.part' && mv '.skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md.part' '.skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md' && test -s '.skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/compose-ui' && cp -R '.skill-downloads/jetpack-compose-best-practices-msv9axca' '.claude/skills/compose-ui'Cursor
test -f '.skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md' && test -s '.skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/compose-ui' && cp -R '.skill-downloads/jetpack-compose-best-practices-msv9axca' '.cursor/skills/compose-ui'Codex
test -f '.skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md' && test -s '.skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/compose-ui' && cp -R '.skill-downloads/jetpack-compose-best-practices-msv9axca' '.agents/skills/compose-ui'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/jetpack-compose-best-practices-msv9axca'openskills read 'jetpack-compose-best-practices-msv9axca'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/jetpack-compose-best-practices-msv9axca/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.