home / skills / hoangnguyen0403 / agent-skills-standard / android-navigation

android-navigation skill

/skills/android/android-navigation

This skill helps implement Android navigation with Jetpack Compose, enforcing type-safe routes, deep links, and validated arguments.

npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill android-navigation

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.2 KB
---
name: Android Navigation
description: Navigation for Android using Jetpack Compose Navigation and App Links.
metadata:
  labels: [android, compose, navigation, deep-linking, app-links]
  triggers:
    files: ['**/*Screen.kt', '**/*Activity.kt', '**/NavGraph.kt']
    keywords: [NavController, NavHost, composable, navArgument, deepLinks]
---

# Android Navigation (Jetpack Compose)

## **Priority: P2 (OPTIONAL)**

Navigation and deep linking using Jetpack Compose Navigation.

## Guidelines

- **Library**: Use `androidx.navigation:navigation-compose`.
- **Type Safety**: Use sealed classes for routes, never raw strings.
- **Deep Links**: Configure `intent-filter` in Manifest and `deepLinks` in NavHost.
- **Validation**: Validate arguments (e.g., proper IDs) before loading content.

[Patterns & Examples](references/navigation-patterns.md)

## Anti-Patterns

- **No String Routes**: Use `Screen.Product.route` instead of `"product/$id"`.
- **No Unvalidated Deep Links**: Check resource existence before rendering.
- **No Missing Manifest**: Deep links require `autoVerify=true` intent filters.

## Related Topics

android-design-system | android-notifications | mobile-ux-core

Overview

This skill documents best practices for Android navigation using Jetpack Compose Navigation and App Links. It focuses on type-safe routing, reliable deep linking, and validation patterns that reduce runtime errors and improve user experience. The guidance is framework-focused and geared toward Compose apps using androidx.navigation:navigation-compose.

How this skill works

The skill recommends using the navigation-compose library to define navigation graphs and destinations. Routes are modeled as sealed classes to enforce type safety and avoid raw string routes. Deep links are handled by combining Manifest intent-filters with NavHost deepLinks and validating incoming arguments before rendering screens.

When to use it

  • Building navigation flows in Jetpack Compose apps
  • Implementing deep links and App Links for Android apps
  • Migrating from XML-based navigation to Compose navigation
  • Ensuring runtime safety for route parameters and IDs
  • Enforcing team-wide navigation conventions and coding standards

Best practices

  • Use androidx.navigation:navigation-compose as the navigation library
  • Represent routes with sealed classes (not raw strings) to ensure compile-time safety
  • Declare deep link intent-filters in the AndroidManifest with autoVerify=true for App Links
  • Configure NavHost deepLinks and also validate arguments (IDs, enums) before loading content
  • Avoid rendering screens directly from unvalidated deep link data; show fallback or error states
  • Centralize route definitions and navigation helpers to keep navigation consistent

Example use cases

  • Defining a Screen sealed class for all routes and using Screen.route when navigating
  • Configuring an intent-filter for your domain and matching deepLinks in NavHost for App Links
  • Validating an incoming productId from a deep link before fetching product details
  • Converting existing string-based routes to sealed classes during a Compose migration
  • Providing a safe fallback screen when a deep link refers to a deleted or private resource

FAQ

Why use sealed classes instead of string routes?

Sealed classes provide compile-time guarantees, reduce typos, and make route refactoring safer than raw strings.

How do I handle invalid deep link arguments?

Validate IDs and parameter formats before loading content; navigate to an error or fallback screen if validation fails.