Skip to content

Conversation

@mattpodwysocki
Copy link
Contributor

Summary

Adds comprehensive style quality validation capabilities through a new skill and prompt, with automatic validation integrated into all style-creation workflows.

New Skill: mapbox-style-quality

Created comprehensive skill document (390+ lines) teaching AI assistants when and how to use quality validation tools:

  • Pre-production checklist: Validate expressions, check accessibility, optimize styles
  • Development workflows: When to use each validation tool during development
  • Best practices: GeoJSON validation, expression validation, WCAG compliance
  • Optimization strategies: When to optimize, recommended order, selective optimization
  • Integration patterns: Git hooks, CI/CD pipelines, code review checklists
  • Common issues: Runtime errors, poor readability, large file sizes with solutions

New Prompt: prepare-style-for-production

Created production-ready workflow prompt that orchestrates 5 validation tools:

  1. validate_expression_tool - Validates filters, paint properties, layout properties
  2. validate_geojson_tool - Validates GeoJSON sources for coordinate/structure errors
  3. check_color_contrast_tool - Checks WCAG AA/AAA accessibility compliance
  4. optimize_style_tool - Removes redundancies, simplifies expressions
  5. compare_styles_tool - Implicit comparison for before/after analysis

Features:

  • Accepts style ID or complete style JSON
  • Configurable WCAG level (AA or AAA, default: AA)
  • Optional optimization skip
  • Generates comprehensive quality report with deployment readiness assessment

Arguments:

  • style_id_or_json (required): Style ID or complete style JSON
  • skip_optimization (optional): Set to "true" to skip optimization
  • wcag_level (optional): "AA" or "AAA" (default: "AA")

Automatic Validation Integration

Updated all 4 style-creation prompts to automatically validate after creating styles:

Updated Prompts:

  1. create-and-preview-style - Auto-validates after creation
  2. build-custom-map - Auto-validates AI-generated styles
  3. design-data-driven-style - Auto-validates complex expressions
  4. setup-mapbox-project - Auto-validates initial style

Validation Flow:

1. Create style ✓
2. Generate preview ✓
3. Automatically validate ✓ (runs without asking)
4. Present: Preview URL + Validation report

Results Shown to Users:

  • ✅ Preview URL
  • ✅ Validation report:
    • Expression validation status
    • Accessibility compliance (WCAG AA)
    • Optimization recommendations
    • Overall: "Production-ready" or list of issues
  • ✅ Note: "Warnings can be ignored for prototypes"

Why Automatic Validation?

Following development tool patterns (ESLint, TypeScript, test runners):

  • Fast: All validation is offline (no API calls, milliseconds)
  • Informational: Shows issues but doesn't block workflow
  • Early detection: Catches problems before runtime
  • Especially valuable for:
    • AI-generated styles (build-custom-map)
    • Complex expressions (design-data-driven-style)
    • Production deployments (all prompts)

Testing

  • 15 comprehensive test cases for PrepareStyleForProductionPrompt
  • Updated prompt registry tests
  • All 386 tests passing ✓

Documentation

  • Added mapbox-style-quality to skills list in README
  • Added complete prompt documentation with usage examples
  • Cross-referenced skill and prompt
  • Updated all 4 style-creation prompts

Related Work

This work depends on and integrates with:

Example Usage

Using the Prompt Directly:

Use prompt: prepare-style-for-production
Arguments:
  style_id_or_json: "username/my-style-id"
  wcag_level: "AA"

Automatic Validation in Workflows:

When a user runs create-and-preview-style, the AI will now:

  1. Create the style
  2. Generate preview
  3. Automatically validate (new!)
  4. Show preview URL + validation report together

Benefits

  • Catches issues early: Expression errors, accessibility problems, optimization opportunities
  • Production-ready by default: All created styles are validated
  • Educational: Users learn about quality issues as they develop
  • No friction: Validation is fast and informational
  • Best practices built-in: WCAG compliance checking, expression validation

🤖 Generated with Claude Code

mattpodwysocki and others added 3 commits January 8, 2026 23:01
…roduction prompt

Adds comprehensive style quality validation capabilities:

Skill:
- Created mapbox-style-quality skill document (390+ lines)
- Pre-production checklist and validation best practices
- Guidance on expression validation, GeoJSON validation, and accessibility
- Optimization strategies and workflow recommendations
- Integration patterns for Git hooks, CI/CD, and code review

Prompt:
- Created prepare-style-for-production prompt
- Orchestrates validation workflow using 5 quality tools:
  * validate_expression_tool - Validate expressions in filters/paint/layout
  * validate_geojson_tool - Validate GeoJSON sources
  * check_color_contrast_tool - WCAG accessibility compliance
  * optimize_style_tool - Remove redundancies and optimize
  * compare_styles_tool - Compare versions (implicit in workflow)
- Configurable WCAG level (AA/AAA) and optional optimization skip
- Generates comprehensive quality report with deployment readiness assessment

Testing:
- 15 test cases for PrepareStyleForProductionPrompt
- All 386 tests passing
- Updated prompt registry tests

Documentation:
- Updated README with new skill listing
- Added prompt documentation with usage examples
- Cross-referenced skill and prompt

Related PRs:
- PR #50: validate_geojson_tool
- PR #51: validate_expression_tool
- PR #52: compare_styles_tool
- PR #53: check_color_contrast_tool
- PR #54: optimize_style_tool

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Updates all style-creation prompts to explicitly ask users if they want
to validate their styles for production readiness:

Updated prompts:
- create-and-preview-style: Adds validation step 6
- build-custom-map: Adds validation step 6
- design-data-driven-style: Adds validation step 8
- setup-mapbox-project: Adds optional validation section

Changes:
- Prompts now explicitly ASK users: "Would you like to validate this style for production readiness?"
- Provides clear IF/ELSE logic for AI to follow based on user response
- If yes: Use prepare-style-for-production prompt with style ID
- If no: Note validation can be done later
- Makes validation actionable rather than just a suggestion

Benefits:
- Catches style issues early in development workflow
- Ensures production styles meet quality and accessibility standards
- Validates complex expressions in data-driven styles
- Provides immediate feedback on WCAG compliance

Related: prepare-style-for-production prompt in previous commit

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Changes all style-creation prompts to automatically validate instead of
asking the user. Validation is fast (offline only), catches issues early,
and provides immediate feedback without friction.

Rationale:
- All validation tools are offline (no API calls, no cost)
- Fast execution (milliseconds)
- Follows development tool patterns (ESLint, TypeScript, tests)
- Results are informational - users can ignore warnings for prototypes
- Better to show issues immediately than discover them later

Updated prompts:
- create-and-preview-style: Step 5 now validates automatically
- build-custom-map: Step 5 now validates automatically
- design-data-driven-style: Step 8 now validates automatically
- setup-mapbox-project: Validates before presenting final summary

Changes:
- Removed user question "Would you like to validate?"
- Added automatic validation step after style creation
- Validation results included in final summary
- Note added that warnings can be ignored for prototypes

Benefits:
- Catches expression errors before runtime
- Ensures WCAG accessibility compliance by default
- Identifies optimization opportunities immediately
- Especially valuable for AI-generated styles (build-custom-map)
- Data-driven styles get complex expression validation

Example flow:
1. Create style ✓
2. Generate preview ✓
3. Automatically validate ✓ (new - runs without asking)
4. Present: Preview URL + Validation report

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant