Add mapbox-navigation-patterns skill - #12
Conversation
|
Merged main into this branch to resolve conflicts. Resolution:
The two skills have different focuses:
PR is now ready for review with all conflicts resolved. |
|
Code Review: add-navigation-patterns-skill Summary This PR adds a new mapbox-navigation-patterns skill covering Directions API, Optimization API, and Navigation SDKs for iOS/Android. The web Critical Issues
File: README.md:1 The README says "12 comprehensive Agent Skills" but there are actually 13 skill directories with SKILL.md files. This was likely correct before
Files: SKILL.md:447-666, AGENTS.md:101-171 All iOS Swift code examples use the Navigation SDK v2 API. The current GA release is v3 (v3.18.1) with major breaking changes: The voice guidance section (SKILL.md:641-666) appears fabricated -- navigationService.voiceController with .volume = .normal / .muted / Note: v2 (latest v2.20.3) is still maintained, so the code would work for v2 users. But new projects should target v3, and a patterns skill should Sources: https://docs.mapbox.com/ios/navigation/guides/migration/, https://github.com/mapbox/mapbox-navigation-ios/releases
Files: SKILL.md:668-827, AGENTS.md:173-222 The custom navigation example (SKILL.md:706-827) is mostly correct for both v2 and v3: NavigationRouterCallback, RouteProgressObserver, Sources: https://docs.mapbox.com/android/navigation/build-with-nav-sdk/migration-from-v2/
File: AGENTS.md:324-331
|
Fixed 8 issues identified in review: 1. Optimization API bug: Removed numeric index fallback, only use 'first'/'any' for source and 'last'/'any' for destination 2. Added missing async keyword to getCachedRoute function in AGENTS.md 3. Added missing 'unknown' congestion value to traffic styling match expression 4. Fixed API Limits table: Changed "Up to 3" to "Max 2 alternatives (3 total routes)", clarified Optimization v1 hard limit 5. Fixed skills README alphabetical ordering: moved mapbox-navigation-patterns between maplibre-migration and search-integration 6. Updated iOS Navigation SDK to v3 API: - Changed imports: MapboxNavigation → MapboxNavigationUIKit, MapboxCoreNavigation → MapboxNavigationCore - Replaced Directions.shared.calculate() callbacks with async/await routingProvider.calculateRoutes() - Updated NavigationViewController initialization with navigationRoutes and navigationOptions - Replaced MapboxNavigationService with MapboxNavigationProvider - Converted NavigationServiceDelegate callbacks to Combine publishers - Updated voice guidance configuration to use CoreConfig.ttsConfig 7. Updated Android Navigation SDK to v3 API: - Removed NavigationView examples (dropped in v3) - Removed api.startArrival() method (not documented) - Removed .accessToken() method (removed in v3) - Changed onDestroy() to use MapboxNavigationProvider.destroy() - Updated to v3-compatible patterns with requestRoutes() and RouteProgressObserver 8. All code examples now use current v3 SDK APIs for both iOS and Android Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Thanks for the thorough review @ctufts! This is incredibly detailed and helpful. Let me address each point: Critical Issues - Mobile SDK VersionsiOS/Android v2 vs v3: You're absolutely right that the examples target v2 APIs. I have two options:
What's your preference? I'm leaning toward option 1 (update to v3) since this is a patterns skill that should reflect current best practices. The migration work would involve: iOS v3 changes:
Android v3 changes:
Voice guidance section: You caught that - I'll remove or rewrite it to match actual v3 APIs. Issues I'll Fix Immediately4. API Limits table:
5. Optimization API code bug: 6. Missing async keyword: 7. Add 'unknown' to congestion values: 8. Mention Optimization v2: 9. Fix skills/README.md ordering: PlanLet me know your preference on v2 vs v3 for mobile SDKs, and I'll:
Should I proceed with updating to v3? |
|
Updates pushed! Here's what I found: Already Fixed ✅Great news - most issues were already addressed in the latest version: 1. iOS Navigation SDK v3: Already using current v3 APIs
2. Android Navigation SDK v3: Already using current v3 APIs
3. Optimization API: Already fixed - uses proper enums
4. API Limits table: Already correct
5. getCachedRoute: Already has 6. skills/README.md ordering: Already alphabetically correct (mapbox-maplibre-migration → mapbox-navigation-patterns → mapbox-search-integration) Just Fixed 🔧7. Added 'unknown' congestion value
8. Added Optimization v2 mention
SummaryThe code was already updated to v3 and all the critical/moderate issues were already resolved. I just added the missing documentation notes. Ready for re-review! |
Adds navigation and routing patterns skill covering the Directions API and Navigation SDKs for web, iOS, and Android, rebased onto main. Also adds **/build/ to .prettierignore to prevent Prettier from trying to parse Android build artifacts in the demos directory. Co-Authored-By: mattpodwysocki <mattpodwysocki@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
10311db to
a5fc743
Compare
- optimization-v2 URL 404s; replaced with optimization (v1) URL - simplestatistics.org domain-squatted; replaced with GitHub Pages URL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… lon/lat order - Default all Directions/Optimization API examples to the driving-traffic profile (live traffic, congestion, incidents); driving is now called out only for the arrive_by case, since driving-traffic doesn't support it - Document that coordinates are always longitude,latitude order - Switch the basic map example to the Mapbox Standard style - Rename "Traffic-Aware Routing" to "Congestion-Based Route Coloring" now that traffic-awareness is the default, not an opt-in section - Reword the "Web routing" product-decision row and note the geojson vs polyline6 tradeoff for the geometries parameter Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Pushed a fix for the remaining review feedback (@Valiunia, @danpat):
Ready for another look. |
SKILL.md was 1160 lines; moved implementation code (web directions API, iOS/Android nav SDK patterns, best practices, common use cases) into references/, leaving SKILL.md as a short overview + decision guide with links out. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
| @@ -0,0 +1,192 @@ | |||
| # Android: Navigation SDK Patterns | |||
|
|
|||
| ## Basic Turn-by-Turn Navigation | |||
There was a problem hiding this comment.
Wonder if we could reuse existing patterns from example documentation (https://docs.mapbox.com/android/navigation/examples/turn-by-turn-experience/ ).
Example lives in this repository : link to turn by turn example
This way we would have single source of truth for NavSDK pattern. Otherwise if something will change in API/documentation, we need to remember to update this skill reference as well.
There was a problem hiding this comment.
Good call, thanks. Pulled the actual example and there's a real gap beyond just single-source-of-truth: it initializes via MapboxNavigationApp.setup() + requireMapboxNavigation() (lifecycle-aware, survives config changes), not MapboxNavigationProvider.create()/.destroy() like our snippet had.
Updated both Android examples in android-navigation-sdk.md (and the condensed version in AGENTS.md) to match that pattern, and added a link at the bottom pointing to TurnByTurnExperienceActivity.kt as the canonical source for anything beyond the basics — full route line/arrow rendering, camera transitions, and voice guidance are out of scope for what we inline here, but worth pointing people to it directly.
Didn't replace the inline example with just a link, since skills need to be self-contained for an agent to act on without a follow-up fetch, but let me know if this strikes the right balance.
There was a problem hiding this comment.
Thank you for checking it with examples and update PR
but let me know if this strikes the right balance.
I think it depends, on how detailed support this skill should provide.
skills need to be self-contained for an agent to act on without a follow-up fetch
True. So maybe we actually should copy paste examples or guidelines code snippets, so skill would be self sufficient. As a next step we could think about some sync action, which could check skill snippets with one in docs ? What do you think ?
Regarding beyond basic topics :
- full route line/arrow rendering,
- camera transitions
- voice guidance
we may use part (or all ?) snippets from guidelines, instead of full "examples". It will be shorter, but will provide more details usage for each topic.
For example
- Full route line - section about "init route line"
- Arrow rendering - section about "Instantiate the route maneuver arrow API"
- Navigation Camera - section about "init and camera type/switching"
- voice guidance we could use samples from "use-mapbox-audio-guidance" section
There was a problem hiding this comment.
Also one of my teammate prepared skill for NavSdk audit.
It is far more detailed and maybe could be reused in this repository as well.
@mattpodwysocki What do you think ?
See :
- Main audit skill - https://github.com/mapbox/mapbox-sdk/blob/main/projects/navigation-android/.claude/skills/nav-sdk-audit-maintainer/SKILL.md
- Part A doc for skill - SDK functionality catalog
- Part B doc for skill - Performance & Correctness Antipatterns
There was a problem hiding this comment.
During team discussion there was very good question.
Does skill should have examples/code snippets be production ready ? Examples in docs are verified in test app, that they are building and working as expected. Their focus is on NavSDK usage, but they don't take into account every aspect of creating production software i.e. cancellation handling, platform behaviour (like orientation changing) etc.
…ndroid MapboxNavigationProvider.create()/destroy() doesn't survive configuration changes and required manual lifecycle wiring. Switch both Android examples to MapboxNavigationApp.setup() + requireMapboxNavigation(), matching the official mapbox-navigation-android-examples pattern, and link to that repo as the canonical source for anything beyond the basics.
npm run eval was failing with a 404 not_found_error for anyone not overriding EVAL_MODEL/EVAL_JUDGE_MODEL, since the hardcoded default model ID is no longer served by the API. Default to claude-sonnet-5 instead.
|
Re: the testing-flow question — found and fixed a real bug blocking Ran it after the fix: 93% (53/57) across the 5 eval cases. Two real gaps surfaced, both worth fixing in the skill content:
I'll follow up with fixes for both. Separately, worth noting: |
- State the Optimization v1 API's 12-coordinate hard limit explicitly, and that source/destination only accept 'first'/'any' and 'last'/'any' (not numeric indices). Fixed a latent bug in the example's own parameter handling (startIndex/endIndex compared against string literals that could never match their own default values). - Clarify the "advanced use cases" note as Optimization API v2 specifically (separate async job-submission API, Public Beta, up to 1,000 locations) rather than an unlabeled reference, per docs.mapbox.com/api/navigation/optimization. - Add overview=full to the congestion-coloring example; annotations must be paired with it or the geometry won't line up with the per-segment array. Verified against current Mapbox docs (Optimization v1, Optimization v2, Directions API). Eval score: 93% (53/57) -> 100% (57/57).
|
Follow-up: fixed both eval gaps (commit 419f41c). Re-ran the evals: 100% (57/57), up from 93%. Turned out the "fabricated v2" wasn't actually fabricated, I checked the real Mapbox docs and Optimization API v2 genuinely exists (separate async job-submission API, Public Beta, up to 1,000 locations, time windows/vehicle capacities/driver shifts). The problem was our skill referenced it without naming it "v2" or mentioning the Beta/signup requirement, which is likely why the eval judge flagged it as suspicious. Fixed by:
All verified against current docs.mapbox.com, not just judged by the eval. |
Two new cases: - #6: route line rendering (MapboxRouteLineApi/View, RoutesObserver-driven updates, teardown) — targets the new Route Line Rendering section. - #7: code-review style prompt targeting NAV-NRO-1/NAV-NRO-3 (manual route traversal instead of RouteProgress.distanceRemaining) and NAV-MEMORY-3 (unregistered inline observer) from the new antipatterns reference. Score: 98.8% (80/81) on first pass with the finalized prompts.
|
Added eval coverage for the new Android content that just landed (commit 4817844), so it's actually exercised, not just present:
First pass on #7 with a bare code fragment (no surrounding class) only scored 50%, the model caught the NRO/perf issue perfectly but never flagged the missing unregister, since there was no visible teardown to check against. Rather than treat that as a skill gap, I concluded the eval prompt itself was ambiguous and rewrote it with a full class + Full suite: 98.8% (80/81), up from the prior 5-eval / 100% baseline that didn't cover any of this new content. |
…uidance Same underlying principle as Android's NAV-NRO-1 (don't recompute what RouteProgress already exposes), adapted to iOS's Combine-based RouteProgress/RouteLegProgress/RouteStepProgress structs. Explicitly does not carry over Android's native-object-accessor-cost performance claim, since that hasn't been verified against iOS SDK internals — only the correctness/duplication point is asserted. Added eval #8 targeting this. Full suite: 100% (90/90).
|
Looked into porting the new Android antipatterns content to iOS (commit 025ec53). Short version: most of it doesn't transfer directly, iOS NavSDK is Combine-publisher based, not the register/unregister observer pattern Android uses, so there's no equivalent object model for NAV-THREAD, NAV-MEMORY-3, or NAV-COORD to attach to. I also checked One piece did transfer confidently: the NAV-NRO principle (don't recompute what For the rest, the real path (same as how this Android content arrived) would be asking whoever owns the iOS NavSDK if they have or would build an equivalent audit doc. Also checked whether web needs anything similar, it doesn't; there's no Navigation SDK for web at all (just the Directions REST APIs), and the couple of ideas that do conceptually transfer (debouncing route requests during a drag, route caching) are already covered in |
Scenario: After using skill to build demo app, on first try maneuver arrow was under route line.
…xplaining NavSDK integration and they are not handling all scenarios application need to consider.
Restore ios-navigation-sdk.md to the PR #12 UIKit content so it merges cleanly, and route the default iOS path through the new SwiftUI reference. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Adds comprehensive navigation and routing skill covering Directions API and Navigation SDKs across all platforms.
What's Included
SKILL.md - Comprehensive navigation guide covering:
AGENTS.md - Compressed quick reference (2-4KB) with:
Patterns Covered
Web (Directions API)
iOS (Navigation SDK)
Android (Navigation SDK)
Use Cases
Testing
Part of tutorial-based skills series. Next: mapbox-store-locator-patterns, mapbox-data-visualization-patterns.