Skip to content

feat(cli): Make sentry init print an agent setup guide - #1856

Open
betegon wants to merge 3 commits into
mainfrom
bt/init-agent-guide
Open

betegon wants to merge 3 commits into
mainfrom
bt/init-agent-guide

Conversation

@betegon

@betegon betegon commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

sentry init no longer runs the remote Mastra setup wizard. It prints a
Markdown guide (packages/cli/init.md) that a coding agent follows to add
Sentry to a project, the same way Railway (railway.com/agents.md) and
Vercel (vercel.com/get-started.md) hand agents a playbook:

  1. Install the CLI (skipped when reading from sentry init)
  2. Log in with sentry auth login
  3. Map the project: which apps to set up, which SDKs each one needs (often
    more than one: TanStack Start on Cloudflare needs @sentry/cloudflare
    and @sentry/tanstackstart-react), and whether Sentry is already there,
    in which case it upgrades or extends the setup instead
  4. Pick or create a Sentry project and read its DSN
  5. Suggest features that fit the app (errors, tracing, logs, metrics, Session
    Replay, profiling, crons, User Feedback, AI agent and MCP monitoring) and
    ask the user which to enable
  6. Install the SDKs from the current docs, never from remembered versions or
    APIs
  7. Verify with a test error: sentry local run --verify, then
    sentry issue list
  8. Report back from what was actually checked

The rules in steps 3, 5, and 6 come from the hosted wizard's agent prompts in
getsentry/cli-init-api: deployable contexts and one SDK per runtime,
evidence-only Crons/AI/MCP suggestions, features that need tracing, the DSN
placement policy, configuring only the chosen features, installing every
package the code imports, browser profiling's Document-Policy header, and
conversation tracking for AI agent monitoring.

Agents get the Markdown source, whether they read it through a pipe or a
pseudo-terminal that detectAgent recognizes; a person in a terminal gets it
rendered; --json returns { guide }. Like any command without input, it
takes no positionals and no flags of its own, only --json and --fields.
It sends nothing to Sentry, so it needs no login and skips the .sentryclirc
URL check (skipRcUrlCheck), which otherwise rejects a directory whose
.sentryclirc points at another Sentry host. With a self-hosted Sentry, the guide tells the agent to read the
docs.sentry.io pages as Markdown, because sentry docs needs a sentry.io
login. The docs site serves
the same file at https://cli.sentry.dev/init.md (a symlink in
apps/cli-docs/public, like install), so users can also say "Fetch
https://cli.sentry.dev/init.md and follow it" before the CLI is installed.

Removed

  • The wizard runner, its local tools, preflight, verification, Ink wizard
    screens, and the init-eval suite (src/lib/init/, test/lib/init/,
    test/init-eval/)
  • init's flags (--yes, --features, --dry-run, --team, --app,
    --no-tui), positionals ([target] [directory]), and their completer.
    Passing one now fails like it would on any other command
  • WizardError, wizard prompt telemetry, SENTRY_INIT_TUI, MASTRA_API_URL
    (sentry docs always calls the hosted service), and the update-notice
    suppression for init
  • @mastra/client-js and ink-spinner, plus the @ai-sdk/provider-utils@2.2.8
    patch that existed only for Mastra's copy
  • Code that only the wizard called: the glob engine (scan/glob.ts),
    safe-read.ts, resolveOrCreateTeam's deferAutoCreateOnEmptyOrg,
    buildProjectIssuesUrl, and exports such as looksLikePath,
    getUncommittedFiles, and captureOAuthScopeRecoveryGate
  • The zod/v3 stub's ZodType export and the GHSA-866g-f22w-33x8
    dependency-review allowance, which only Mastra's dependencies needed

Kept and moved

  • The org/project/account picker moved from src/lib/init/ui/ to
    src/lib/select-ui/ and is now only what those prompts use: one
    filterable, single-choice list drawn inline. The wizard's multiselect,
    centered layout, details panel, paging, shortcut registry, and frame
    width helpers are gone. The sidecar is still
    ink-app.js, so build and packaging are unchanged. Picker tests that went
    through the wizard App now render SelectPicker directly.
  • sentry docs still calls the same hosted service; its host check moved from
    init/init-service-auth.ts into docs-service.ts.
  • Exit codes 61–63 stay reserved; 64 is still used by
    sentry local run --verify, now named EXIT.VERIFY_FAILED.

