
Mapbox Style Quality
- 1.4k installs
- 71 repo stars
- Updated August 4, 2026
- mapbox/mapbox-agent-skills
mapbox-style-quality is an agent skill for expert guidance on validating, optimizing, and ensuring quality of mapbox styles through validation, accessibility checks, and optimization. use when preparing styles for.
About
The mapbox-style-quality skill is designed for expert guidance on validating, optimizing, and ensuring quality of Mapbox styles through validation, accessibility checks, and optimization. Use when preparing styles for. 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. Invoke when the user preparing styles for production, debugging issues, or ensuring map quality standards.
- Always validate external GeoJSON with validate_geojson_tool before using as a source.
- 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.
Mapbox Style Quality by the numbers
- 1,411 all-time installs (skills.sh)
- +41 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #285 of 1,880 Design & UI/UX skills by installs in the Skillselion catalog
- Security screen: MEDIUM risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
mapbox-style-quality capabilities & compatibility
- Capabilities
- always validate external geojson with validate_g · validate expressions with validate_expression_to · catch type mismatches early (e.g., using string · verify operator availability in your mapbox gl j
- Use cases
- frontend
What mapbox-style-quality says it does
Expert guidance on validating, optimizing, and ensuring quality of Mapbox styles through validation, accessibility checks, and optimization. Use when preparing styles for productio
Expert guidance on validating, optimizing, and ensuring quality of Mapbox styles through validation, accessibility checks, and optimization. Use when preparing
npx skills add https://github.com/mapbox/mapbox-agent-skills --skill mapbox-style-qualityAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.4k |
|---|---|
| repo stars | ★ 71 |
| Security audit | 2 / 3 scanners passed |
| Last updated | August 4, 2026 |
| Repository | mapbox/mapbox-agent-skills ↗ |
How do I expert guidance on validating, optimizing, and ensuring quality of mapbox styles through validation, accessibility checks, and optimization. use when preparing styles for?
Expert guidance on validating, optimizing, and ensuring quality of Mapbox styles through validation, accessibility checks, and optimization. Use when preparing styles for.
Who is it for?
Developers using mapbox style quality workflows documented in SKILL.md.
Skip if: Skip when the task falls outside mapbox-style-quality scope or needs a different stack.
When should I use this skill?
User preparing styles for production, debugging issues, or ensuring map quality standards.
What you get
Completed mapbox-style-quality workflow with documented commands, files, and expected deliverables.
- Validated style JSON
- Accessibility audit notes
- Performance optimization recommendations
Files
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_toolbefore using as a source
When writing expressions:
- Validate expressions with
validate_expression_toolas 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_toolto 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_toolto 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]toexpr, 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-validateExpression Validation
Validate expressions for:
- Filter conditions (
filterproperty on layers) - Data-driven styling (
paintandlayoutproperties) - 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 neededFull 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. DeployTroubleshooting 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 issueCommon 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 Quality Guide
Quick reference for style validation, accessibility, performance optimization, and testing.
Style Validation Rules
Required Elements
✅ Valid version 8 style specification ✅ At least one source defined ✅ At least one layer defined ✅ Valid layer types and properties ✅ Proper source references in layers
Common Errors
// ❌ Layer references non-existent source
{
"id": "layer",
"source": "missing-source" // Error!
}
// ❌ Invalid property values
{
"paint": {
"fill-color": "not-a-color" // Error!
}
}
// ✅ Valid layer
{
"id": "layer",
"source": "valid-source",
"type": "fill",
"paint": {
"fill-color": "#ff0000"
}
}Accessibility Standards
Color Contrast (WCAG 2.1)
Requirements:
- Normal text: 4.5:1 contrast ratio
- Large text (18pt+): 3:1 contrast ratio
- UI components: 3:1 contrast ratio
// ✅ Good contrast for labels
'text-color': '#222222',
'text-halo-color': '#ffffff',
'text-halo-width': 2,
'text-halo-blur': 1Colorblind Accessibility
Test for:
- Deuteranopia (red-green, 8% of males)
- Protanopia (red-green, 1% of males)
- Tritanopia (blue-yellow, rare)
Rules:
- ❌ Don't rely on color alone
- ✅ Add patterns, labels, or symbols
- ✅ Use colorblind-safe palettes
- ✅ Test with colorblind simulators
Touch Targets
Mobile requirements:
- Minimum: 44x44 pixels (iOS)
- Recommended: 48x48 pixels (Material Design)
// ✅ Large enough tap targets
'icon-size': 1.2, // Larger icons
'icon-allow-overlap': false, // No overlapping
'symbol-spacing': 250 // Space between symbolsPerformance Optimization
Layer Count
Rule: Minimize layer count
- Good: < 50 layers
- Warning: 50-100 layers
- Problem: > 100 layers
Optimization:
// ❌ Multiple layers for categories
map.addLayer({ id: 'parks', filter: ['==', 'type', 'park'] });
map.addLayer({ id: 'water', filter: ['==', 'type', 'water'] });
// ✅ One layer with data-driven styling
map.addLayer({
id: 'features',
paint: {
'fill-color': ['match', ['get', 'type'], 'park', '#90EE90', 'water', '#87CEEB', '#CCCCCC']
}
});Source Optimization
// ✅ Set appropriate zoom ranges
{
"type": "vector",
"tiles": ["https://..."],
"minzoom": 0,
"maxzoom": 14 // Don't over-fetch
}
// ✅ Use generateId for feature state
{
"type": "geojson",
"data": geojson,
"generateId": true // Better performance
}Paint Properties
// ✅ Use data-driven expressions efficiently
'circle-radius': [
'interpolate', ['linear'], ['zoom'],
8, 2,
16, 8
]
// ❌ Avoid expensive operations in expressions
'circle-radius': [
'sqrt', // Expensive!
['*', ['get', 'value'], ['get', 'multiplier']]
]Style Testing Checklist
Visual Testing
✅ Test at multiple zoom levels (0, 5, 10, 15, 20) ✅ Test with different data densities ✅ Check label collisions ✅ Verify symbol/icon rendering ✅ Test on desktop and mobile viewports ✅ Check dark mode compatibility
Functional Testing
// ✅ Validate style loads
map.on('style.load', () => {
console.log('Style loaded successfully');
});
// ✅ Check for missing resources
map.on('error', (e) => {
console.error('Style error:', e);
});
// ✅ Validate sources
const sources = map.getStyle().sources;
Object.keys(sources).forEach((id) => {
console.log('Source:', id, sources[id]);
});
// ✅ Validate layers
const layers = map.getStyle().layers;
layers.forEach((layer) => {
console.log('Layer:', layer.id, 'Type:', layer.type);
});Performance Testing
// ✅ Measure style load time
const startTime = performance.now();
map.setStyle(style);
map.once('idle', () => {
console.log('Style load time:', performance.now() - startTime, 'ms');
});
// ✅ Monitor frame rate
const fps = map.getFPS();
console.log('FPS:', fps); // Should be close to 60
// ✅ Check layer count
console.log('Layer count:', map.getStyle().layers.length);Common Quality Issues
1. Label Collisions
// ❌ Overlapping labels
'text-allow-overlap': true // Bad for readability
// ✅ Prevent collisions
'text-allow-overlap': false,
'text-padding': 2,
'symbol-spacing': 2502. Inconsistent Styling
// ❌ Different styles for similar features
layer1: { 'line-width': 2 }
layer2: { 'line-width': 3 } // Inconsistent
// ✅ Consistent styling
'line-width': [
'match', ['get', 'class'],
'primary', 4,
'secondary', 2,
1
]3. Missing Error Handling
// ❌ No error handling
map.addSource('source', sourceData);
// ✅ Check before adding
if (!map.getSource('source')) {
map.addSource('source', sourceData);
}4. Poor Mobile Performance
Issues:
- Too many layers
- Large GeoJSON files
- High-resolution images
- Complex expressions
Solutions:
- Simplify geometry
- Use vector tiles
- Optimize images
- Cache data
Style Optimization Workflow
1. Validate Structure
- Check JSON syntax
- Verify all sources referenced
- Validate property types
2. Test Accessibility
- Check color contrast
- Test colorblind modes
- Verify touch targets
3. Optimize Performance
- Reduce layer count
- Simplify expressions
- Set appropriate zoom ranges
- Use feature state
4. Test Across Devices
- Desktop browsers
- Mobile browsers
- Different screen sizes
- Low-end devices
5. Monitor in Production
- Track load times
- Monitor errors
- Check tile request counts
- Measure FPS
Tools & Resources
Validation:
- Mapbox Style Specification: <https://docs.mapbox.com/mapbox-gl-js/style-spec/>
- JSON Schema validators
Accessibility:
- WebAIM Contrast Checker
- Coblis Color Blindness Simulator
- WAVE Accessibility Evaluation Tool
Performance:
- Chrome DevTools Performance tab
- Mapbox GL JS Performance metrics
- Bundle size analyzers
Quick Fixes
Slow rendering? → Reduce layer count, simplify geometry
Label collisions? → Increase text-padding, reduce symbol density
Poor mobile performance? → Use vector tiles, reduce complexity
Low contrast? → Add text halos, adjust colors
Icons not loading? → Check sprite paths, add error handlers
{
"skill_name": "mapbox-style-quality",
"evals": [
{
"id": 1,
"prompt": "I'm shipping a major Mapbox style update to production next week. I added 5 new GeoJSON sources from third-party APIs, wrote about a dozen custom filter and data-driven paint expressions, and added several text label layers to the map. What quality checks should I run and in what order before deploying?",
"expectations": [
"Validates GeoJSON sources with validate_geojson_tool before adding them as sources (catches invalid coordinates, unclosed rings, wrong coordinate order)",
"Validates all expressions with validate_expression_tool during development — not at runtime — to catch type mismatches and syntax errors early",
"Checks color contrast for text label layers against WCAG AA standard (4.5:1 ratio for normal text, 3:1 for large text)",
"Compares with the previous production style using compare_styles_tool to identify unintended changes",
"Optimizes the style with optimize_style_tool before deploying — recommends removing unused sources first, then duplicate layers, then simplifying expressions, then empty layers"
]
},
{
"id": 2,
"prompt": "My Mapbox style started at 80KB and has grown to 380KB over 6 months. I've deleted many layers but their source data is still referenced in the style. I also copy-pasted layers a lot, so there are duplicates with identical paint properties. What's the right approach to clean this up?",
"expectations": [
"Recommends running optimize_style_tool to handle this automatically",
"Explains to remove unused sources first — they are the main bloat after deleting layers",
"Then remove duplicate layers (layers with identical properties)",
"Then simplify redundant boolean expressions",
"Then remove empty layers as a final cleanup step",
"Recommends reviewing the optimization report (percentReduction, changes list) and testing before deploying"
]
},
{
"id": 3,
"prompt": "I have a layer filter that should show only cities with a population over 1 million, but I'm getting runtime expression errors. My filter is: `['==', ['get', 'population'], 'large']`. The population field in my data is stored as a number. What's wrong and how do I prevent this kind of error in the future?",
"expectations": [
"Identifies the type mismatch: population is a number but the filter compares it to the string 'large'",
"Provides the correct expression using a numeric comparison: ['>', ['get', 'population'], 1000000]",
"Recommends using validate_expression_tool during development to catch type mismatches before they cause runtime errors",
"Suggests adding expression validation to pre-commit hooks or CI/CD pipeline as a preventive measure"
]
}
]
}
Integration with Development Workflow
Git Pre-Commit Hook
# Validate expressions before commit
npm run validate-style
# Optimize before commit (optional)
npm run optimize-styleCI/CD Pipeline
1. Validate all expressions
2. Check accessibility compliance
3. Run optimization (warning if significant savings)
4. Compare with production version
5. Generate quality reportCode Review Checklist
- [ ] All expressions validated
- [ ] Text contrast meets WCAG AA
- [ ] GeoJSON sources validated
- [ ] Style optimized for production
- [ ] Changes documented in comparison report
Style Comparison Workflow
When to Compare Styles
Before merging changes:
- Review what changed in your feature branch
- Ensure no unintended modifications
- Generate change summary for PR description
When investigating issues:
- Compare working version vs. broken version
- Identify what changed between versions
- Narrow down root cause of problems
During migrations:
- Compare old format vs. new format
- Verify data integrity after conversion
- Document transformation differences
Comparison Best Practices
Use ignoreMetadata flag:
// Ignore metadata differences (id, owner, created, modified)
compare_styles_tool({
styleA: oldStyle,
styleB: newStyle,
ignoreMetadata: true
})Focus on meaningful changes:
- Layer additions/removals
- Source changes
- Expression modifications
- Paint/layout property updates
Document significant changes:
- Note breaking changes in documentation
- Update style version numbers
- Communicate changes to team/users
Refactoring Workflow
1. Create backup of current style
2. Make refactoring changes
3. Compare before vs. after
4. Validate all modified expressions
5. Optimize to clean up
6. Review size impactBest Practices Summary
Before Committing:
- Compare with previous version
- Document significant changes
- Validate modified expressions
Optimization Best Practices
When to Optimize
Before production deployment:
- After all development changes are complete
- After merging multiple feature branches
- When style has grown significantly over time
- Before major releases or launches
Benefits of optimization:
- Faster initial load times
- Reduced bandwidth usage
- Better runtime performance
- Cleaner, more maintainable code
Optimization Types
Remove unused sources:
- Automatically identifies sources not referenced by any layer
- Safe to remove without affecting functionality
- Common after deleting layers or refactoring
Remove duplicate layers:
- Finds layers with identical properties (excluding ID)
- Can occur when copying/pasting layers
- Reduces style complexity and file size
Simplify expressions:
- Converts
["all", true]→true - Converts
["any", false]→false - Converts
["!", false]→true - Converts
["!", true]→false - Improves expression evaluation performance
Remove empty layers:
- Removes layers with no paint or layout properties
- Preserves background layers (valid even when empty)
- Cleans up incomplete or placeholder layers
Consolidate filters:
- Identifies groups of layers with identical filter expressions
- Highlights opportunities for layer consolidation
- Doesn't automatically consolidate (informational only)
Optimization Strategy
Recommended order:
1. Remove unused sources first (reduces noise for other checks) 2. Remove duplicate layers (eliminates redundancy) 3. Simplify expressions (improves readability and performance) 4. Remove empty layers (final cleanup) 5. Review consolidation opportunities (manual step)
Selective optimization:
// All optimizations (recommended for production)
optimize_style_tool({ style })
// Specific optimizations only
optimize_style_tool({
style,
optimizations: ['remove-unused-sources', 'simplify-expressions']
})Review before deploying:
- Check the optimization report
- Verify size savings (percentReduction)
- Review the list of changes (optimizations array)
- Test the optimized style before deployment
Best Practices Summary
During Development:
- Validate expressions as you write them
- Check GeoJSON data when adding sources
- Test color contrast for new text layers
Before Production:
- Run full validation suite
- Check accessibility compliance
- Optimize style
- Test optimized version
- Generate quality report
Regular Maintenance:
- Periodically optimize to prevent bloat
- Review and consolidate similar layers
- Update expressions to use simpler forms
- Remove deprecated or unused code
Related skills
FAQ
What does mapbox-style-quality do?
Expert guidance on validating, optimizing, and ensuring quality of Mapbox styles through validation, accessibility checks, and optimization. Use when preparing styles for.
When should I use mapbox-style-quality?
User preparing styles for production, debugging issues, or ensuring map quality standards.
Is mapbox-style-quality safe to install?
Review the Security Audits panel on this page before installing in production.