home / skills / hoangnguyen0403 / agent-skills-standard / navigation
This skill enforces type-safe Jetpack Navigation Compose practices, using serializable routes and hoisted callbacks to simplify navigation across Android apps.
npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill navigationReview the files below or copy the command above to add this skill to your agents.
---
name: Android Navigation
description: Standards for Jetpack Navigation Compose (Type-safe)
metadata:
labels: [android, navigation, compose]
triggers:
files: ['**/*NavHost.kt', '**/*Graph.kt']
keywords: ['NavHost', 'navController', '@Serializable']
---
# Android Navigation Standards
## **Priority: P0**
## Implementation Guidelines
### Type-Safe Navigation
- **Library**: Navigation Compose 2.8.0+.
- **Routes**: Use `@Serializable` objects/classes instead of String routes.
- **Arguments**: No manual bundle parsing. Use `.toRoute<T>()`.
### Structure
- **Graphs**: Split large apps into nested navigation graphs (`navigation` extension functions).
- **Hoisting**: Hoist navigation events out of Screens. Composable screens should accept callbacks (`onNavigateToX`).
## Anti-Patterns
- **Hardcoded Strings**: `**No String Routes**: Use Typed Objects.`
- **Passing NavController**: `**No NavController in UI**: Hoist events.`
## References
- [Route Definitions](references/implementation.md)
This skill captures a concise set of standards and best practices for implementing type-safe navigation with Jetpack Navigation Compose. It focuses on preventing runtime errors and improving maintainability by using typed route objects, structured graphs, and hoisted navigation events. The guidance targets modern Compose apps and encourages Navigation Compose 2.8.0+ usage.
The skill inspects navigation usage patterns and recommends replacing String routes with @Serializable typed objects or classes so routes are validated at compile time. It enforces no manual bundle parsing and suggests helper extensions like .toRoute<T>() for argument marshalling. It also promotes splitting large flows into nested navigation graphs and hoisting navigation callbacks out of composable screens.
Why avoid String routes?
String routes are error-prone and untyped; using serializable route objects enables compile-time checks and safer argument handling.
How should UI composables trigger navigation?
Hoist navigation: composables accept callbacks (e.g., onNavigateToProfile) and the parent or a view model performs NavController actions.