Also

  • Labels in the compact picker no longer disappear when a long hint fills the
    row (found while porting the tests).

  • check:doc-examples now validates every sentry … command in init.md.

  • init.md is embedded by an init-guide step in script/generate.ts
    (phase 1, skipped when init.md hasn't changed).

  • The agent skill tells agents to use sentry init when adding Sentry.

  • The installers still honor SENTRY_INIT=1: they run sentry init after
    cli setup, which no longer skips its login step for it.

Not in this PR

  • The wizard workflow on the hosted Mastra worker can be retired separately;
    the worker still serves sentry docs.

Testing

Rebased on main at 9637d09:

  • pnpm run typecheck, root pnpm run lint, and pnpm run ci:policy pass
  • vitest run test/lib test/commands test/types test/script: 12,563 pass.
    The 22 failures are in permission and zstd tests (cli fix,
    agent-skills, completions install, db/resilient, code-scanner,
    upgrade, zstd-transport) that also fail on main in this sandbox,
    which runs as root on Node 22
  • script/bundle.ts builds dist/ink-app.js with mountSelectPrompt;
    sentry init prints the guide from the bundle, with no token and a
    self-hosted .sentryclirc in the directory, and rejects --yes and
    my-org/x like any command without input; the @sentry/mcp-server
    bundle builds and its bundle test passes

https://claude.ai/code/session_017M6odVd9nWxcAefpXRLd8M


Generated by Claude Code

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Nov 4, 2026 7:52pm UTC

Request Review

`sentry init` no longer runs the remote Mastra setup wizard. It prints
`packages/cli/init.md`, a guide a coding agent follows to add Sentry:
install the CLI, log in, map the project (which apps, which SDKs each
needs, whether Sentry is already there), pick a Sentry project, choose
features with the user, install the SDKs from the current docs, verify
with a test error, and report back. The docs site serves the same file
at https://cli.sentry.dev/init.md.

The wizard runner, tools, preflight, verification, Ink wizard screens,
init-eval suite, WizardError, wizard prompt telemetry, SENTRY_INIT_TUI,
@mastra/client-js, ink-spinner, and the provider-utils patch that only
Mastra needed are removed. The org/project picker moves to
src/lib/select-ui/, and the docs service keeps its host check in
docs-service.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017M6odVd9nWxcAefpXRLd8M
Delete the glob engine (`scan/glob.ts`), `safe-read.ts`, and the exports
nothing calls now that the wizard is gone: `looksLikePath`,
`getUncommittedFiles`, `captureOAuthScopeRecoveryGate`,
`parseOrgProjectFromSettingsUrl`, `FULL_BANNER_LINES`, `bannerLinesWidth`,
`YES_ALIASES`, and `BUFFER_SIZE`. Helpers the wizard imported but their
own module still uses are no longer exported. Comments that pointed at
the wizard now describe the remaining callers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017M6odVd9nWxcAefpXRLd8M
…eanup

`sentry init` failed in a directory whose `.sentryclirc` points at another
Sentry host: `buildCommand` checks that URL for every command unless it
sets `skipRcUrlCheck`, and `auth: false` does not skip it. `init` sends
nothing to Sentry, so it now skips the check.

- `init` takes no positionals and no flags of its own, only the `--json`
  and `--fields` every command gets. It no longer accepts the wizard's
  flags, and update notices are no longer suppressed for it.
- Print the Markdown source to agents behind a pseudo-terminal, and add
  an output schema for `--json`.
- Remove `MASTRA_API_URL`; `sentry docs` always calls the hosted service.
- Run `sentry init` from the installers after `cli setup`, which no longer
  skips the login step for `SENTRY_INIT=1`.
- Guide: read the docs pages as Markdown on self-hosted Sentry, the CLI
  picks the team, what to do when `sentry` isn't on PATH, and a
  `--verify` timeout doesn't mean the setup failed.
- Reduce the picker to the single filterable list the org, project, and
  account prompts use, without the wizard's shortcut registry and frame
  width helpers.
- Rename `EXIT.WIZARD_VERIFY` to `EXIT.VERIFY_FAILED`, and remove
  `deferAutoCreateOnEmptyOrg`, `buildProjectIssuesUrl`, the `zod/v3`
  stub's `ZodType`, and the provider-utils advisory allowance, which only
  the wizard needed.
- Update comments, docs, and test fixtures that still described the
  wizard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017M6odVd9nWxcAefpXRLd8M

This branch was successfully deployed

1 active deployment
Preview — ad0bf68d Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants