Agent skill
kotlin-composable-preview
Generate comprehensive @Preview functions for Jetpack Compose composables. Analyzes component parameters, states, and dependencies to create previews covering all visual states, edge cases, and configurations.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/kotlin-composable-preview
SKILL.md
Kotlin Composable Preview Generator
Skill for generating production-quality @Preview functions for Jetpack Compose UI components.
When to Use
- Adding previews to new Composable functions
- Enhancing existing previews with more state coverage
- Creating previews for components with sealed class states
- Generating multi-configuration previews (light/dark, device sizes)
Preview Categories
- Simple Preview - Basic single-state preview
- Multi-State Preview - Separate @Preview for each state (sealed class, enum)
- Variant Preview - Column/Row showing all variants in one preview
- Interactive Preview - Using PreviewParameter for data-driven previews
- Configuration Preview - Device, font scale, UI mode configurations
Generation Workflow
-
Analyze Composable signature
- Extract parameters (required/optional)
- Identify state classes (data class, sealed class, enum)
- Find callback parameters (lambdas)
-
Identify preview requirements
- Check for HazeState dependency → needs hazeSource setup
- Check for modifier patterns → use appropriate sizing
- Check for sealed class states → generate preview for each subtype
-
Generate previews
- Follow naming:
{ComposableName}Preview,{ComposableName}{State}Preview - Use
privatemodifier for preview functions - Add dark background wrapper when needed
- Provide realistic sample data
- Follow naming:
Preview Patterns Reference
See references/preview-patterns.md for detailed examples.
Output Guidelines
| Aspect | Guideline |
|---|---|
| Naming | {ComposableName}Preview, {ComposableName}{State}Preview |
| Visibility | private for preview functions |
| Background | Use Box(Modifier.background(Black)) for dark-themed components |
| HazeState | Use rememberHazeState() + hazeSource() setup |
| Callbacks | Use empty lambdas {} for onClick, onDismiss |
| Sample Data | Use realistic Vietnamese text when appropriate |
Quality Checklist
- All sealed class/enum states have dedicated previews
- Required parameters have realistic sample values
- Preview renders correctly in Android Studio
- Dark backgrounds used for dark-themed components
- HazeState properly configured when needed
- Proper imports added
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?