mapbox-token-security
This skill guides agents on Mapbox access token security, covering token types (public, secret, temporary), scope management with least privilege, URL…
Identity proven by GitHub's verified organisation badge (mapbox)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- f71cd72pinned Oct 9, 2026
- Context cost
- about 2,000 tokenswhen the skill loads
- GitHub stars
- 80on mapbox/mapbox-agent-skills
- Scripts
- None found
What it does
“Security best practices for Mapbox access tokens, including scope management, URL restrictions, rotation strategies, and protecting sensitive data. Use when creating, managing, or advising on Mapbox token security.”
Generated summary from the skill's own text
This skill guides agents on Mapbox access token security, covering token types (public, secret, temporary), scope management with least privilege, URL restrictions, and storage practices. It helps agents create and manage tokens safely, implement rotation strategies, and respond to security incidents.
When to use it
- Creating or configuring Mapbox tokens for web and mobile applications
- Deciding between public tokens for client-side use and secret tokens for server-side use
- Setting up URL restrictions and scope limitations to follow least privilege principle
- Implementing token rotation schedules or responding to token compromise incidents
When not to
- Managing non-Mapbox APIs or authentication systems
- Resolving general application security issues unrelated to Mapbox tokens
- Generating or validating tokens; this skill advises on practices, not token creation
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add mapbox/mapbox-agent-skills --skill mapbox-token-securityInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install mapbox/mapbox-agent-skills mapbox-token-security@f71cd72b8d8937b06db440538bd65559eb792c49Installs the commit we checked (f71cd72).
Copy by hand
Download the folder at f71cd72 and put it in .claude/skills/mapbox-token-security for Claude Code and in .agents/skills/mapbox-token-security for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install mapbox@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "mapbox-token-security" by Mapbox. Source, pinned to commit f71cd72b8d8937b06db440538bd65559eb792c49: https://github.com/mapbox/mapbox-agent-skills/tree/f71cd72b8d8937b06db440538bd65559eb792c49/skills/mapbox-token-security 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/mapbox-token-security/ for Claude Code and .agents/skills/mapbox-token-security/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/mapbox/mapbox-token-security
SKILL.md at the pin
---
name: mapbox-token-security
description: Security best practices for Mapbox access tokens, including scope management, URL restrictions, rotation strategies, and protecting sensitive data. Use when creating, managing, or advising on Mapbox token security.
---
# Mapbox Token Security Skill
This skill provides security expertise for managing Mapbox access tokens safely and effectively.
## Token Types and When to Use Them
### Public Tokens (pk.\*)
**Characteristics:**
- Can be safely exposed in client-side code
- Limited to specific public scopes only
- Can have URL restrictions
- Cannot access sensitive APIs
**When to use:**
- Client-side web applications
- Mobile apps
- Public-facing demos
- Embedded maps on websites
**Allowed scopes:**
- `styles:tiles` - Display style tiles (raster)
- `styles:read` - Read style specifications
- `fonts:read` - Access Mapbox fonts
- `datasets:read` - Read dataset data
- `vision:read` - Vision API access
### Secret Tokens (sk.\*)
**Characteristics:**
- **NEVER expose in client-side code**
- Full API access with any scopes
- Server-side use only
- Can create/manage other tokens
**When to use:**
- Server-side applications
- Backend services
- CI/CD pipelines
- Administrative tasks
- Token management
**Common scopes:**
- `styles:write` - Create/modify styles
- `styles:list` - List all styles
- `tokens:read` - View token information
- `tokens:write` - Create/modify tokens
- User feedback management scopes
### Temporary Tokens (tk.\*)
**Characteristics:**
- Short-lived (max 1 hour)
- Created by secret tokens
- Single-purpose use
- Automatically expire
**When to use:**
- One-time operations
- Temporary delegated access
- Short-lived demos
- Security-conscious workflows
## Scope Management Best Practices
### Principle of Least Privilege
**Always grant the minimum scopes needed:**
❌ **Bad:**
```javascript
// Overly permissive - don't do this
{
scopes: ['styles:read', 'styles:write', 'styles:list', 'styles:delete', 'tokens:read', 'tokens:write'];
}
```
✅ **Good:**
```javascript
// Only what's needed for displaying a map
{
scopes: ['styles:read', 'fonts:read'];
}
// Add 'styles:tiles' if your map uses raster tile sources
{
scopes: ['styles:read', 'fonts:read', 'styles:tiles'];
}
```
### Scope Combinations by Use Case
**Public Map Display (client-side):**
```json
{
"scopes": ["styles:read", "fonts:read", "styles:tiles"],
"note": "Public token for map display",
"allowedUrls": ["https://myapp.com/*"]
}
```
**Style Management (server-side):**
```json
{
"scopes": ["styles:read", "styles:write", "styles:list"],
"note": "Backend style management - SECRET TOKEN"
}
```
**Token Administration (server-side):**
```json
{
"scopes": ["tokens:read", "tokens:write"],
"note": "Token management only - SECRET TOKEN"
}
```
**Read-Only Access:**
```json
{
"scopes": ["styles:list", "styles:read", "tokens:read"],
"note": "Auditing/monitoring - SECRET TOKEN"
}
```
## URL Restrictions
### Why URL Restrictions Matter
URL restrictions limit where a public token can be used, preventing unauthorized usage if the token is exposed.
### Effective URL Patterns
✅ **Recommended patterns:**
```
https://myapp.com/* # Production domain
https://*.myapp.com/* # All subdomains
https://staging.myapp.com/* # Staging environment
http://localhost:* # Local development
```
❌ **Avoid these:**
```
* # No restriction (insecure)
http://* # Any HTTP site (insecure)
*.com/* # Too broad
```
### Multiple Environment Strategy
Create separate tokens for each environment:
```javascript
// Production
{
note: "Production - myapp.com",
scopes: ["styles:read", "fonts:read"],
allowedUrls: ["https://myapp.com/*", "https://www.myapp.com/*"]
}
// Staging
{
note: "Staging - staging.myapp.com",
scopes: ["styles:read", "fonts:read"],
allowedUrls: ["https://staging.myapp.com/*"]
}
// Development
{
note: "Development - localhost",
scopes: ["styles:read", "fonts:read"],
allowedUrls: ["http://localhost:*", "http://127.0.0.1:*"]
}
```
## Token Storage and Handling
### Server-Side (Secret Tokens)
✅ **DO:**
- Store in environment variables
- Use secret management services (AWS Secrets Manager, HashiCorp Vault)
- Encrypt at rest
- Limit access via IAM policies
- Log token usage
❌ **DON'T:**
- Hardcode in source code
- Commit to version control
- Store in plaintext configuration files
- Share via email or Slack
- Reuse across multiple services
**Example: Secure Environment Variable:**
```bash
# .env (NEVER commit this file)
MAPBOX_SECRET_TOKEN=sk.ey...
# .gitignore (ALWAYS include .env)
.env
.env.local
.env.*.local
```
### Client-Side (Public Tokens)
✅ **DO:**
- Use public tokens only
- Apply URL restrictions
- Use different tokens per app
- Rotate periodically
- Monitor usage
❌ **DON'T:**
- Expose secret tokens
- Use tokens without URL restrictions
- Share tokens between unrelated apps
- Use tokens with excessive scopes
**Example: Safe Client Usage (Vite):**
> **Note:** This example uses **Vite**. For Next.js, CRA, Angular, or a plain `window.MAPBOX_ACCESS_TOKEN` / CDN setup, see [Token Management](references/token-management.md). Do not chain `import.meta.env` and `process.env` in one expression — the unused path throws `ReferenceError` in the browser.
```javascript
// Public token with URL restrictions - SAFE (Vite)
const mapboxToken = import.meta.env.VITE_MAPBOX_ACCESS_TOKEN;
// Guard BEFORE constructing the map — missing tokens otherwise yield a silent blank map
if (!mapboxToken || mapboxToken === 'YOUR_MAPBOX_ACCESS_TOKEN') {
throw new Error('Missing VITE_MAPBOX_ACCESS_TOKEN — set it in env before creating the map');
}
mapboxgl.accessToken = mapboxToken;
```
### Agent anti-pattern: skip the token guard
Agents often assign `mapboxgl.accessToken` and call `new mapboxgl.Map(...)` with no check. That fails closed as a blank canvas with no UI error.
**Always:**
1. Resolve the token from the env pattern for your bundler (never hardcode a real `pk.` in source)
2. Validate it is present and not a placeholder
3. Only then set `accessToken` and construct the map
## Security Checklist
**Token Creation:**
- [ ] Use public tokens for client-side, secret for server-side
- [ ] Apply principle of least privilege for scopes
- [ ] Add URL restrictions to public tokens
- [ ] Use descriptive names/notes for token identification
- [ ] Document intended use and environment
**Token Management:**
- [ ] Store secret tokens in environment variables or secret managers
- [ ] Never commit tokens to version control
- [ ] Rotate tokens every 90 days (or per policy)
- [ ] Remove unused tokens promptly
- [ ] Separate tokens by environment (dev/staging/prod)
- [ ] Guard missing tokens in client code before `new mapboxgl.Map`
**Monitoring:**
- [ ] Track token usage patterns
- [ ] Set up alerts for unusual activity
- [ ] Regular security audits (monthly)
- [ ] Review team access quarterly
- [ ] Scan repositories for exposed tokens
**Incident Response:**
- [ ] Documented revocation procedure
- [ ] Emergency contact list
- [ ] Rotation process documented
- [ ] Post-incident review template
- [ ] Team training on security procedures
## Reference Files
For detailed guidance on specific topics, load these references as needed:
- **`references/token-management.md`** — Bundler-specific env var names and access patterns (Vite / Next / CRA / Angular / CDN). Load when: wiring tokens in a different framework than the Vite example above.
- **`references/rotation-monitoring.md`** — Token rotation strategies (zero-downtime + emergency), monitoring metrics, alerting rules, and monthly/quarterly audit checklists. Load when: implementing rotation, setting up monitoring, or conducting audits.
- **`references/incident-response.md`** — Step-by-step incident response plan and common security mistakes with code examples. Load when: responding to a token compromise, reviewing code for security issues, or training on anti-patterns.
## When to Use This Skill
Invoke this skill when:
- Creating new tokens
- Deciding between public vs secret tokens
- Setting up token restrictions
- Implementing token rotation
- Investigating security incidents
- Conducting security audits
- Training team on token security
- Reviewing code for token exposure
From mapbox/mapbox-agent-skills at f71cd72, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.md.
View SKILL.md on GitHub at f71cd72Files
- SKILL.md8.5 KB · 2d7f46a90f8f
- AGENTS.md6.0 KB · 6fff80d7f8f3
- evals/
- evals.json3.5 KB · c8a7841358d5
- references/
- incident-response.md2.3 KB · 194691bfcc58
- rotation-monitoring.md2.0 KB · 9689f6ddfeb9
- token-management.md1.1 KB · e11959df5fe9
6 files, 23 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at f71cd72More from Mapbox
mapbox-android-patterns
This skill provides official patterns for integrating Mapbox Maps SDK v11 on Android, covering setup, map initialization, markers, user location display…
Claude Code, Codex, Cursor +4 · about 2.5K tokens · pinned 6 days ago
mapbox-cartography
This skill provides cartographic expertise for designing effective maps with Mapbox, covering visual hierarchy, color theory, typography, and zoom strategies.
Claude Code, Codex, Cursor +4 · about 1.7K tokens · pinned 6 days ago
mapbox-data-visualization-patterns
This skill teaches the agent to implement data visualization patterns on Mapbox maps, including choropleth maps, heat maps, 3D extrusions, and animated data…
Claude Code, Codex, Cursor +4 · about 2.1K tokens · pinned 6 days ago
mapbox-flutter-patterns
This skill teaches agents the standard patterns for integrating the Mapbox Maps Flutter SDK into iOS and Android apps written in Dart.
Claude Code, Codex, Cursor +4 · about 2.3K tokens · pinned 6 days ago
mapbox-geospatial-operations
This skill guides agents on selecting appropriate geospatial tools from the Mapbox MCP Server based on problem requirements.
Claude Code, Codex, Cursor +4 · about 4.8K tokens · pinned 6 days ago
mapbox-google-maps-migration
This skill guides developers migrating from Google Maps Platform to Mapbox GL JS by comparing APIs, translating patterns, and highlighting architectural…
Claude Code, Codex, Cursor +4 · about 2.9K tokens · pinned 6 days ago
Related in Security
claude-security
Scans your repository for security issues using Claude, examines code changes or commits for vulnerabilities, and generates patch files to fix findings.
by AnthropicOfficial publisher
Claude Code · about 1K tokens · pinned 6 days ago
sensitive-logging-audit
The skill helps audit and fix sensitive data leaks in Python SDK logging, exceptions, and telemetry by collecting candidate sinks, manually tracing values…
by OpenAIOfficial publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 970 tokens · pinned 6 days ago
security-audit
This skill guides security audits of codebases, APIs, and services by finding vulnerabilities that cross real trust boundaries.
by CloudflareOfficial publisher
Contains scripts
Claude Code · about 5.4K tokens · pinned 6 days ago
assess-patch-risk
This skill analyzes patch artifacts to assess their program impact, regression risk, and suitability for automated merging.
by OpenAIOfficial publisher
Codex · about 2.3K tokens · pinned 6 days ago
attack-path-analysis
This skill analyzes security findings to build explicit attack paths from source to sink, calibrates severity, and decides whether each finding is reportable.
by OpenAIOfficial publisher
Codex · about 2.1K tokens · pinned 6 days ago
deep-security-scan
Performs exhaustive, multi-pass security analysis across a repository or scoped directory by running repeated independent security scans and aggregating…
by OpenAIOfficial publisher
Codex · about 3.4K tokens · pinned 6 days ago