agentleFS
sledtoolssledtools/pika/.agents/skills/jetpack-compose-material3-expert-skill/SKILL.md

jetpack-compose-material3-expert-skill

Skill45 starsChanged 8 months agoMITView on GitHub

Write, review, or improve Jetpack Compose UI using Material Design 3, adaptive layout/navigation patterns, and modern Compose state/performance practices. Use when building new Android Compose screens, refactoring existing Compose code, auditing M3 theming, adapting UI for tablets/foldables, or aligning implementation with official Android guidance and the Reply sample app.

The file

Show its rules and text

We split this skill into the rules it gives an agent

28 rules. About 0 are common, 15 are distinctive, and 13 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 13

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill to implement and review Material 3 Compose code with strong defaults for theme architecture, adaptive navigation, state …

    line 10
  2. Very specific:

    Verify M3 theme setup and token usage (see references/material3-theming.md)

    line 15
  3. Very specific:

    Verify adaptive layout/navigation logic and size-class handling (see references/adaptive-navigation-layout.md)

    line 16
  4. Very specific:

    Verify state ownership and Flow collection patterns (see references/state-management.md)

    line 17
  5. Very specific:

    Verify recomposition and lazy list performance patterns (see references/performance-patterns.md)

    line 18
  6. Very specific:

    Verify accessibility semantics, touch targets, and contrast assumptions (see references/accessibility.md)

    line 19
  7. Distinctive:

    Add previews across multiple size classes and verify behavior parity

    line 36
  8. Very specific:

    Use lightColorScheme and darkColorScheme as baseline schemes

    line 42
  9. Very specific:

    Prefer semantic roles (primary, surfaceContainerHigh, onSurfaceVariant) over raw color literals

    line 44
  10. Distinctive:

    Keep component theming local unless a full-system token change is required

    line 45
  11. Distinctive:

    Treat width class as the primary branching signal.

    line 49
  12. Very specific:

    Use NavigationSuiteScaffold when automatic bar/rail/drawer switching is desired

    line 50
  13. Very specific:

    Keep local UI element state in remember / rememberSaveable

    line 56
  14. Very specific:

    Keep screen UI state in a dedicated holder (typically a ViewModel on Android)

    line 57
  15. Very specific:

    Use remember for expensive computations that should survive recomposition

    line 62
  16. Very specific:

    Use derivedStateOf for frequently changing inputs to limit downstream recompositions

    line 63
  17. Very specific:

    Always provide stable key values in LazyColumn/LazyRow

    line 64
  18. Distinctive:

    Avoid mutating state from a stale point in composition ("backwards writes")

    line 65
  19. Distinctive:

    Keep composables small and isolate changing state to reduce recomposition scope

    line 66
  20. Distinctive:

    Prefer Material components first.

    line 69
  21. Distinctive:

    Add meaningful descriptions for non-text interactive content

    line 70
  22. Distinctive:

    Ensure interactive elements maintain usable target sizes

    line 71
  23. Distinctive:

    Verify large text/scale behavior and traversal order in adaptive layouts

    line 73
  24. Distinctive:

    Use a wrapper layer to decide navigation shell type from adaptive info

    line 76
  25. Distinctive:

    Keep list/detail logic explicit for medium and expanded layouts

    line 78
  26. Distinctive:

    Prefer official Android APIs over custom abstractions when both solve the task

    line 151
  27. Distinctive:

    Keep architecture explicit and testable, not framework-heavy

    line 152
  28. Distinctive:

    Treat adaptive behavior as first-class product behavior, not a later patch

    line 153

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Jetpack Compose Material3 Expert Skill

Overview

Use this skill to implement and review Material 3 Compose code with strong defaults for theme architecture, adaptive navigation, state hoisting, performance, and accessibility. Prefer official Android APIs and naming, then use Reply sample patterns when choosing between multiple valid implementations.

Workflow Decision Tree

1) Review existing Compose code

  • Verify M3 theme setup and token usage (see references/material3-theming.md)
  • Verify adaptive layout/navigation logic and size-class handling (see references/adaptive-navigation-layout.md)
  • Verify state ownership and Flow collection patterns (see references/state-management.md)
  • Verify recomposition and lazy list performance patterns (see references/performance-patterns.md)
  • Verify accessibility semantics, touch targets, and contrast assumptions (see references/accessibility.md)
  • Compare architecture decisions against Reply sample patterns when relevant (see references/reply-sample-patterns.md)

2) Improve existing Compose code

  • Replace hardcoded visual values with semantic M3 tokens from MaterialTheme
  • Introduce dynamic color with API-level fallback if missing
  • Move navigation and pane selection to explicit adaptive logic
  • Hoist screen UI state to a state holder (ViewModel for screen-level concerns)
  • Introduce stable lazy-list keys and reduce unnecessary recomposition triggers
  • Fix accessibility gaps in roles, labels, and text/touch scaling behavior

