mapbox-style-quality by mapbox/mapbox-agent-skills
npx skills add https://github.com/mapbox/mapbox-agent-skills --skill mapbox-style-quality此技能通过验证、可访问性和优化工具,提供确保 Mapbox 样式质量的专家指导。
在将任何 Mapbox 样式部署到生产环境之前:
当添加 GeoJSON 数据时:
validate_geojson_tool 验证外部 GeoJSON当编写表达式时:
validate_expression_tool 进行验证当设置文本/标签样式时:
check_color_contrast_tool 检查前景/背景对比度广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
比较样式版本:
compare_styles_tool 生成差异报告优化样式:
optimize_style_tool 以减小文件大小在以下情况始终进行验证:
常见的 GeoJSON 错误:
示例工作流:
1. 接收 GeoJSON 数据
2. 使用 validate_geojson_tool 验证
3. 如果有效:添加为样式数据源
4. 如果无效:修复错误,重新验证
验证以下表达式:
filter 属性)paint 和 layout 属性)常见的表达式错误:
预防策略:
WCAG 级别:
文本大小分类:
需要检查的常见场景:
测试策略:
在生产部署之前:
优化的好处:
移除未使用的数据源:
移除重复图层:
简化表达式:
["all", true] → true["any", false] → false["!", false] → true["!", true] → false移除空图层:
合并过滤器:
推荐顺序:
选择性优化:
// 所有优化(生产环境推荐)
optimize_style_tool({ style })
// 仅进行特定优化
optimize_style_tool({
style,
optimizations: ['remove-unused-sources', 'simplify-expressions']
})
部署前审查:
合并更改之前:
调查问题时:
迁移期间:
使用 ignoreMetadata 标志:
// 忽略元数据差异(id、owner、created、modified)
compare_styles_tool({
styleA: oldStyle,
styleB: newStyle,
ignoreMetadata: true
})
关注有意义的更改:
记录重大更改:
1. 验证样式中的表达式
2. 检查文本图层的颜色对比度
3. 如有需要,进行优化
1. 验证所有 GeoJSON 数据源
2. 验证所有表达式(过滤器、绘制、布局)
3. 检查所有文本图层的颜色对比度
4. 与之前的生产版本比较
5. 优化样式
6. 测试优化后的样式
7. 部署
1. 比较工作样式与故障样式
2. 识别差异
3. 验证可疑表达式
4. 如果与数据源相关,检查 GeoJSON 数据
5. 如果是可见性问题,验证颜色对比度
1. 创建当前样式的备份
2. 进行重构更改
3. 比较重构前后
4. 验证所有修改过的表达式
5. 进行优化以清理
6. 审查大小影响
问题: 地图在运行时抛出表达式错误
解决方案: 在开发期间使用 validate_expression_tool 验证表达式
预防: 将表达式验证添加到预提交钩子或 CI/CD 中
问题: 文本标签在地图上难以阅读
解决方案: 使用 check_color_contrast_tool 检查对比度,调整颜色以满足 WCAG AA 标准
预防: 在浅色和深色背景上测试文本,在不同缩放级别检查
问题: 样式加载或传输时间过长
解决方案: 运行 optimize_style_tool 以移除冗余并简化
预防: 在开发期间定期优化,立即移除未使用的数据源
问题: GeoJSON 数据源无法加载或渲染
解决方案: 使用 validate_geojson_tool 验证,修复坐标问题,验证结构
预防: 在将外部 GeoJSON 添加到样式之前进行验证
问题: 样式已更改但不清楚修改了什么
解决方案: 使用 compare_styles_tool 生成差异报告
预防: 对所有重大更改进行前后比较,记录修改
# 提交前验证表达式
npm run validate-style
# 提交前优化(可选)
npm run optimize-style
1. 验证所有表达式
2. 检查可访问性合规性
3. 运行优化(如果节省显著则发出警告)
4. 与生产版本比较
5. 生成质量报告
开发期间:
提交之前:
生产之前:
定期维护:
| 工具 | 使用时机 | 输出 |
|---|---|---|
validate_geojson_tool | 添加 GeoJSON 数据源时 | 有效/无效 + 错误列表 |
validate_expression_tool | 编写表达式时 | 有效/无效 + 错误列表 |
check_color_contrast_tool | 设置文本标签样式时 | 通过/失败 + WCAG 级别 |
compare_styles_tool | 审查更改时 | 包含路径的差异报告 |
optimize_style_tool | 部署之前 | 优化后的样式 + 节省量 |
每周安装数
303
仓库
GitHub 星标数
35
首次出现
2026年2月2日
安全审计
安装于
codex275
opencode274
gemini-cli271
github-copilot266
kimi-cli255
amp255
This skill provides expert guidance on ensuring Mapbox style quality through validation, accessibility, and optimization tools.
Before deploying any Mapbox style to production:
When adding GeoJSON data:
validate_geojson_tool before using as a sourceWhen writing expressions:
validate_expression_tool as you write themWhen styling text/labels:
check_color_contrast_toolCompare style versions:
compare_styles_tool to generate a diff reportOptimize the style:
optimize_style_tool to reduce file sizeAlways validate when:
Common GeoJSON errors:
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
Validate expressions for:
filter property on layers)paint and layout properties)Common expression errors:
Prevention strategies:
WCAG Levels:
Text size categories:
Common scenarios to check:
Testing strategy:
Before production deployment:
Benefits of optimization:
Remove unused sources:
Remove duplicate layers:
Simplify expressions:
["all", true] → true["any", false] → false["!", false] → true["!", true] → falseRemove empty layers:
Consolidate filters:
Recommended order:
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:
Before merging changes:
When investigating issues:
During migrations:
Use ignoreMetadata flag:
// Ignore metadata differences (id, owner, created, modified)
compare_styles_tool({
styleA: oldStyle,
styleB: newStyle,
ignoreMetadata: true
})
Focus on meaningful changes:
Document significant changes:
1. Validate expressions in style
2. Check color contrast for text layers
3. Optimize if needed
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
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
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 impact
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
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
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
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
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
# Validate expressions before commit
npm run validate-style
# Optimize before commit (optional)
npm run optimize-style
1. Validate all expressions
2. Check accessibility compliance
3. Run optimization (warning if significant savings)
4. Compare with production version
5. Generate quality report
During Development:
Before Committing:
Before Production:
Regular Maintenance:
| 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 |
Weekly Installs
303
Repository
GitHub Stars
35
First Seen
Feb 2, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex275
opencode274
gemini-cli271
github-copilot266
kimi-cli255
amp255
Vue.js开发指南:最佳实践、组件设计与响应式编程核心原则
1,500 周安装
| Before deployment |
| Optimized style + savings |