kmp-navigation
Skill18 starsChanged 4 months agoMITView on GitHub
Type-safe Compose Navigation for Kotlin Multiplatform (Android + iOS) - route objects, feature nav graphs, cross-feature callbacks, and wiring in :composeApp. Use this skill whenever setting up navigation, defining routes, adding a new screen to a nav graph, navigating between features, or wiring nav graphs in the app module. Trigger on phrases like "set up navigation", "add a route", "navigate between screens", "nav graph", "NavController", "type-safe nav", "cross-feature navigation", or "NavGraphBuilder".
2 other projects use a version of this.
Adopted by
Most recently taken up by
- giolaq/tv-build-harnesstheir own version, first seen Nov 1, 2026
- ronjunevaldoz/kmp-agent-skillstheir own version, first seen Aug 2, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- ronjunevaldoz/kmp-agent-skills★ 5same name
- giolaq/tv-build-harness★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository67 other files it gives its agents.
- agent-onboardingSkill
- android-backgroundSkill
- android-cliSkill
- android-compose-architectureSkill
- android-compose-componentsSkill
- android-data-layerSkill
- android-di-koinSkill
- android-error-handlingSkill
- android-integration-testingSkill
- android-jacoco-setupSkill
- android-jvm-test-coverageSkill
- android-module-structureSkill
- android-navigationSkill
- android-presentation-mviSkill
- android-preview-figma-verifySkill
- android-ui-screenshot-verifySkill
- android-ui-testingSkill
- android-ui-verifySkill
- android-unit-testingSkill
- android-version-catalogSkill
- architecture-decision-recordSkill
- careful-planningSkill
- compose-adaptive-layoutsSkill
- figma-to-android-vectorSkill
- finalizeSkill
- git-commitSkill
- handoffSkill
- kmp-compose-architectureSkill
- kmp-compose-componentsSkill
- kmp-data-layerSkill
- kmp-di-koinSkill
- kmp-error-handlingSkill
- kmp-integration-testingSkill
- kmp-migration-analyzerSkill
- kmp-module-structureSkill
- kmp-presentation-mviSkill
- kmp-ui-testingSkill
- kmp-unit-testingSkill
- kotlin-coroutinesSkill
- kotlin-flowsSkill
- kotlin-mutation-testingSkill
- openspec-artifact-review-lightSkill
- openspec-artifact-reviewSkill
- project-breakdownSkill
- react-data-layerSkill
- react-error-handlingSkill
- react-integration-testingSkill
- react-presentation-mviSkill
- react-project-structureSkill
- react-routingSkill
- react-screen-architectureSkill
- react-securitySkill
- react-server-stateSkill
- react-ui-componentsSkill
- react-unit-testingSkill
- speckit-parallelize-agent-teamsSkill
- speckit-parallelize-subagentsSkill
- spring-api-layerSkill
- spring-di-configurationSkill
- spring-integration-testingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Use the multiplatform navigation artifact in commonMain (added by the cmp.feature convention plugin):
- Very specific: line 27
Do not use androidx.navigation:navigation-compose in shared code — it is Android-only.
- Very specific: line 41
Use data object for screens with no parameters, data class for screens with arguments.
- Distinctive: line 76
All feature nav graphs are assembled in one place:
- Distinctive: line 111
Avoid passing complex objects via navigation — pass IDs and load data in the destination ViewModel.
≈ “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.
Files
KMP Navigation
Principles
- Type-safe navigation with
@Serializableroute objects (KotlinX Serialization). - One nav graph per feature, defined in the feature's
presentationmodule. - Feature nav graphs are assembled in
:composeApp(commonMain), inside the sharedApp()composable. - Navigation within a feature uses a
NavControllerpassed into the feature nav graph. - Feature-to-feature navigation uses callbacks, keeping features decoupled.
Dependency
Use the multiplatform navigation artifact in commonMain (added by the cmp.feature convention plugin):
org.jetbrains.androidx.navigation:navigation-composeDo not use androidx.navigation:navigation-compose in shared code — it is Android-only. Imports are unchanged (androidx.navigation.NavController, androidx.navigation.NavGraphBuilder, androidx.navigation.compose.NavHost, androidx.navigation.compose.composable, androidx.navigation.compose.navigation, androidx.navigation.toRoute). Every module that declares routes needs the KotlinX Serialization plugin (applied by kmp.library).
Route Objects
Define routes as @Serializable objects or data classes in the feature's presentation module:
// feature:notes:presentation
@Serializable object NoteListRoute
@Serializable data class NoteDetailRoute(val noteId: String)Use data object for screens with no parameters, data class for screens with arguments.
Feature Nav Graph
Each feature exposes a NavGraphBuilder extension function:
// feature:notes:presentation
fun NavGraphBuilder.notesGraph(
navController: NavController,
onNavigateToEditor: (String) -> Unit // callback for cross-feature navigation
) {
navigation<NoteListRoute>(startDestination = NoteListRoute) {
composable<NoteListRoute> {
NoteListRoot(
onNavigateToDetail = { navController.navigate(NoteDetailRoute(it)) }
)
}
composable<NoteDetailRoute> { backStackEntry ->
val route: NoteDetailRoute = backStackEntry.toRoute()
NoteDetailRoot(
noteId = route.noteId,
onNavigateToEditor = onNavigateToEditor
)
}
}
}Wiring in :composeApp
All feature nav graphs are assembled in one place:
// :composeApp — commonMain, inside App()
val navController = rememberNavController()
NavHost(navController, startDestination = NoteListRoute) {
notesGraph(
navController = navController,
onNavigateToEditor = { navController.navigate(EditorRoute(it)) }
)
editorGraph(navController)
}Cross-feature navigation is always expressed as a lambda callback — never by importing a route from another feature module.
Passing Arguments
For simple scalar arguments, use @Serializable data class routes:
@Serializable data class NoteDetailRoute(val noteId: String)
// Navigate
navController.navigate(NoteDetailRoute(noteId = "abc123"))
// Receive
composable<NoteDetailRoute> { backStackEntry ->
val route: NoteDetailRoute = backStackEntry.toRoute()
// route.noteId available here
}Avoid passing complex objects via navigation — pass IDs and load data in the destination ViewModel.
Platform Behavior
- Back navigation: Android system back and predictive back work as usual. On iOS the edge swipe-back gesture is handled by the navigation library — no extra code. iOS has no system back button, so every non-root screen needs a visible back button in its top bar.
- Intercepting back:
androidx.activity.compose.BackHandleris not available incommonMain. Use the multiplatform back handler fromorg.jetbrains.compose.ui:ui-backhandler. - Deep links: routes are shared; the incoming URL arrives per platform (
Intentin:androidApp,onOpenURLin the iOS app) and is forwarded to the sharedNavController. :androidAppcontains no navigation code — it only hostsApp().
Naming Conventions
| Thing | Convention | Example |
| Nav route | <Screen>Route | NoteListRoute, NoteDetailRoute |
| Feature nav graph | <feature>Graph(...) on NavGraphBuilder | notesGraph(...) |
Checklist: Adding Navigation to a New Feature
- Define
@Serializableroute objects for each screen infeature:presentation - Add feature nav graph function (
NavGraphBuilder.<feature>Graph(...)) - Pass
NavControllerfor intra-feature navigation - Expose cross-feature destinations as lambda callbacks (not direct route imports)
- Wire nav graph and cross-feature callbacks in
:composeApp'sNavHost - Every non-root screen has a visible back button (iOS has no system back)
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
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.

