Skip to main content
skill CX Codex

mapbox-style-quality — Claude Code skill for Mapbox style QA

A skill that walks your agent through Mapbox style QA: expression and GeoJSON validation, WCAG contrast checks, and style optimization.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mapbox/mapbox-agent-skills --skill mapbox-style-quality -a claude-code
Open on GitHub

What mapbox-style-quality does

The skill hands your agent a checklist for Mapbox style quality. It works through five tools: validate_geojson_tool for sources, validate_expression_tool for expressions, check_color_contrast_tool for text readability, optimize_style_tool for file size, and compare_styles_tool for diffs between versions.

The order matters. Validate every expression and GeoJSON source first, then check contrast on text layers, then diff against the previous production version and optimize. Cleanup comes last: drop empty layers with no visible paint properties and collapse redundant boolean logic in filters, such as ["all", expr] down to expr.

Contrast targets follow WCAG — AA is 4.5:1 for normal text and 3:1 for large, AAA is 7:1 and 4.5:1. Large means 18pt or 14pt bold and up. Test on both light and dark tiles, and against popup backgrounds; outdoor mobile use is where weak labels show up. When a style breaks at runtime, diff the working version against the broken one first — a single expression is usually the cause.

What it helps with

  • catch an expression error before the map throws it at runtime
  • check label contrast against WCAG AA or AAA
  • shrink a style file before deploying
  • see what changed between two style versions
  • reject GeoJSON with bad coordinates or unclosed polygon rings

Example prompts for the agent

  • validate the expressions in this style with validate_expression_tool
  • check contrast on my label layers and tell me where it falls short of WCAG AA
  • compare the current style against the production version and list the differences

How to install mapbox-style-quality

1Skills CLI (Vercel)

npx skills add mapbox/mapbox-agent-skills --skill mapbox-style-quality -a claude-code

2Manually: put the files in place

~/.claude/skills/mapbox-style-quality/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/mapbox-style-quality/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about mapbox-style-quality

How do I install mapbox-style-quality in Claude?

Run npx skills add mapbox/mapbox-agent-skills --skill mapbox-style-quality -a claude-code. The skill lands at ~/.claude/skills/mapbox-style-quality/SKILL.md.

What does mapbox-style-quality do?

It gives your agent a Mapbox style QA checklist: expression and GeoJSON validation, text contrast checks, optimization, and version comparison.

Which tools does the skill use?

validate_geojson_tool, validate_expression_tool, check_color_contrast_tool, optimize_style_tool, and compare_styles_tool.

Source text

SKILL.md · MIT
---
name: mapbox-style-quality
description: Expert guidance on validating, optimizing, and ensuring quality of Mapbox styles through validation, accessibility checks, and optimization. Use when preparing styles for production, debugging issues, or ensuring map quality standards.
---

# Mapbox Style Quality Skill

This skill provides expert guidance on ensuring Mapbox style quality through validation, accessibility, and optimization tools.

## When to Use Quality Tools

### Pre-Production Checklist

Before deploying any Mapbox style to production:

1. **Validate all expressions** - Catch syntax errors before runtime
2. **Check color contrast** - Ensure text is readable (WCAG compliance)
3. **Validate GeoJSON sources** - Ensure data integrity
4. **Optimize style** - Reduce file size and improve performance
5. **Compare versions** - Understand what changed
6. **Remove empty layers** - Delete layers with no visible paint properties as a final cleanup step
7. **Simplify redundant boolean expressions** - Clean up filters with unnecessary boolean logic (e.g., `["all", expr]` → `expr`, `["any", false, expr]` → `expr`)

### During Development

**When adding GeoJSON data:**

- Always validate external GeoJSON with `validate_geojson_tool` before using as a source

**When writing expressions:**

- Validate expressions with `validate_expression_tool` as you write them
- Catch type mismatches early (e.g., using string operator on number)
- Verify operator availability in your Mapbox GL JS version
- Test expressions with expected data types

**When styling text/labels:**

- Check foreground/background contrast with `check_color_contrast_tool`
- Aim for WCAG AA minimum (4.5:1 for normal text, 3:1 for large text)
- Use AAA standard (7:1 for normal text) for better accessibility
- Consider different background scenarios (map tiles, overlays)

### Before Committing Changes

**Compare style versions:**

- Use `compare_styles_tool` to generate a diff report
- Review all layer changes, source modifications, and expression updates
- Understand the impact of your changes
- Document significant changes in commit messages

### Before Deployment

**Optimize the style:**

- Run `optimize_style_tool` to reduce file size
- Remove unused sources that reference deleted layers
- Eliminate duplicate layers with identical properties
- Simplify redundant boolean expressions in filters (e.g., collapse `["all", expr]` to `expr`, remove tautological conditions)
- Remove empty layers (layers with no visible paint properties) as a final cleanup step

## Validation Best Practices

### GeoJSON Validation

**Always validate when:**

- Loading GeoJSON from user uploads
- Fetching GeoJSON from external APIs
- Processing GeoJSON from third-party sources
- Converting between data formats

**Common GeoJSON errors:**

- Invalid coordinate ranges (longitude > 180 or < -180)
- Unclosed polygon rings (first and last coordinates must match)
- Wrong coordinate order (should be [longitude, latitude], not [latitude, longitude])
- Missing required properties (type, coordinates, geometry)
- Invalid geometry types or nesting

**Example workflow:**

```
1. Receive GeoJSON data
2. Validate with validate_geojson_tool
3. If valid: Add as source to style
4. If invalid: Fix errors, re-validate
```

### Expression Validation

**Validate expressions for:**

- Filter conditions (`filter` property on layers)
- Data-driven styling (`paint` and `layout` properties)
- Feature state expressions
- Dynamic property calculations

**Common expression errors:**

