developing-with-compose-previews

Implement preview-driven Jetpack Compose workflows with state hoisting and configuration-aware rendering.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/trancee/MeshLink-template --skill developing-with-compose-previews-trancee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: developing-with-compose-previews
Source: https://github.com/trancee/MeshLink-template/tree/main/.agents/skills/android-testing-skills/compose/preview/developing-with-compose-previews
Command: npx skills add https://github.com/trancee/MeshLink-template --skill developing-with-compose-previews-trancee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill solves the common issue of brittle, broken, or non-rendering Jetpack Compose previews caused by tight coupling with ViewModels, DI graphs, and complex dependencies.

Core Features & Use Cases

  • State Hoisting Patterns: Learn to structure composables so they are stateless and easily previewable without needing a full app environment.
  • Configuration Coverage: Use multipreview annotations and PreviewParameterProviders to render all UI states (loading, error, empty, RTL, dark mode) in one place.
  • Environment Isolation: Safely handle context-bound dependencies like image loaders using LocalInspectionMode to prevent preview crashes.

Quick Start

Use the developing-with-compose-previews skill to refactor a screen-level composable into a stateless component and generate a comprehensive set of preview states.

Frequently Asked Questions about developing-with-compose-previews

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why do my Jetpack Compose previews crash when using ViewModels or dependency injection?

Jetpack Compose previews crash when composables are tightly coupled to ViewModels or DI graphs. Refactoring into stateless components using state hoisting isolates these dependencies, enabling high-fidelity component visualization without a full application build.

How do I render all Jetpack Compose UI states like dark mode and error states in one place?

To render all Jetpack Compose UI states in one place, apply multipreview annotations and PreviewParameterProviders. This configuration-aware rendering approach displays loading, error, empty, RTL, and dark mode states simultaneously for robust preview-based UI testing.

What is state hoisting in Jetpack Compose and how does it improve UI previews?

State hoisting in Jetpack Compose structures composables to be stateless by moving state ownership upward. This pattern improves UI previews by removing dependencies on complex application environments, allowing realistic sample data injection for direct component visualization.

How do I prevent preview crashes from context-bound dependencies like image loaders in Jetpack Compose?

Prevent context-bound dependency crashes in Jetpack Compose previews by safely handling environment isolation. Use LocalInspectionMode to detect the preview environment and provide mock implementations for context-bound dependencies like image loaders.

Does preview-driven development work for screen-level composables in Android UI modules?

Yes, preview-driven development effectively optimizes Android UI modules by refactoring screen-level composables into stateless components. This workflow generates a comprehensive set of preview states without requiring full application builds.

What are the limitations of using LocalInspectionMode for Compose preview environment isolation?

LocalInspectionMode limitations require you to manually mock context-bound dependencies during environment isolation. While it prevents preview crashes, you must ensure realistic sample data injection to maintain accurate preview-based UI testing across all configuration states.