skills/jetpack-compose-navigation-expert/SKILL.md
Jetpack Compose navigation expert with type-safe routes, Hilt DI, and MVVM/MVI architecture. Activate on: Jetpack Compose navigation, Compose type-safe routes, Hilt dependency injection, MVVM Android, MVI pattern, Compose state management, NavHost, ViewModel. NOT for: XML layouts (use frontend-architect), iOS SwiftUI (use swiftui-data-flow-expert), React Native (use react-native-architect).
npx skillsauth add curiositech/windags-skills jetpack-compose-navigation-expertInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Expert in Jetpack Compose navigation with type-safe routes, Hilt dependency injection, and clean MVVM/MVI architecture.
Activate on: "Jetpack Compose navigation", "Compose type-safe routes", "Hilt DI", "MVVM Android", "MVI pattern", "Compose state management", "NavHost", "ViewModel Compose", "navigation-compose"
NOT for: XML layouts → frontend-architect | iOS SwiftUI → swiftui-data-flow-expert | React Native → react-native-architect
implementation("androidx.navigation:navigation-compose:2.9.x") with type-safe routes@Serializable data class ProductRoute(val id: String)@HiltViewModel for ViewModels with constructor injectioncollectAsStateWithLifecycle| Domain | Technologies | |--------|-------------| | Navigation | Navigation Compose 2.9, type-safe routes, nested graphs | | DI | Hilt 2.53, @HiltViewModel, @Inject, module scoping | | Architecture | MVVM, MVI (Circuit, Mavericks), UDF (unidirectional data flow) | | State | StateFlow, collectAsStateWithLifecycle, SavedStateHandle | | Async | Kotlin Coroutines, Flow, Room with Flow, Retrofit suspend |
// Define routes as serializable data classes
@Serializable
data object HomeRoute
@Serializable
data class ProductRoute(val productId: String)
@Serializable
data class OrderRoute(val orderId: String, val showConfirmation: Boolean = false)
// NavHost with type-safe composable destinations
@Composable
fun AppNavHost(navController: NavHostController = rememberNavController()) {
NavHost(navController = navController, startDestination = HomeRoute) {
composable<HomeRoute> {
HomeScreen(
onProductClick = { id ->
navController.navigate(ProductRoute(productId = id))
}
)
}
composable<ProductRoute> { backStackEntry ->
val route = backStackEntry.toRoute<ProductRoute>()
ProductScreen(productId = route.productId)
}
composable<OrderRoute> { backStackEntry ->
val route = backStackEntry.toRoute<OrderRoute>()
OrderScreen(orderId = route.orderId)
}
}
}
@HiltViewModel
class ProductViewModel @Inject constructor(
private val repository: ProductRepository,
savedStateHandle: SavedStateHandle,
) : ViewModel() {
private val productId: String = savedStateHandle.toRoute<ProductRoute>().productId
private val _uiState = MutableStateFlow<ProductUiState>(ProductUiState.Loading)
val uiState: StateFlow<ProductUiState> = _uiState.asStateFlow()
init { loadProduct() }
fun onEvent(event: ProductEvent) {
when (event) {
is ProductEvent.AddToCart -> addToCart(event.quantity)
is ProductEvent.Refresh -> loadProduct()
}
}
private fun loadProduct() {
viewModelScope.launch {
_uiState.value = ProductUiState.Loading
repository.getProduct(productId)
.onSuccess { _uiState.value = ProductUiState.Success(it) }
.onFailure { _uiState.value = ProductUiState.Error(it.message) }
}
}
}
// Composable observes state
@Composable
fun ProductScreen(viewModel: ProductViewModel = hiltViewModel()) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
when (val state = uiState) {
is ProductUiState.Loading -> LoadingIndicator()
is ProductUiState.Success -> ProductContent(
product = state.product,
onEvent = viewModel::onEvent,
)
is ProductUiState.Error -> ErrorMessage(state.message)
}
}
Root NavHost
├─ Auth Graph (unauthenticated)
│ ├─ Login
│ ├─ Register
│ └─ ForgotPassword
├─ Main Graph (authenticated)
│ ├─ Home Tab
│ │ ├─ Feed
│ │ └─ Product Detail
│ ├─ Search Tab
│ │ ├─ Search
│ │ └─ Category
│ └─ Profile Tab
│ ├─ Profile
│ └─ Settings
└─ Fullscreen overlays (shared)
├─ ImageViewer
└─ VideoPlayer
navController.navigate("product/123") is error-prone. Use type-safe route classes (@Serializable data class ProductRoute(val id: String)).hiltViewModel() which handles scoping to the NavBackStackEntry.collectAsState() keeps collecting when the app is backgrounded. Use collectAsStateWithLifecycle() to respect lifecycle.navController.navigate() from ViewModel. Instead, expose navigation events via SharedFlow or callback lambdas; let the composable handle navigation.[ ] Type-safe navigation routes using @Serializable classes
[ ] Hilt configured with @HiltViewModel for all ViewModels
[ ] UI state collected with collectAsStateWithLifecycle
[ ] Unidirectional data flow: events up, state down
[ ] Deep links configured in NavHost
[ ] Navigation tested with TestNavHostController
[ ] SavedStateHandle used for process death restoration
[ ] Nested graphs for auth, main, and feature flows
[ ] No navigation logic in ViewModels (events/callbacks instead)
[ ] Compose previews with mock data for all screens
[ ] ProGuard/R8 rules configured for serializable routes
[ ] Screen transitions animated with shared element transitions
tools
Building resilient distributed systems with circuit breakers, retries with full-jitter exponential backoff, retry budgets (per-request 3-attempt + per-client 10% ratio per Google SRE), deadline propagation, and the cascading-failure math (4 layers × 3 retries = 64x amplification). Grounded in Resilience4j, Microsoft Cloud Patterns, AWS Architecture Blog (Marc Brooker), and Google SRE Book.
testing
Designing HTTP cache headers that work correctly across browsers, CDNs, and shared proxies — `Cache-Control` directives per RFC 9111, `stale-while-revalidate` and `stale-if-error` per RFC 5861, the Vary header for varying responses, and surrogate keys for tag-based purging. Grounded in IETF RFCs and Cloudflare/Fastly docs.
development
Use when designing or fixing a Content Security Policy on a real site, choosing between nonce-based and hash-based CSP, adding strict-dynamic, debugging "Refused to execute inline script" errors, deploying CSP in report-only mode first, configuring report-to / report-uri, or auditing an existing policy for unsafe-inline / unsafe-eval / wildcards. Triggers: "CSP blocks legitimate inline script", strict-dynamic, nonce-{RANDOM}, sha256-{HASH}, object-src none, base-uri none, frame-ancestors, Trusted Types, X-Content-Security-Policy obsolete, report-only vs enforced. NOT for general HTTP security headers (HSTS, COOP/COEP), Trusted Types deep dive, CORS configuration, or building a WAF.
tools
Choosing and operating an HTTP API versioning strategy that doesn't break clients — Stripe's date-based pinned versions, the Deprecation/Sunset header pair (RFC 9745 + RFC 8594), URI vs header vs media-type approaches, and the version-transformer pattern. Grounded in Stripe's published architecture and IETF RFCs.