Skip to content

Guide · Agent skill

How to use the Android Navigation Event Back Handling agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The navigation-event skill is a set of instructions that teaches an AI coding agent how to handle the Android back gesture in apps built with Jetpack Compose, using the NavigationEvent (androidx.navigationevent) library. It is written for Android developers who need Predictive Back support, teams moving older back-handling code to NavigationEvent, and developers chasing back-gesture crashes. After this guide you will know what the skill changes, how to install it, how to ask for help with natural requests, and what to check before letting an agent edit your project.

Android Navigation Event Back Handlingandroid/skills · Apache-2.0

Quick start

  1. 1Download the ZIP. Download the navigation-event skill ZIP from this page.
  2. 2Unzip into a skills folder. Unzip it into ~/.claude/skills/ for personal use, or into your project's .claude/skills/ folder.
  3. 3Or upload it in the Claude apps. In the Claude apps, open Settings, go to Capabilities, then Skills, and upload the ZIP.
  4. 4Confirm your project fits. Check that the app uses Jetpack Compose and that compileSdk is 36 or higher.
  5. 5Describe the back behaviour you need. Ask the agent in plain language, naming the screen, tab, dialog or crash involved.
  6. 6Review the changes. Read the edits to source files and build.gradle.kts, then run your app and test the back gesture.

What the navigation-event skill makes the agent do

An agent skill is a folder of instructions that an AI coding agent loads when a task matches the skill's description. This one covers back handling in Compose Android apps. Once it is active, the agent follows its guidelines for setting up the NavigationEvent library, intercepting back swipes and button presses, and scoping handlers for tabs, ViewPagers and dialogs.

The skill also tells the agent how to migrate older code such as BackHandler or OnBackPressedCallback on SDK 36 and above, and how to fix common crashes. It points to bundled reference guides on the dispatcher, handling back events, setup, and the library overview, so the agent can read the relevant page before changing code.

  • Sets up the NavigationEvent dependency and checks compileSdk is 36 or higher
  • Uses ComponentActivity's built-in navigationEventDispatcher instead of overriding it
  • Scopes handlers for ViewPagers, tabs and nested navigation with rememberNavigationEventDispatcherOwner()
  • Handles Compose NavigationBackHandler and animates UI during swipes
  • Explains the StackOverflowError caused by shadowing navigationEventDispatcher

Install the navigation-event skill

Download the ZIP for the navigation-event skill from this page. Then choose one of the two install locations below.

For a personal setup available across your projects, unzip the download into ~/.claude/skills/. For a single project, unzip it into that project's .claude/skills/ folder so it travels with the repository.

You can also upload the ZIP in the Claude apps. Open Settings, go to Capabilities, then Skills, and add the file there.

  • Personal: ~/.claude/skills/
  • Project: .claude/skills/ inside your project folder
  • Claude apps: Settings → Capabilities → Skills, then upload the ZIP

Check what the project needs before you start

The skill only helps with a specific kind of project. Your app must use Jetpack Compose, because the skill is scoped exclusively to Compose Android. Android Views and non-Compose implementations are excluded.

The skill also expects compileSdk 36 or higher. If your project is lower, the skill instructs the agent to raise it in build.gradle.kts. You also need the androidx.navigationevent library dependency, which the setup guide covers.

If your project already uses Navigation 3, the skill tells the agent to use Navigation 3's built-in back navigation support instead of adding low-level dispatchers.

  • Android project using Jetpack Compose
  • compileSdk 36 or higher
  • androidx.navigationevent library dependency

Trigger the skill with natural requests

You do not need special syntax. Describe the back behaviour you want in plain language, and mention Android, Compose or back handling so the agent matches the skill. Good requests name the screen or problem, such as a tab layout, a dialog or a crash.

The skill's guidelines cover setup, dispatcher scoping, handler creation and migration, so requests on any of those topics are a good fit.

  • "Add predictive back animation to my Compose screen that shrinks the content during the swipe."
  • "Migrate this BackHandler in my Compose app to NavigationEvent on SDK 36."
  • "My app crashes on launch with a StackOverflowError after I overrode navigationEventDispatcher. Fix it."
  • "Scope back handling so the ViewPager tabs disable their handlers when the parent is disabled."
  • "Make back gestures close this Compose ModalBottomSheet without extra CompositionLocalProvider code."

