Sentry cli

From mikker/dotfiles · View interactive version

Sentry cli is an AI agent skill from the GitHub repository mikker/dotfiles. Guide for using the Sentry CLI to interact with Sentry from the command line. Use when the user asks about viewing issues, events, projects, organizations, making API calls, or authenticating with Sentry via CLI.

How to use this skill

Skill file

Sentry CLI Usage Guide

Help users interact with Sentry from the command line using the sentry CLI.

Core rule for agents: just run the command. The sentry CLI auto-detects your org and project (from .sentryclirc, DSNs in .env/source, and the directory name), so do not list organizations and then list their projects to work out which one this checkout maps to — that manual discovery only duplicates work the CLI already does on every command. Pass an explicit <org>/<project> only when the CLI reports it can't detect the target or picks the wrong one.

Agent Guidance

Best practices and operational guidance for AI coding agents using the Sentry CLI.

Key Principles

Design Principles

The sentry CLI follows conventions from well-known tools — if you're familiar with them, that knowledge transfers directly:

Context Window Tips

Safety Rules

Exit Codes

The CLI uses semantic exit codes. Key ranges for agents:

| Range | Meaning | Agent Action |

|-------|---------|-------------|

| 0 | Success | Proceed normally |

| 10–19 | Auth error | Prompt user to run sentry auth login |

| 20–29 | Input error | Check command arguments and retry |

| 30–39 | API error | Retry or report to user |

| 40–49 | Feature unavailable | Inform user about plan/settings |

| 50–59 | Operation error | Report to user |

| 60–69 | Command-specific | Check stderr for details |

See Exit Codes for the complete reference.

Workflow Patterns

Investigate an Issue
# 1. Find the issue (auto-detects org/project from DSN or config)
sentry issue list --query "is:unresolved" --limit 5

# 2. Get details. For agents, prefer --json — it includes the full issue plus
# the latest event under `event`, so you get everything in one call.
sentry issue view PROJECT-123 --json

# 3. Get AI root cause analysis
sentry issue explain PROJECT-123

# 4. Get a fix plan
sentry issue plan PROJECT-123

sentry issue view <SHORT-ID> --json is the fastest way to get an agent up to

speed on an issue. Select just the fields you need with --fields instead of

consuming the whole payload — the latest event's request entry can carry live

session data (cookies, headers, body), so extract named fields rather than

dumping the entire object:

# Top-level issue fields
sentry issue view PROJECT-123 --json --fields shortId,title,culprit,count,userCount,permalink

# Named fields from the latest event — avoids pulling the full request/session blob
sentry issue view PROJECT-123 --json --fields event.id,event.title,event.dateCreated

# Just the request URL and method (not the whole request entry). Event data
# lives under event.entries[], each tagged with a `type` and `data` payload.
sentry issue view PROJECT-123 --json | jq '.event.entries[] | select(.type == "request") | .data | {url, method}'
Explore Traces and Performance
# 1. List recent traces (auto-detects org/project)
sentry trace list --limit 5

# 2. View a specific trace with span tree
sentry trace view abc123def456...

# 3. View spans for a trace
sentry span list abc123def456...

# 4. View logs associated with a trace
sentry trace logs abc123def456...
Stream Logs
# Stream logs in real-time (auto-detects org/project)
sentry log list --follow

# Filter logs by severity
sentry log list --query "severity:error"
Capture Events Locally (Spotlight)
# Run the app with the local server auto-enabled; tail errors/traces/logs.
# No DSN needed — with no DSN, events go ONLY to the local server (nothing
# reaches the user's Sentry org, no production quota). With a DSN set, the
# SDK sends to both.
sentry local run -- npm run dev          # or: python manage.py runserver, etc.

# From a CLI source checkout, run the Local UI in a second terminal, then open it.
pnpm --filter local dev
sentry local run --open -- npm run dev

# Watch only AI/agent (gen_ai, mcp) spans while iterating on an agent.
sentry local -f ai

# Server-side SDKs read SENTRY_SPOTLIGHT automatically. The CLI also injects
# the URL under every framework client prefix (NEXT_PUBLIC_, VITE_, PUBLIC_,
# NUXT_PUBLIC_, REACT_APP_, VUE_APP_, GATSBY_). Until the browser SDK reads
# these automatically (getsentry/sentry-javascript#18198), reference the var
# matching your framework in the client config:
# Sentry.init({ spotlight: process.env.NEXT_PUBLIC_SENTRY_SPOTLIGHT ?? false })
Query Sentry Documentation
# Ask a documentation question
sentry docs "How do I configure tracing in Next.js?"

# Search the documentation index
sentry docs list "source maps"
Check Sentry Service Status
# Show current status of Sentry services
sentry status

# Machine-readable status
sentry status --json
Explore the API Schema
# Browse all API resource categories
sentry schema

# Search for endpoints related to a resource
sentry schema issues

# Get details about a specific endpoint
sentry schema "GET /api/0/organizations/{organization_id_or_slug}/issues/"
Manage Releases
# Create a release — version must match Sentry.init({ release }) exactly
sentry release create my-org/1.0.0 --project my-project

# Associate commits via repository integration (needs local git checkout)
sentry release set-commits my-org/1.0.0 --auto

# Or read commits from local git history (no integration needed)
sentry release set-commits my-org/1.0.0 --local

# Mark the release as finalized
sentry release finalize my-org/1.0.0

# Record a production deploy
sentry release deploy my-org/1.0.0 production

Key details:

Arbitrary API Access
# GET request (default)
sentry api /api/0/organizations/my-org/

# POST request with data
sentry api /api/0/organizations/my-org/projects/ --method POST --data '{"name":"new-project","platform":"python"}'

Dashboard Layout

Sentry dashboards use a 6-column grid. When adding widgets, aim to fill complete rows (widths should sum to 6).

Display types with default sizes:

| Display Type | Width | Height | Category | Notes |

|---|---|---|---|---|

| big_number | 2 | 1 | common | Compact KPI — place 3 per row (2+2+2=6) |

| line | 3 | 2 | common | Half-width chart — place 2 per row (3+3=6) |

| area | 3 | 2 | common | Half-width chart — place 2 per row |

| bar | 3 | 2 | common | Half-width chart — place 2 per row |

| table | 6 | 2 | common | Full-width — always takes its own row |

| stacked_area | 3 | 2 | specialized | Stacked area chart |

| top_n | 3 | 2 | specialized | Top N ranked list |

| categorical_bar | 3 | 2 | specialized | Categorical bar chart |

| text | 3 | 2 | specialized | Static text/markdown widget |

| details | 3 | 2 | internal | Detail view |

| wheel | 3 | 2 | internal | Pie/wheel chart |

| rage_and_dead_clicks | 3 | 2 | internal | Rage/dead click visualization |

| server_tree | 3 | 2 | internal | Hierarchical tree display |

| agents_traces_table | 3 | 2 | internal | Agents traces table |

Use common types for general dashboards. Use specialized only when specifically requested. Avoid internal types unless the user explicitly asks.

Available datasets: spans (default), errors, metrics, issue, logs. Run sentry dashboard widget --help for dataset descriptions, query formats, and examples.

Row-filling examples:

# 3 KPIs filling one row (2+2+2 = 6)
sentry dashboard widget add <dashboard> "Error Count" --display big_number --query count
sentry dashboard widget add <dashboard> "P95 Duration" --display big_number --query p95:span.duration
sentry dashboard widget add <dashboard> "Throughput" --display big_number --query epm

# 2 charts filling one row (3+3 = 6)
sentry dashboard widget add <dashboard> "Errors Over Time" --display line --query count
sentry dashboard widget add <dashboard> "Latency Over Time" --display line --query p95:span.duration

# Full-width table (6 = 6)
sentry dashboard widget add <dashboard> "Top Endpoints" --display table \
  --query count --query p95:span.duration \
  --group-by transaction --sort -count --limit 10

Quick Reference

Time filtering

Use --period (alias: -t) to filter by time window:

sentry trace list --period 1h
sentry span list --period 24h
sentry span list -t 7d
Scoping to an org or project

Org and project are positional arguments following gh CLI conventions:

sentry trace list my-org/my-project
sentry issue list my-org/my-project
sentry span list my-org/my-project/abc123def456...
Listing spans in a trace

Pass the trace ID as a positional argument to span list:

sentry span list abc123def456...
sentry span list my-org/my-project/abc123def456...
Dataset names for the Events API

When querying the Events API (directly or via sentry api), valid dataset values are: spans, logs, errors, tracemetrics, profile_functions, and uptime_results.

Common Mistakes

Prerequisites

The CLI must be installed and authenticated before use.

Installation

curl https://cli.sentry.dev/install -fsS | bash
curl https://cli.sentry.dev/install -fsS | bash -s -- --version nightly

# Or install via npm/pnpm/bun
npm install -g sentry

Authentication

sentry auth
sentry auth --token YOUR_SENTRY_API_TOKEN
sentry auth status
sentry auth logout

Command Reference

Auth

Authenticate with Sentry

→ Full flags and examples: references/auth.md

Org

Work with Sentry organizations

→ Full flags and examples: references/org.md

Project

Work with Sentry projects

→ Full flags and examples: references/project.md

Issue

Manage Sentry issues

→ Full flags and examples: references/issue.md

Event

View, list, and send Sentry events

→ Full flags and examples: references/event.md

API

Make an authenticated API request

→ Full flags and examples: references/api.md

Alert

Manage Sentry alert rules

→ Full flags and examples: references/alert.md

Build

Manage mobile build artifacts

→ Full flags and examples: references/build.md

CLI

CLI-related commands

→ Full flags and examples: references/cli.md

Code-mappings

Manage code mappings for stack trace linking

→ Full flags and examples: references/code-mappings.md

Agent-conversation

List and view agent conversations

→ Full flags and examples: references/agent-conversation.md

Dart-symbol-map

Work with Dart/Flutter symbol maps

→ Full flags and examples: references/dart-symbol-map.md

Debug-files

Work with debug information files

→ Full flags and examples: references/debug-files.md

Dashboard

Manage Sentry dashboards

→ Full flags and examples: references/dashboard.md

Docs

Search and query current Sentry documentation

→ Full flags and examples: references/docs.md

Platform

List valid Sentry platform identifiers

→ Full flags and examples: references/platform.md

Proguard

Work with ProGuard/R8 mapping files

→ Full flags and examples: references/proguard.md

React-native

Upload React Native sourcemaps from build steps

→ Full flags and examples: references/react-native.md

Replay

Search and inspect Session Replays

→ Full flags and examples: references/replay.md

Release

Work with Sentry releases

→ Full flags and examples: references/release.md

Repo

Work with Sentry repositories

→ Full flags and examples: references/repo.md

Team

Work with Sentry teams

→ Full flags and examples: references/team.md

Explore

Query aggregate event data (Explore)

→ Full flags and examples: references/explore.md

Feedback

Search and inspect User Feedback

→ Full flags and examples: references/feedback.md

Log

View Sentry logs

→ Full flags and examples: references/log.md

Monitor

Work with Sentry cron monitors

→ Full flags and examples: references/monitor.md

Snapshots

Manage and compare snapshots

→ Full flags and examples: references/snapshots.md

Sourcemap

Manage sourcemaps

→ Full flags and examples: references/sourcemap.md

Span

List and view spans in projects or traces

→ Full flags and examples: references/span.md

Status

Check Sentry service status

→ Full flags and examples: references/status.md

Trace

View distributed traces

→ Full flags and examples: references/trace.md

Trial

Manage product trials

→ Full flags and examples: references/trial.md

Init

Initialize Sentry in your project (experimental)

→ Full flags and examples: references/init.md

Info

Print configuration and verify authentication

→ Full flags and examples: references/info.md

Local

Sentry for local development

→ Full flags and examples: references/local.md

Schema

Browse the Sentry API schema

→ Full flags and examples: references/schema.md

Global Options

All commands support the following global options:

Output Formats

JSON Output

Most list and view commands support --json flag for JSON output, making it easy to integrate with other tools:

sentry org list --json | jq '.[] | .slug'

Opening in Browser

View commands support -w or --web flag to open the resource in your browser:

sentry issue view PROJ-123 -w
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.