Best use case
jetpack-compose is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Jetpack Compose Android declarative UI. Use for Android.
Teams using jetpack-compose should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/jetpack-compose/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How jetpack-compose Compares
| Feature / Agent | jetpack-compose | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Jetpack Compose Android declarative UI. Use for Android.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Jetpack Compose
Jetpack Compose is Android's modern toolkit for building native UIs. It simplifies and accelerates UI development on Android with less code, powerful tools, and intuitive Kotlin APIs.
## When to Use
- New Android application development (Grid/List content, complex layouts).
- Migrating existing View-based apps incrementally (Interoperability).
- Sharing UI logic with Kotlin Multiplatform (Compose Multiplatform).
## Quick Start
```kotlin
// build.gradle.kts needs composed enabled
// MainActivity.kt
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.lifecycle.viewmodel.compose.viewModel
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
MyApp()
}
}
}
}
@Composable
fun MyApp(viewModel: CounterViewModel = viewModel()) {
// Collecting state from ViewModel
val count by viewModel.uiState.collectAsState()
Scaffold(
floatingActionButton = {
FloatingActionButton(onClick = { viewModel.increment() }) {
Text("+")
}
}
) { padding ->
Text(
text = "Count: $count",
modifier = Modifier.padding(padding)
)
}
}
```
## Core Concepts
### Composable Functions
Functions annotated with `@Composable` are the building blocks. They describe specialized UI widgets or layouts. They can call other Composables.
### Recomposition
When the state of a Composable changes, the framework re-executes the function to update the UI. Smart logic ensures only necessary parts are redrawn.
### Modifiers
The `Modifier` object allows you to decorate or augment a composable (layout, appearance, interactions, etc.). They are chainable and order-sensitive.
## Common Patterns
### State Hoisting
State should be moved up to the caller to make components stateless and reusable.
- **Stateful**: Owns state (`remember { mutableStateOf(...) }`).
- **Stateless**: Receives state as parameters and emits events via lambdas.
### ViewModel & StateFlow
Use `ViewModel` to hold business logic and expose screen state via `StateFlow` or `Compose State`. Collect it in the UI using `collectAsStateWithLifecycle()`.
### Navigation Compose
Define a `NavHost` with composable destinations. Pass arguments and navigate using a type-safe approach (library dependent) or string routes (default).
## Best Practices
**Do**:
- Use **Material 3** (`androidx.compose.material3`) for the latest design specs.
- Use `remember` and `derivedStateOf` to optimize performance.
- Use `LazyColumn` / `LazyRow` for lists (equivalent to RecyclerView).
- Use `Preview` annotations to visualize UI without running the app.
**Don't**:
- Don't perform expensive operations in the composition phase (use `LaunchedEffect` or `ViewModel`).
- Don't create state inside a loop.
- Don't ignore the `Modifier` parameter in reusable components (always allow caller to pass one).
## Troubleshooting
| Error | Cause | Solution |
| :-------------------------------------------------------- | :------------------------------------------------------------------- | :---------------------------------------------------------------- |
| `@Composable invocations can only happen from context...` | Calling a composable from a standard function. | Add `@Composable` annotation to the caller. |
| Infinite Recomposition | Updating state inside the composition without a side-effect wrapper. | Move update logic to a callback or `SideEffect`/`LaunchedEffect`. |
| `ViewModel` state not updating UI | Using a non-observable type or forgetting `collectAsState`. | Use `StateFlow`/`MutableState` and collect it properly. |
## References
- [Jetpack Compose Documentation](https://developer.android.com/jetpack/compose)
- [Compose Material 3](https://developer.android.com/jetpack/compose/designsystems/material3)
- [Accompanist Libraries](https://google.github.io/accompanist/)Related Skills
template
Expert [skill-name] assistance covering [feature 1], [feature 2], and [feature 3]. Use when [working with X], [debugging Y], or [implementing Z].
zsh
Zsh shell with oh-my-zsh. Use for terminal shell.
zed
Zed high-performance collaborative editor. Use for fast editing.
xcode
Xcode Apple development IDE with simulators. Use for iOS/macOS development.
webstorm
WebStorm JavaScript IDE with debugging. Use for web development.
webpack
Webpack module bundler with loaders and plugins. Use for bundling.
warp
Warp modern terminal with AI. Use for terminal work.
vscode
Visual Studio Code editor with extensions and debugging. Use for code editing.
vite
Vite fast build tool with HMR. Use for modern frontend builds.
visual-studio
Visual Studio IDE for Windows with debugging and profiling. Use for .NET development.
vim
Vim text editor with motions, macros, and plugins. Use for terminal editing.
turbopack
Turbopack Rust-powered bundler. Use for fast builds.