Example: fix a launch crash in an Activity

A common problem is an Activity that implements NavigationEventDispatcherOwner and overrides navigationEventDispatcher with a new instance. The skill identifies this as the cause of a recursive loop and a StackOverflowError on launch. The correct pattern is to let ComponentActivity provide the built-in dispatcher and not override it.

class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { MyApplicationContent() } } }

Example: handle a dialog's back gesture

Compose Dialog, ModalBottomSheet and ComponentDialog windows automatically provide a NavigationEventDispatcherOwner, so you do not need to re-provide it inside the dialog. The skill's example creates a NavigationEventState and attaches a NavigationBackHandler that calls onDismiss when the back gesture completes.

@Composable fun MyDialog(onDismiss: () -> Unit) { Dialog(onDismissRequest = onDismiss) { val navigationState = rememberNavigationEventState(currentInfo = NavigationEventInfo.None) NavigationBackHandler( state = navigationState, onBackCompleted = onDismiss ) } }

Know the safety notes before you run it

The skill runs no scripts and uses no network access, according to its listing. It contains instructions and reference documents only. The agent still edits your source files and build configuration, so review its changes, especially updates to build.gradle.kts and dependency versions, before you commit them.

Keep one rule in mind when reviewing code: a single NavigationEventState should not be bound to several active NavigationBackHandler instances. The skill notes this is strictly enforced and violating it throws an IllegalArgumentException.

  • Runs scripts: no
  • Uses network: no
  • Review build file and dependency changes made by the agent

Tips for better results

Name the exact file or screen and say whether it uses ViewPager, tabs or a dialog. The skill's scoping rules depend on where handlers live.

If you have Navigation 3 in the project, say so up front, because the skill then prefers the library's built-in back support over manual dispatchers.

For manual cleanup, remember that Compose APIs such as NavigationBackHandler and rememberNavigationEventDispatcherOwner() tear down automatically. Explicit remove(), isEnabled = false and dispose() calls are for custom dispatchers and non-Compose handlers.

What people use it for

  • Adding Predictive Back animations to a Compose screen during the swipe
  • Migrating BackHandler or OnBackPressedCallback code to NavigationEvent on SDK 36 and above
  • Fixing a StackOverflowError on launch caused by overriding navigationEventDispatcher
  • Scoping back handling for ViewPagers, tabs and nested navigation hosts
  • Making back gestures dismiss Compose dialogs and bottom sheets correctly

Frequently asked questions

What is the navigation-event skill for?

It gives an AI coding agent instructions for handling the Android back gesture in Jetpack Compose apps using the NavigationEvent library. It also covers migrating older back-handling code and fixing common back-gesture crashes.

What do I need to use it?

You need an Android project that uses Jetpack Compose, a compileSdk of 36 or higher (the skill instructs raising it if needed), and the androidx.navigationevent library dependency. The skill does not support Android Views.

How do I install the navigation-event skill?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or into a project's .claude/skills/ folder. You can also upload the ZIP in the Claude apps under Settings, then Capabilities, then Skills.

Does the skill run scripts or use the network?

No. The skill's listing states it runs no scripts and uses no network. It contains instructions and reference guides only.

Can it help with a StackOverflowError on launch?

Yes. The skill explains that implementing NavigationEventDispatcherOwner on an Activity and overriding navigationEventDispatcher causes a recursive loop. The fix is to use the dispatcher that ComponentActivity provides automatically.

Does it work with Android Views or non-Compose apps?

No. The skill is explicitly scoped to Compose Android, and Android Views and non-Compose implementations are excluded. Use it only for apps built with Jetpack Compose.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you build Compose Android apps and need Predictive Back support, a migration from BackHandler or OnBackPressedCallback, or a fix for back-gesture crashes. Pick something else if your app uses Android Views, or if you want a finished app rather than code changes to an existing project.

Download the skill