Skip to content
Skillpedia
Mobile apps48k · #2128

android-jetpack-compose-expert

Guides creating Android user interfaces with Jetpack Compose. It helps with state management and design.

What it does

This guide helps build modern user interfaces for Android apps using Jetpack Compose. It teaches how to organize code, manage changing information on the screen, navigate between screens, and optimize performance.

When to use it

  • ✓When starting a new Android app with Jetpack Compose.
  • ✓When migrating old layouts (XML) to the new Compose system.
  • ✓When creating complex features that need constant screen updates.

Example of what to ask your AI

“How can I set up type-safe navigation between screens in my Android app with Jetpack Compose?”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/android-jetpack-compose-expert/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/android-jetpack-compose-expert/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

It provides code examples and explanations on how to use Jetpack Compose components, like `ViewModel` for managing data and `NavHost` for navigation. The goal is to write cleaner and more efficient code.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add sickn33/agentic-awesome-skills --skill android-jetpack-compose-expert

Or download just the file:

curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/android-jetpack-compose-expert/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Android Jetpack Compose Expert

Overview

A comprehensive guide for building production-quality Android applications using Jetpack Compose. This skill covers architectural patterns, state management with ViewModels, navigation type-safety, and performance optimization techniques.

When to Use This Skill

  • Use when starting a new Android project with Jetpack Compose.
  • Use when migrating legacy XML layouts to Compose.
  • Use when implementing complex UI state management and side effects.
  • Use when optimizing Compose performance (recomposition counts, stability).
  • Use when setting up Navigation with type safety.

Step-by-Step Guide

1. Project Setup & Dependencies

Ensure your libs.versions.toml includes the necessary Compose BOM and libraries.

[versions]
composeBom = "2024.02.01"
activityCompose = "1.8.2"

[libraries]
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }

2. State Management Pattern (MVI/MVVM)

Use ViewModel with StateFlow to expose UI state. Avoid exposing MutableStateFlow.

// UI State Definition
data class UserUiState(
    val isLoading: Boolean = false,
    val user: User? = null,
    val error: String? = null
)

// ViewModel
class UserViewModel @Inject constructor(
    private val userRepository: UserRepository
) : ViewModel() {

    private val _uiState = MutableStateFlow(UserUiState())
    val uiState: StateFlow<UserUiState> = _uiState.asStateFlow()

    fun loadUser() {
        viewModelScope.launch {
            _uiState.update { it.copy(isLoading = true) }
            try {
                val user = userRepository.getUser()
                _uiState.update { it.copy(user = user, isLoading = false) }
            } catch (e: Exception) {
                _uiState.update { it.copy(error = e.message, isLoading = false) }
            }
        }
    }
}

3. Creating the Screen Composable

Consume the state in a "Screen" composable and pass data down to stateless components.

@Composable
fun UserScreen(
    viewModel: UserViewModel = hiltViewModel()
) {
    val uiState by viewModel.uiState.collectAsStateWithLifecycle()

    UserContent(
        uiState = uiState,
        onRetry = viewModel::loadUser
    )
}

@Composable
fun UserContent(
    uiState: UserUiState,
    onRetry: () -> Unit
) {
    Scaffold { padding ->
        Box(modifier = Modifier.padding(padding)) {
            when {
                uiState.isLoading -> CircularProgressIndicator()
                uiState.error != null -> ErrorView(uiState.error, onRetry)
                uiState.user != null -> UserProfile(uiState.user)
            }
        }
    }
}

Examples

Example 1: Type-Safe Navigation

Using the new Navigation Compose Type Safety (available in recent versions).

// Define Destinations
@Serializable
object Home

@Serializable
data class Profile(val userId: String)

// Setup NavHost
@Composable
fun AppNavHost(navController: NavHostController) {
    NavHost(navController, startDestination = Home) {
        composable<Home> {
            HomeScreen(onNavigateToProfile = { id ->
                navController.navigate(Profile(userId = id))
            })
        }
        composable<Profile> { backStackEntry ->
            val profile: Profile = backStackEntry.toRoute()
            ProfileScreen(userId = profile.userId)
        }
    }
}

Best Practices

  • ✅ Do: Use remember and derivedStateOf to minimize unnecessary calculations during recomposition.
  • ✅ Do: Mark data classes used in UI state as @Immutable or @Stable if they contain List or other unstable types to enable smart recomposition skipping.
  • ✅ Do: Use LaunchedEffect for one-off side effects (like showing a Snackbar) triggered by state changes.
  • ❌ Don't: Perform expensive operations (like sorting a list) directly inside the Composable function body without remember.

…

FAQ

What is Jetpack Compose?

It's a modern way to build user interfaces for Android, using Kotlin code instead of XML files.

What is a ViewModel?

It's a class that helps store and manage screen data, surviving changes like phone rotations.

What does 'type-safe navigation' mean?

It means the navigation system checks if you are passing the correct data between screens, preventing errors.

Details

Original description by the author

Expert guidance for building modern Android UIs with Jetpack Compose, covering state management, navigation, performance, and Material Design 3.

repo: sickn33/agentic-awesome-skills

Popularity

GitHub stars
48k
Ranking position
#2128
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills