Features
The Sentry CLI includes several features designed to streamline your workflow, especially in complex project setups.
DSN Auto-Detection
The CLI automatically detects your Sentry project from your codebase, eliminating the need to specify --org and --project flags for every command.
How It Works
DSN detection follows this priority order (highest first):
- Source code - Explicit DSN in
Sentry.init()calls - Environment files -
.env.local,.env, etc. - Environment variable -
SENTRY_DSN
When a DSN is found, the CLI resolves it to your organization and project, then caches the result for fast subsequent lookups.
Supported Languages
The CLI can detect DSNs from source code in these languages:
| Language | File Extensions | Detection Pattern |
|---|---|---|
| JavaScript/TypeScript | .js, .ts, .jsx, .tsx, .mjs, .cjs | Sentry.init({ dsn: "..." }) |
| Python | .py | sentry_sdk.init(dsn="...") |
| Go | .go | sentry.Init(sentry.ClientOptions{Dsn: "..."}) |
| Java | .java | Sentry.init(options -> options.setDsn("...")) |
| Ruby | .rb | `Sentry.init { |
| PHP | .php | \Sentry\init(['dsn' => '...']) |
Caching
To avoid scanning your codebase on every command, the CLI caches:
- DSN location - Which file contains the DSN
- Resolved project - The org/project slugs from the API
The cache is validated on each run by checking if the source file still contains the same DSN. If the DSN changes or the file is deleted, a full scan is triggered.
Usage
Once your project has a DSN configured, commands automatically use it:
# Instead of:sentry issue list --org my-org --project my-project
# Just run:sentry issue listThe CLI will show which project was detected:
Detected project: my-app (from .env)
ID SHORT ID TITLE COUNT123456789 MYAPP-ABC TypeError: Cannot read prop... 142Monorepo Support & Alias System
In monorepos with multiple Sentry projects, the CLI generates short aliases for each project, making it easy to work with issues across projects.
How Aliases Work
When you run sentry issue list, the CLI:
- Scans for DSNs in monorepo directories (
packages/,apps/, etc.) - Generates unique short aliases for each project
- Caches the aliases for use with other commands
Aliases are the shortest unique prefix of each project slug. For example:
| Project Slug | Alias |
|---|---|
frontend | f |
functions | fu |
backend | b |
For projects with a common prefix (like spotlight-electron, spotlight-website), the prefix is stripped first:
| Project Slug | Alias |
|---|---|
spotlight-electron | e |
spotlight-website | w |
spotlight-backend | b |
Using Alias-Suffix Format
After running issue list, you can reference issues using the alias-suffix format:
# List issues - note the ALIAS columnsentry issue listALIAS SHORT ID TITLE COUNTe SPOTLIGHT-ELEC-4Y TypeError: Cannot read prop... 142w SPOTLIGHT-WEB-ABC Failed to fetch user data 89b SPOTLIGHT-BACK-XYZ Connection timeout 34# View issue using alias-suffixsentry issue view e-4Y
# Explain using alias-suffixsentry issue explain w-ABC
# Works with any issue commandsentry issue plan b-XYZCross-Organization Support
If you work with multiple organizations that have projects with the same slug, the CLI uses org-prefixed aliases:
ALIAS SHORT ID TITLEo1:api ORG1-API-123 Error in API handlero2:api ORG2-API-456 Database connection failedIssue ID Formats
The CLI accepts several formats for identifying issues:
Numeric ID
The internal Sentry issue ID:
sentry issue view 123456789sentry issue explain 987654321Full Short ID
The project-prefixed short ID shown in Sentry UI:
sentry issue view MYPROJECT-ABCsentry issue explain FRONTEND-XYZShort Suffix
Just the suffix portion when --project context is provided:
sentry issue view ABC --org my-org --project myprojectAlias-Suffix
The short alias plus suffix, available after running issue list:
# First, list issues to populate the alias cachesentry issue list
# Then use alias-suffix formatsentry issue view e-4Ysentry issue explain w-ABCsentry issue plan b-XYZThis format is especially useful in monorepos where you’re working across multiple projects.
AI-Powered Analysis with Seer
The CLI integrates with Sentry’s Seer AI to provide root cause analysis and fix plans directly in your terminal.
Root Cause Analysis
Use sentry issue explain to understand why an issue is happening:
sentry issue explain MYPROJECT-ABCSeer analyzes:
- Stack traces and error messages
- Related events and patterns
- Your codebase (via GitHub integration)
And provides:
- Detailed root cause explanation
- Reproduction steps
- Relevant code locations
Fix Plans
After understanding the root cause, use sentry issue plan to get actionable fix steps:
sentry issue plan MYPROJECT-ABCThe plan includes:
- Specific files to modify
- Code changes to make
- Implementation guidance
Requirements
For Seer integration to work, you need:
- Seer enabled for your organization
- GitHub integration configured with repository access
- Code mappings set up to link stack frames to source files
See Sentry’s Seer documentation for setup instructions.