3) Implement a new feature

  • Define theme contract first (color, typography, shapes, surface roles)
  • Define adaptive behavior by window width class and posture requirements
  • Choose navigation shell (NavigationSuiteScaffold or explicit bar/rail/drawer)
  • Define state model (UiState) and event contract before writing composables
  • Build composables as stateless UI + callbacks where practical
  • Add previews across multiple size classes and verify behavior parity

Core Guidelines

Material 3 Theming

  • Build a single app theme entry point with MaterialTheme(colorScheme, typography, shapes)
  • Use lightColorScheme and darkColorScheme as baseline schemes
  • Enable dynamic color on Android 12+ via dynamicLightColorScheme / dynamicDarkColorScheme, with explicit fallback
  • Prefer semantic roles (primary, surfaceContainerHigh, onSurfaceVariant) over raw color literals
  • Keep component theming local unless a full-system token change is required

Adaptive Layout and Navigation

  • Drive layout from current window size class, not device type assumptions
  • Treat width class as the primary branching signal; include height/posture where needed
  • Use NavigationSuiteScaffold when automatic bar/rail/drawer switching is desired
  • Customize navigation type when product ergonomics require different breakpoints
  • Handle foldable postures with FoldingFeature data when content can intersect a hinge

State and Data Flow

  • Hoist state to the lowest common ancestor that needs to read/write it
  • Keep local UI element state in remember / rememberSaveable
  • Keep screen UI state in a dedicated holder (typically a ViewModel on Android)
  • Expose immutable StateFlow for UI state and collect with collectAsStateWithLifecycle
  • Pass state and callbacks down; do not pass ViewModel instances deep into leaf composables

Performance

  • Use remember for expensive computations that should survive recomposition
  • Use derivedStateOf for frequently changing inputs to limit downstream recompositions
  • Always provide stable key values in LazyColumn/LazyRow
  • Avoid mutating state from a stale point in composition ("backwards writes")
  • Keep composables small and isolate changing state to reduce recomposition scope

Accessibility

  • Prefer Material components first; they include strong semantics defaults
  • Add meaningful descriptions for non-text interactive content
  • Ensure interactive elements maintain usable target sizes
  • Validate contrast and readability when overriding color roles
  • Verify large text/scale behavior and traversal order in adaptive layouts

Reply-Informed Patterns

  • Use a wrapper layer to decide navigation shell type from adaptive info
  • Separate content type (single-pane vs dual-pane) from navigation type
  • Keep list/detail logic explicit for medium and expanded layouts
  • Model screen state as a single UiState object published by StateFlow

Quick Reference

Window Width Classes

ClassWidth
Compact< 600dp
Medium600dp <= width < 840dp
Expanded840dp <= width < 1200dp
Large1200dp <= width < 1600dp
Extra-large>= 1600dp

Navigation Mapping (Common M3 Pattern)

ConditionTypical Navigation UI
Compact widthNavigationBar
Medium widthNavigationRail
Expanded/Large widthNavigationDrawer or PermanentNavigationDrawer

Dynamic Color with Fallback

val colorScheme = when {
    dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ->
        if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
    darkTheme -> darkColorScheme()
    else -> lightColorScheme()
}

Review Checklist

Theme

  • App theme defines colorScheme, typography, and shapes in one place
  • Dynamic color is API-gated and has light/dark fallback
  • UI uses semantic M3 roles instead of raw colors

Adaptive

  • UI behavior changes from WindowSizeClass (not device heuristics only)
  • Navigation shell is appropriate for compact/medium/expanded widths
  • Fold/posture handling exists where hinge overlap is possible
  • Preview coverage includes at least compact + medium + expanded scenarios

State

  • Screen UI state comes from a dedicated state holder
  • UI collects StateFlow with lifecycle awareness
  • Composables receive state and events, not deep ViewModel dependencies
  • rememberSaveable is used for restorable local UI element state

Performance

  • Expensive computations are cached with remember
  • Rapidly changing derived values use derivedStateOf when needed
  • Lazy lists use stable keys
  • No avoidable wide-scope recomposition triggers

Accessibility

  • Interactive elements are labeled and discoverable
  • Contrast remains valid after theme overrides
  • Typography/layout remain usable at larger font scales
  • Navigation and content order remain clear across adaptive layouts

References

  • references/material3-theming.md - M3 theme architecture, color roles, dynamic color
  • references/adaptive-navigation-layout.md - Window size classes, adaptive nav, fold posture
  • references/state-management.md - State hoisting, ViewModel boundaries, Flow collection
  • references/performance-patterns.md - Recomposition, lazy list keys, derived state, caching
  • references/accessibility.md - Compose accessibility checks and semantic guidance
  • references/reply-sample-patterns.md - File-level patterns from the Reply sample app

Philosophy

This skill optimizes for practical, production-safe Compose guidance:

  • Prefer official Android APIs over custom abstractions when both solve the task
  • Keep architecture explicit and testable, not framework-heavy
  • Treat adaptive behavior as first-class product behavior, not a later patch
  • Favor semantic M3 design tokens and accessibility by default

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.