You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(config): support .sentryclirc config file for per-directory defaults
Add backward-compatible support for .sentryclirc INI config files.
The CLI walks up from CWD to find config files, merging them
(closest wins per-field) with ~/.sentryclirc as a global fallback.
Supported fields:
- [defaults] org, project, url
- [auth] token
Token and URL are applied via env shim (SENTRY_AUTH_TOKEN, SENTRY_URL).
Org and project are inserted into the resolution chain between env vars
and SQLite defaults with source tracking.
This enables per-directory project defaults in monorepos and seamless
migration from legacy sentry-cli.
Copy file name to clipboardExpand all lines: docs/src/content/docs/agent-guidance.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Best practices and operational guidance for AI coding agents using the Sentry CL
12
12
-**Use `sentry schema` to explore the API** — if you need to discover API endpoints, run `sentry schema` to browse interactively or `sentry schema <resource>` to search. This is faster than fetching OpenAPI specs externally.
13
13
-**Use `sentry issue view <id>` to investigate issues** — when asked about a specific issue (e.g., `CLI-G5`, `PROJECT-123`), use `sentry issue view` directly.
14
14
-**Use `--json` for machine-readable output** — pipe through `jq` for filtering. Human-readable output includes formatting that is hard to parse.
15
-
-**The CLI auto-detects org/project** — most commands work without explicit targets by scanning for DSNs in `.env` files, source code, config defaults, and directory names. Only specify `<org>/<project>` when the CLI reports it can't detect the target or detects the wrong one.
15
+
-**The CLI auto-detects org/project** — most commands work without explicit targets by checking `.sentryclirc` config files, scanning for DSNs in `.env` files and source code, and matching directory names. Only specify `<org>/<project>` when the CLI reports it can't detect the target or detects the wrong one.
16
16
17
17
## Design Principles
18
18
@@ -213,7 +213,7 @@ When querying the Events API (directly or via `sentry api`), valid dataset value
213
213
-**Wrong issue ID format**: Use `PROJECT-123` (short ID), not the numeric ID `123456789`. The short ID includes the project prefix.
214
214
-**Pre-authenticating unnecessarily**: Don't run `sentry auth login` before every command. The CLI detects missing/expired auth and prompts automatically. Only run `sentry auth login` if you need to switch accounts.
215
215
-**Missing `--json` for piping**: Human-readable output includes formatting. Use `--json` when parsing output programmatically.
216
-
-**Specifying org/project when not needed**: Auto-detection resolves org/project from DSNs, env vars, config defaults, and directory names. Let it work first — only add `<org>/<project>` if the CLI says it can't detect the target or detects the wrong one.
216
+
-**Specifying org/project when not needed**: Auto-detection resolves org/project from `.sentryclirc` config files, DSNs, env vars, and directory names. Let it work first — only add `<org>/<project>` if the CLI says it can't detect the target or detects the wrong one.
217
217
-**Confusing `--query` syntax**: The `--query` flag uses Sentry search syntax (e.g., `is:unresolved`, `assigned:me`), not free text search.
218
218
-**Not using `--web`**: View commands support `-w`/`--web` to open the resource in the browser — useful for sharing links.
219
219
-**Fetching API schemas instead of using the CLI**: Prefer `sentry schema` to browse the API and `sentry api` to make requests — the CLI handles authentication and endpoint resolution, so there's rarely a need to download OpenAPI specs separately.
Copy file name to clipboardExpand all lines: docs/src/content/docs/configuration.md
+60-2Lines changed: 60 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,67 @@
1
1
---
2
2
title: Configuration
3
-
description: Environment variables and configuration options for the Sentry CLI
3
+
description: Environment variables, config files, and configuration options for the Sentry CLI
4
4
---
5
5
6
-
The Sentry CLI can be configured through environment variables and a local database. Most users don't need to set any of these — the CLI auto-detects your project from your codebase and stores credentials locally after `sentry auth login`.
6
+
The Sentry CLI can be configured through config files, environment variables, and a local database. Most users don't need to set any of these — the CLI auto-detects your project from your codebase and stores credentials locally after `sentry auth login`.
7
+
8
+
## Configuration File (`.sentryclirc`)
9
+
10
+
The CLI supports a `.sentryclirc` config file using standard INI syntax. This is the same format used by the legacy `sentry-cli` tool, so existing config files are automatically picked up.
11
+
12
+
### How It Works
13
+
14
+
The CLI looks for `.sentryclirc` files by walking up from your current directory toward the filesystem root. If multiple files are found, values from the closest file take priority, with `~/.sentryclirc` serving as a global fallback.
15
+
16
+
```ini
17
+
[defaults]
18
+
org = my-org
19
+
project = my-project
20
+
21
+
[auth]
22
+
token = sntrys_...
23
+
```
24
+
25
+
### Supported Fields
26
+
27
+
| Section | Key | Description |
28
+
|---------|-----|-------------|
29
+
|`[defaults]`|`org`| Default organization slug |
30
+
|`[defaults]`|`project`| Default project slug |
31
+
|`[defaults]`|`url`| Sentry base URL (for self-hosted) |
32
+
|`[auth]`|`token`| Auth token (mapped to `SENTRY_AUTH_TOKEN`) |
33
+
34
+
### Monorepo Setup
35
+
36
+
In monorepos, place a `.sentryclirc` at the repo root with your org, then add per-package configs with just the project:
37
+
38
+
```
39
+
my-monorepo/
40
+
.sentryclirc # [defaults] org = my-company
41
+
packages/
42
+
frontend/
43
+
.sentryclirc # [defaults] project = frontend-web
44
+
backend/
45
+
.sentryclirc # [defaults] project = backend-api
46
+
```
47
+
48
+
When you run a command from `packages/frontend/`, the CLI resolves `org = my-company` from the root and `project = frontend-web` from the closest file.
49
+
50
+
### Resolution Priority
51
+
52
+
When the CLI needs to determine your org and project, it checks these sources in order:
53
+
54
+
1.**Explicit CLI arguments** — `sentry issue list my-org/my-project`
3.**`.sentryclirc` config file** — walked up from CWD, merged with `~/.sentryclirc`
57
+
4.**DSN auto-detection** — scans source code and `.env` files
58
+
5.**Directory name inference** — matches your directory name against project slugs
59
+
60
+
The first source that provides both org and project wins. For org-only commands, only the org is needed.
61
+
62
+
### Backward Compatibility
63
+
64
+
If you previously used the legacy `sentry-cli` and have a `~/.sentryclirc` file, the new CLI reads it automatically. The `[defaults]` and `[auth]` sections are fully compatible. The `[auth] token` value is mapped to the `SENTRY_AUTH_TOKEN` environment variable internally (only if the env var is not already set).
Copy file name to clipboardExpand all lines: docs/src/content/docs/features.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ The Sentry CLI includes several features designed to streamline your workflow, e
7
7
8
8
## DSN Auto-Detection
9
9
10
-
The CLI automatically detects your Sentry project from your codebase, eliminating the need to specify the target for every command.
10
+
The CLI automatically detects your Sentry project from your codebase, eliminating the need to specify the target for every command. DSN detection is one part of the [resolution priority chain](./configuration/#resolution-priority) — it runs after checking for explicit arguments, environment variables, and `.sentryclirc` config files.
11
11
12
12
### How It Works
13
13
@@ -19,6 +19,10 @@ DSN detection follows this priority order (highest first):
19
19
20
20
When a DSN is found, the CLI resolves it to your organization and project, then caches the result for fast subsequent lookups.
21
21
22
+
:::tip
23
+
For monorepos or when DSN detection picks up the wrong project, use a [`.sentryclirc` config file](./configuration/#configuration-file-sentryclirc) to pin your org/project explicitly.
24
+
:::
25
+
22
26
### Supported Languages
23
27
24
28
The CLI can detect DSNs from source code in these languages:
Copy file name to clipboardExpand all lines: plugins/sentry-cli/skills/sentry-cli/SKILL.md
+4-25Lines changed: 4 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ Best practices and operational guidance for AI coding agents using the Sentry CL
22
22
-**Use `sentry schema` to explore the API** — if you need to discover API endpoints, run `sentry schema` to browse interactively or `sentry schema <resource>` to search. This is faster than fetching OpenAPI specs externally.
23
23
-**Use `sentry issue view <id>` to investigate issues** — when asked about a specific issue (e.g., `CLI-G5`, `PROJECT-123`), use `sentry issue view` directly.
24
24
-**Use `--json` for machine-readable output** — pipe through `jq` for filtering. Human-readable output includes formatting that is hard to parse.
25
-
-**The CLI auto-detects org/project** — most commands work without explicit targets by scanning for DSNs in `.env` files, source code, config defaults, and directory names. Only specify `<org>/<project>` when the CLI reports it can't detect the target or detects the wrong one.
25
+
-**The CLI auto-detects org/project** — most commands work without explicit targets by checking `.sentryclirc` config files, scanning for DSNs in `.env` files and source code, and matching directory names. Only specify `<org>/<project>` when the CLI reports it can't detect the target or detects the wrong one.
26
26
27
27
### Design Principles
28
28
@@ -223,7 +223,7 @@ When querying the Events API (directly or via `sentry api`), valid dataset value
223
223
-**Wrong issue ID format**: Use `PROJECT-123` (short ID), not the numeric ID `123456789`. The short ID includes the project prefix.
224
224
-**Pre-authenticating unnecessarily**: Don't run `sentry auth login` before every command. The CLI detects missing/expired auth and prompts automatically. Only run `sentry auth login` if you need to switch accounts.
225
225
-**Missing `--json` for piping**: Human-readable output includes formatting. Use `--json` when parsing output programmatically.
226
-
-**Specifying org/project when not needed**: Auto-detection resolves org/project from DSNs, env vars, config defaults, and directory names. Let it work first — only add `<org>/<project>` if the CLI says it can't detect the target or detects the wrong one.
226
+
-**Specifying org/project when not needed**: Auto-detection resolves org/project from `.sentryclirc` config files, DSNs, env vars, and directory names. Let it work first — only add `<org>/<project>` if the CLI says it can't detect the target or detects the wrong one.
227
227
-**Confusing `--query` syntax**: The `--query` flag uses Sentry search syntax (e.g., `is:unresolved`, `assigned:me`), not free text search.
228
228
-**Not using `--web`**: View commands support `-w`/`--web` to open the resource in the browser — useful for sharing links.
229
229
-**Fetching API schemas instead of using the CLI**: Prefer `sentry schema` to browse the API and `sentry api` to make requests — the CLI handles authentication and endpoint resolution, so there's rarely a need to download OpenAPI specs separately.
@@ -436,29 +436,8 @@ Browse the Sentry API schema
436
436
437
437
→ Full flags and examples: `references/schema.md`
438
438
439
-
## Global Options
440
-
441
-
All commands support the following global options:
0 commit comments