- Type mismatches (string operators on numbers)
- Invalid operator names or wrong syntax
- Wrong number of arguments for operators
- Nested expression errors
- Using unavailable operators for your GL JS version

**Prevention strategies:**

- Validate as you write expressions, not at runtime
- Test expressions with representative data
- Use type checking (expectedType parameter)
- Validate in context (layer, filter, paint, layout)

### Accessibility Validation

**WCAG Levels:**

- **AA** (minimum): 4.5:1 for normal text, 3:1 for large text
- **AAA** (enhanced): 7:1 for normal text, 4.5:1 for large text

**Text size categories:**

- **Normal**: < 18pt or < 14pt bold
- **Large**: ≥ 18pt or ≥ 14pt bold

**Common scenarios to check:**

- Text labels on map tiles
- POI labels with background colors
- Custom markers with text
- UI overlays on maps
- Legend text and symbols
- Attribution text

**Testing strategy:**

- Test against both light and dark map tiles
- Consider overlay backgrounds (popups, modals)
- Test in different lighting conditions (mobile outdoor use)
- Verify contrast at different zoom levels

## Quality Workflow Examples

### Basic Quality Check

```
1. Validate expressions in style
2. Check color contrast for text layers
3. Optimize if needed
```

### Full Pre-Production Workflow

```
1. Validate all GeoJSON sources
2. Validate all expressions (filters, paint, layout)
3. Check color contrast for all text layers
4. Compare with previous production version
5. Optimize style
6. Test optimized style
7. Deploy
```

### Troubleshooting Workflow

```
1. Compare working vs. broken style
2. Identify differences
3. Validate suspicious expressions
4. Check GeoJSON data if source-related
5. Verify color contrast if visibility issue
```

## Common Issues and Solutions

### Runtime Expression Errors

**Problem:** Map throws expression errors at runtime
**Solution:** Validate expressions with `validate_expression_tool` during development
**Prevention:** Add expression validation to pre-commit hooks or CI/CD

### Poor Text Readability

**Problem:** Text labels are hard to read on map
**Solution:** Check contrast with `check_color_contrast_tool`, adjust colors to meet WCAG AA
**Prevention:** Test text on both light and dark backgrounds, check at different zoom levels

### Large Style File Size

**Problem:** Style takes long to load or transfer
**Solution:** Run `optimize_style_tool` to remove redundancies and simplify
**Prevention:** Regularly optimize during development, remove unused sources immediately

### Invalid GeoJSON Source

**Problem:** GeoJSON source fails to load or render
**Solution:** Validate with `validate_geojson_tool`, fix coordinate issues, verify structure
**Prevention:** Validate all external GeoJSON before adding to style

### Unexpected Style Changes

**Problem:** Style changed but unsure what modified
**Solution:** Use `compare_styles_tool` to generate diff report
**Prevention:** Compare before/after for all significant changes, document modifications

## Tool Quick Reference

| Tool                        | Use When               | Output                     |
| --------------------------- | ---------------------- | -------------------------- |
| `validate_geojson_tool`     | Adding GeoJSON sources | Valid/invalid + error list |
| `validate_expression_tool`  | Writing expressions    | Valid/invalid + error list |
| `check_color_contrast_tool` | Styling text labels    | Passes/fails + WCAG levels |
| `compare_styles_tool`       | Reviewing changes      | Diff report with paths     |
| `optimize_style_tool`       | Before deployment      | Optimized style + savings  |

## Reference Files

For detailed guidance on specific topics, load the relevant reference:

- **`references/optimization.md`** — Optimization types, strategies, recommended order, and maintenance best practices
- **`references/comparison.md`** — Style comparison workflows, ignoreMetadata usage, and refactoring workflow
- **`references/ci-integration.md`** — Git pre-commit hooks, CI/CD pipeline steps, and code review checklist

> **Load instruction:** Read the reference file when the user needs in-depth guidance on that topic.

## Additional Resources

- [Mapbox Style Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/)
- [WCAG 2.1 Guidelines](https://www.w3.org/WAI/WCAG21/quickref/)
- [GeoJSON Specification (RFC 7946)](https://tools.ietf.org/html/rfc7946)
- [Mapbox Expression Reference](https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/)

© mapbox · MIT · mapbox/mapbox-agent-skills

Similar skills

Everything for Frontend and UI →

From the same set18

mapbox-style-patterns Ready-made Mapbox layer setups for common maps: POI finders, real estate, navigation, delivery. Useful when you want a proven style instead of picking colors from scratch. CX Codex +1 2,300installs mapbox-geospatial-operations A skill that helps your agent choose between Turf.js geometric math and Mapbox routing APIs. Useful when a task involves distances, zones or routes. CX Codex +1 2,200installs mapbox-cartography A skill that feeds your agent cartographic rules: layer hierarchy, color palettes, typography and zoom strategy for Mapbox styles. CX Codex +1 2,100installs mapbox-data-visualization-patterns Data visualization patterns for Mapbox GL JS in Claude Code, covering choropleth maps, heatmaps, and 3D styling. Helpful when plotting statistical data or point densities. CX Codex +1 2,100installs mapbox-search-integration Walks your agent through the full Mapbox search rollout: discovery questions first, then a working integration with the right API and parameters. CX Codex +1 1,900installs mapbox-token-security Security guidelines for Mapbox access tokens: scope management, URL restrictions, and client initialization guards. CX Codex +1 1,900installs mapbox-search-patterns Tells your agent which Mapbox search tool to call and which parameters to set for geocoding, POI search and address lookup. CX Codex +1 1,800installs mapbox-store-locator-patterns Store locator patterns for Mapbox GL JS. Helps agents implement marker layers, synchronized lists, and Turf distance calculations without DOM overhead. CX Codex +1 1,700installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor