$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
Kotlin / AndroidintermediateNew

Jetpack Compose

Share

Build Jetpack Compose UIs with state and navigation

Works with OpenClaude

You are an Android developer building declarative UIs with Jetpack Compose, managing state lifecycle, and implementing navigation between composables.

What to check first

  • Verify build.gradle has androidx.compose.ui:ui, androidx.compose.material3:material3, and androidx.navigation:navigation-compose dependencies
  • Run android:list in Android Studio to confirm your target API level supports Compose (API 21+)
  • Check that your Activity uses setContent { } instead of setContentView(R.layout.xml)

Steps

  1. Define a ViewModel with mutableStateOf() to hold UI state that survives configuration changes
  2. Create a composable function marked with @Composable that accepts state and callback parameters
  3. Use remember { } for temporary state tied to composition and rememberSaveable { } for state surviving process death
  4. Implement a NavController using rememberNavController() and wrap navigation destinations with NavHost
  5. Define routes as string constants or sealed classes (e.g., "detail/{id}" or sealed class Route)
  6. Use navController.navigate("route") to push destinations; use navController.popBackStack() to go back
  7. Extract route arguments with backStackEntry.arguments?.getString("id") and pass to destination composables
  8. Leverage derivedStateOf { } to compute values from state without recomposition overhead

Code

import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument

// ViewModel with state
class CounterViewModel : ViewModel() {
    private val _count = mutableStateOf(0)
    val count: State<Int> = _count

    fun increment() {
        _count.value++
    }
}

// Main composable with navigation
@Composable
fun AppNavigation() {
    val navController = rememberNavController()
    val viewModel = viewModel<CounterViewModel>()

    NavHost(navController, startDestination = "home") {
        composable("home") {
            HomeScreen(
                count = viewModel.count.value,
                onIncrement = { viewModel.increment() },
                onNavigateToDetail = { id ->
                    navController.navigate("detail/$id")
                }
            )
        }
        composable(
            "detail/{id}",
            arguments = listOf(navArgument("id") { type = NavType.StringType })
        ) { backStackEntry ->
            val id = backStackEntry.arguments?.getString("id")

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
kotlinjetpack-composeandroid

Install command:

curl -o ~/.claude/skills/kotlin-compose.md https://clskills.in/skills/kotlin/kotlin-compose.md

Related Kotlin / Android Skills

Other Claude Code skills in the same category — free to download.

Want a Kotlin / Android skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.