santimattius/performance-compose-skills/compose-previews-tooling
Claude Code and agent skill by santimattius/performance-compose-skills
- community
Checking that the SKILL.md file is still in the repository.
Jetpack Compose previews, tooling, and performance profiling: @Preview, @PreviewWrapper, @PreviewParameter, screenshot testing, Compose Compiler Reports, Composition Tracing, Layout Inspector, and Macrobenchmark. Trigger: when working with @Preview, @PreviewWrapper, @PreviewParameter, screenshot testing, Paparazzi, Roborazzi, Baseline Profiles, Compose Compiler Reports, Layout Inspector, Composition Tracing, or Macrobenchmark.
Install
npx vskill@latest install santimattius/performance-compose-skills/compose-previews-toolingSKILL.md
Performance First
Every Compose frame runs three phases. Cost rises left-to-right; restart scope shrinks left-to-right.
| Phase | What Runs | Restart Cost | Trigger | |
|---|---|---|---|---|
| Composition | Composable functions, state reads | HIGH (whole scope) | State read in composable body | |
| Layout | Measure + place | MEDIUM (subtree) | State read in measure lambda | |
| Drawing | Canvas commands, graphicsLayer | LOW (single node) | State read in draw/graphicsLayer lambda |
Defer State Reads (decision tree)
Do you need the value during composition?
- YES → read as
T(Composition phase) — accept full restart cost - NO → can you defer to layout/draw?
- Layout-only? → pass
() -> TintoModifier.layout/offset { }lambda - Draw/transform? → pass
() -> TintoModifier.graphicsLayer { }/drawBehind { }lambda
Rule: prefer Modifier.offset { lambda } over Modifier.offset(state.value.dp). Lambda variant defers the read to the layout phase, skipping recomposition entirely.
Profile-in-Release Mandate
CRITICAL: Previews run in the same JVM/LayoutLib environment as debug builds — they do NOT reflect release performance. Debug and preview environments disable R8, inlining, and Strong Skipping Mode, making ALL numbers meaningless for performance. NEVER use debug builds or Previews as a performance baseline. Always profile areleaseorbenchmarkbuild type on a real device.
Performance Toolchain
WARNING: NEVER profile in debug builds. Debug disables R8, inlining, and Strong Skipping — numbers are meaningless. Always profile a release build withprofileableenabled or a benchmark build type.
| Tool | Use For | When | |
|---|---|---|---|
| Baseline Profiles | AOT-compile critical paths (startup, scroll) | Ship in release; regenerate per release | |
| Compose Compiler Reports | Detect unstable params, restartable/skippable status | Every PR; fail CI on new unstable types | |
| Layout Inspector (recomposition counts) | See which composables recompose and why | When debugging excess recomposition | |
| Composition Tracing | Frame-level composition timing in Android Studio | When Layout Inspector is not enough | |
| Macrobenchmark | Measure startup, frame timing, jank in release | Per-release regression gate |
When to Use
Use this skill when:
- Writing or configuring
@Previewfor a composable - Wrapping all previews with a custom theme using
@PreviewWrapper - Creating data-driven previews with
@PreviewParameter - Deciding between screenshot testing libraries (Paparazzi vs Roborazzi vs instrumented)
- Enabling or interpreting Compose Compiler Reports (stability analysis)
- Adding Composition Tracing to diagnose frame-timing problems
- Setting up Layout Inspector for recomposition count debugging
- Configuring Macrobenchmark for performance regression gates
CMP Applicability
Canonical CMP rules: `../_shared/cmp-platform.md`
| Source set | Status | Notes | |
|---|---|---|---|
commonMain | ⚠️ | JetBrains @Preview ✅; runComposeUiTest ✅; Paparazzi/Macrobenchmark/Layout Inspector ❌ | |
androidMain | ✅ | Full skill content applies; Android Studio @Preview + all tooling available | |
iosMain | ⚠️ | JetBrains @Preview ✅ (Fleet/IJ); Compose Hot Reload ✅; use Instruments for profiling | |
desktopMain | ⚠️ | JetBrains @Preview ✅; Compose Hot Reload ✅; use JFR/JVisualVM for profiling | |
wasmJsMain | ⚠️ | JetBrains @Preview ✅ (limited); use Chrome DevTools for profiling |
Status legend: ✅ fully supported · ⚠️ partial / version-gated · ❌ Android-only.
Android-only tools (do NOT suggest for CMP non-Android targets):
- Paparazzi — Android/JVM renderer only
- Macrobenchmark — requires Android device/emulator
- Baseline Profiles — AGP + Android only
- Layout Inspector — Android Studio only
CMP-compatible tools: JetBrains @Preview (CMP 1.5+, Fleet/IJ), Compose Hot Reload (experimental), runComposeUiTest (commonTest), Compose Compiler Reports (all targets), Roborazzi ⚠️ (1.7+, Android JVM runner).
See full tooling matrix: `references/cmp-tooling-matrix.md`.
Critical Patterns
1. @PreviewWrapper + PreviewWrapperProvider — New April 2026
NEW April 2026 — NOT in pre-2026 docs:@PreviewWrapperwas introduced in April 2026. Do not expect it in documentation predating this date.
@PreviewWrapper lets you define a single composable wrapper that is automatically applied to ALL @Preview annotations in the module. This eliminates the need to manually wrap every preview with your theme.
Without @PreviewWrapper, every preview file manually wraps content in the theme, causing drift when the theme signature changes.
2. @PreviewParameter — Data-Driven Previews
@PreviewParameter generates one preview instance per value in the provider, covering multiple states automatically.
Decision: use @PreviewParameter for components with distinct state variants (loading/success/error). Do NOT use it for exhaustive enum coverage that would produce >10 previews — that degrades IDE performance.
3. Screenshot Testing — ALPHA Warning
ALPHA — Screenshot Testing Activity (androidx.compose.ui.test.screenshot): 0.0.1-alpha14: API may break between releases. Requires AGP 8.5+ for full functionality; AGP 9.0+ for IDE integration. Prefer Paparazzi or Roborazzi for production CI pipelines.
Decision tree for screenshot library:
4. Profile-in-Release Mandate
Debug builds disable:
- R8 optimization (code shrinking + inlining)
- Strong Skipping Mode (all lambdas treated as unstable)
- Compose Compiler optimizations
Result: any performance number from a debug build is meaningless for production decisions. Configure benchmark build type:
5. Compose Compiler Reports
Reports show stability status of every composable's parameters. Run ONLY on release/benchmark builds.
Interpret the output:
restartable— composable can skip if inputs unchanged (good)skippable— composable WILL skip on recomposition if stable inputs unchanged (best)unstable— composable ALWAYS recomposes (investigate)
6. Composition Tracing — ProGuard Rule for Release
Composition Tracing inserts trace markers for Android Studio's CPU Profiler. These markers must NOT be stripped by R8 in release builds.
Add the runtime-tracing artifact:
7. Layout Inspector Requirements
- Android device/emulator: API 29+
- Compose: 1.2+
- Enable:
View > Tool Windows > Layout Inspectorin Android Studio
Use it to inspect:
- Recomposition counts per composable (shows which ones fire excessively)
- Semantics tree (for accessibility debugging)
- Layer hierarchy and modifier chains
Pitfalls
| Pitfall | Fix | Phase Cost | |
|---|---|---|---|
| Profiling in debug build | Switch to benchmark or release build type | Numbers are meaningless | |
| Wrapping each preview with theme manually | Use @PreviewWrapper (April 2026+) | Maintenance drift | |
Using @PreviewParameter with >10 values | Limit to meaningful state variants | IDE preview rendering degradation | |
Screenshot tests via alpha androidx.compose.ui.test.screenshot on CI | Use Paparazzi or Roborazzi for stable CI | API may break on alpha update | |
| Composition Tracing stripped by R8 | Add ProGuard keep rule | Traces missing in profiler | |
| Running Layout Inspector on API <29 | Requires API 29+ device | Inspector not available | |
| Running Compiler Reports on debug build | Append :assembleRelease | Reports reflect unoptimized code |
Code Examples
Full Preview Setup with @PreviewWrapper
Paparazzi Screenshot Test
Commands
Related Skills
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/compose-previews-tooling/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/santimattius/performance-compose-skills/compose-previews-tooling)