Skip to content

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

Merged
betegon merged 7 commits into
mainfrom
bt/init-agent-guide
Nov 5, 2026
Merged

betegon merged 7 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/get-started-with-sentry.md (a symlink in
apps/cli-docs/public, like install), so users can also say "Fetch
https://cli.sentry.dev/get-started-with-sentry.md and follow it" before the
CLI is installed. It isn't called init.md there, which would read as a
guide to initializing the CLI itself.

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 are gone rather than reserved, since the CLI is still
    0.x; 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.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 5, 2026 7:16pm 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
Conflicts:
- Wizard files main changed (init/ui/ink-ui.ts, stdin-reopen.ts,
  tools/create-sentry-project.ts, verify-setup.ts, wizard-runner.ts and
  their tests) stay deleted; main's edits there were lint and
  error-reporting changes with nothing to carry over.
- force-exit.ts stays deleted, as on main (#1960).
- .oxlintrc.json: keep main's codemod ignore, drop the init-eval one.
- env-registry.ts: keep main's SENTRY_GAMES_API_URL, drop SENTRY_INIT_TUI.
- cli/setup.ts: keep main's SENTRY_SETUP_CODE login skip, drop the
  SENTRY_INIT one, and restore the getEnv import it needs.

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

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think there's value in listing all available SDKs to the agent, the version we compiled from sentry release registry, ask it to pick one from there and instruct it to use sentry docs to keep going or generate a guide or something.

@betegon

betegon commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

@BYK thanks for the review, i'm making those changes.

About showing the sdks, i've had a bad experience with it in init in the past:

  • sometimes you need more than 1 sdk
  • if for any reason the agent doesn't look at docs, it may get the sdk and install it from the wrong registry (e.g. in the past we were using deno.land for the deno sdk and now it's npm so that could fail)
  • if we force the agent to always look at docs, there's no need to tell it about the sdk registry because that's in the docs

The CLI is still 0.x, so exit codes 61–63 don't need to stay reserved
after the `sentry init` wizard's removal. 64 stays: `sentry local run
--verify` uses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017M6odVd9nWxcAefpXRLd8M
On cli.sentry.dev, `init.md` reads as a guide to initializing the CLI
itself. The guide is about adding Sentry to a project, so the docs site
now serves it at https://cli.sentry.dev/get-started-with-sentry.md.
`sentry init` still prints the same file.

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

BYK commented Nov 5, 2026

Copy link
Copy Markdown
Member

@betegon I'm not suggesting that we propose an SDK, merely providing the list of all available SDKs from our registry to the agent so it can make the decision to add multiple if needed which we should also mention.

…e init guide

The guide only explained several SDKs through framework and runtime, and
assumed one Sentry project. It now:

- lists the other cases (frontend and backend, separately deployed
  services such as each Supabase Edge Function, mobile and native code),
  and that one SDK can also cover several parts;
- leaves the choice to the setup pages the agent reads, with
  https://docs.sentry.io/platforms.md as the index when a search finds
  nothing;
- adds integrations for the libraries the app uses (AI SDKs, Zod, Prisma,
  queues), added only when the docs say they aren't on by default;
- creates one Sentry project per frontend and backend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017M6odVd9nWxcAefpXRLd8M
@betegon
betegon merged commit 2b41243 into main Nov 5, 2026
66 of 70 checks passed
@betegon
betegon deleted the bt/init-agent-guide branch November 5, 2026 20:18
BYK added a commit that referenced this pull request Nov 5, 2026
This finishes the CLI 0.48.0 release. Every publish target shipped, but
Craft couldn't merge the release branch back into `main` ([job
log](https://github.com/getsentry/publish/actions/runs/42102069927/job/127507152523)),
so the post-release bump never ran either.

**Why the merge failed:** `release: 0.48.0` (283b555) changed `version:
0.48.0-dev.0` to `version: 0.48.0` in `references/init.md`. #1856
changed the `description:` line right below it on `main`. The fix in
Craft is getsentry/craft#964.

**This PR**
1. Merges `release/cli/0.48.0` into `main`. That brings in the 0.48.0
`CHANGELOG.md` section and the release versions. For `init.md`, it keeps
the new description from `main` together with `version: 0.48.0`. I
resolved the conflict with the resolver from getsentry/craft#964.
2. Bumps to the next development version the same way Craft's
`postReleaseBump` does: the npm bump plus `versioning.files` from
`.craft.yml`.
- `packages/cli/package.json` and `packages/mcp-server/package.json` →
`0.49.0-dev.0`
   - Skill frontmatter (`SKILL.md`, `references/*.md`) → `0.49.0-dev.0`
   - `.claude-plugin/plugin.json` → `0.49.0` (`stripPrerelease`)

Squash merging is fine: the `cli@0.48.0` tag already points at the
release commit. Once this lands, `release/cli/0.48.0` can be deleted.

#skip-changelog

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A2b52a6f3270e30b7c2e844d3 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A2b52a6f3270e30b7c2e844d3/?project=4510944073809921)

<!-- junior-session-footer:end -->

This branch was previously deployed

1 inactive deployment
Preview — 4ed3cc55 Deployed Nov 5, 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.

3 participants