joaquincampo/my-plugins/add-approuter
Claude Code and agent skill by joaquincampo/my-plugins
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Adopt AppRouter (github.com/dimillian/AppRouter) for type-safe SwiftUI navigation with sheets and deep linking. Use when starting an app's nav layer or replacing ad-hoc `NavigationStack` path management. SimpleRouter or tab Router.
Install
npx vskill@latest install joaquincampo/my-plugins/add-approuterSKILL.md
The same SKILL.md was published earlier as joaquincampo/my-plugins/add-approuter.
Add AppRouter
When this applies
- Starting a new SwiftUI app and need a navigation layer that survives beyond a single view.
- Refactoring an app where
@Statepaths, sheet flags, and tab indices are scattered across views. - Wanting URL deep links into the navigation stack without hand-rolling a parser.
When NOT to use it
- Trivial 2-screen apps. A plain
NavigationStackwith local@Stateis enough. - Apps already on TCA or pointfreeco/swift-navigation. Do not bolt a second router on.
- You need
.fullScreenCover, multiple simultaneous sheets, or sheets that are part of the URL.
Install
- In Xcode, File, Add Package Dependencies, paste
https://github.com/dimillian/AppRouter, pin from1.0.0. - Or in
Package.swift:.package(url: "https://github.com/dimillian/AppRouter", from: "1.0.0"). import AppRouterin the file that defines your router root.- Min platforms: iOS 17, macOS 14, tvOS 17, watchOS 10. Swift 5.9.
The 4 core types
DestinationType:Hashableenum of push destinations. One requirement,static func from(path:fullPath:parameters:) -> Self?, used by the URL parser. Returnnilif you skip deep linking.SheetType:Hashable & Identifiableenum of sheets. No methods. Common pattern,var id: Int { hashValue }.TabType:Hashable, CaseIterable, Identifiable, Sendableenum of tabs, withvar icon: String(SF Symbol). Only needed forRouter.SimpleRouter<Destination, Sheet>for one stack.Router<Tab, Destination, Sheet>for a tab app with one independent stack per tab.
Both routers are @Observable @MainActor final class. Sheets, one slot, shared across tabs in Router.
3-step adoption playbook
- Define
enum Destination: DestinationTypeandenum Sheet: SheetTypefor the app's navigation vocabulary. Addenum AppTab: TabTypeonly if you have tabs. - In the root view, hold the router as
@State. Inject with.environment(router). For tabs, also set.environment(\.currentTab, router.selectedTab). - Bind the stack with
NavigationStack(path: $router.path)(Simple) orNavigationStack(path: $router[tab])(tabs). Bind sheets with.sheet(item: $router.presentedSheet). In children, read with@Environment(SimpleRouter<Destination, Sheet>.self)and callrouter.navigateTo(.foo)orrouter.presentSheet(.bar).
Deep dives in references/
references/simple-and-tab-router.md: full worked examples ofSimpleRouterandRouter.references/deep-linking.md: URL format,onOpenURL, contextual routing, parameter limits.
Gotchas
- Symptom:
myapp://users/detail?id=u1lands on the wrong destination or returnsfalse. Cause:URL.deepLinkusesString(describing:)per case; only argumentless cases serialize cleanly, and context prefixes silently skip whenfrom(...)returnsnil. Fix: build URLs withURLComponents, usefullPathto disambiguate insidefrom(...). Seereferences/deep-linking.md. - Symptom: presenting a second sheet replaces the first instead of stacking. Cause: one sheet slot per router;
presentSheetoverwrites. Fix: dismiss first, or push aNavigationStackinside the sheet for multi-step flows. - Symptom:
router.navigate(to: url)lands in the wrong tab. Cause:navigate(to: URL)always writes intoselectedTab. Fix: setrouter.selectedTabfirst; parse the tab from the URL host yourself. - Symptom: contextual routing misfires for URLs with repeated tokens like
myapp://detail/detail. Cause: parser usesfullPath.firstIndex(of: path)so both calls see the same previous token. Fix: known gap, use distinct tokens (item,subitem) or pass position via a query parameter. - Symptom:
router.navigate(to: url)returnsfalseand nothing happens. Cause: everyfrom(...)returnednil. Fix: log the parse result; ensure at least one path token resolves.
Hard limits
- One sheet slot per router. No sheet stack, no
.fullScreenCover, no popover. - Sheets are not URL-addressable. The parser builds
[Destination]only; present sheets after navigating. - Query parameters are shared across every destination parsed from a single URL. There is no per-segment scoping.
- No persistence, no animation hooks, no tab-switch callbacks. Wire those yourself.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingapple-dev/skills/add-approuter/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/joaquincampo/my-plugins/add-approuter)