Repository navigation
Description
Question
patchy login prints a URL and a code that the agent relays to a human, then receives a machine token. An agent's shell tool waits for the process to exit, so a login that blocks until the browser confirms never gets its URL in front of anyone. Grilling on Device login: the protocol, and the machine token's columns could not settle the CLI's shape from the ticket alone. Find how CLIs that people drive from agents and headless machines actually do it, from their docs and source, not from memory:
- Blocking or two-step. For each of
gh auth login,vercel login,fly auth login/flyctl,wrangler login,netlify login,supabase login,stripe login,railway login,heroku login,doppler login,turbo login,eas login,claude(Claude Code's own sign-in andclaude setup-token),codex login, and any other CLI with a headless or agent story: does the command block until the browser confirms? Is there a non-interactive,--no-browser,--browserless,--device,--jsonor non-TTY behaviour that returns the handoff and finishes on a later call? Where do the URL and code print (stdout, stderr), and in what shape? - What the URL carries. Does the browser URL carry the user code (RFC 8628
verification_uri_complete), a separate opaque id, or nothing (the person types the code)? Does a bare verification page exist alongside? - Confirm or type. Which of them show the code for confirmation rather than asking the person to type it, and what does the confirm page say (machine name, account, expiry)?
- What the agent-first tools do. Claude Code, Codex CLI, Cursor's CLI, and any tool whose docs address running under an agent or in CI: how a token gets onto a machine nobody is sitting at, and whether they hand out long-lived tokens from a web page.
- Failure copy. What each prints when the code expires or the person denies.
Findings go in this ticket's resolution comment: a table for 1–3 with a source link per row, then the patterns that recur and the one or two shapes worth prototyping. No branch, no file in the tree. Read the docs and the source; say which claims you could not verify.
Activity
allisonmahmood commentedon Sep 3, 2026
Resolution — how agent-driven CLIs hand off a device login
Source and docs for 20 CLIs. Two headlines. Stripe and Netlify already ship what this ticket needs — hand back the URL, exit, finish on a later invocation. And Stripe does not gate on
isatty; it gates on "is an agent driving me", sniffingCLAUDECODE,CLAUDE_CODE_ENTRYPOINT,CURSOR_AGENT,CODEX_*,GEMINI_CLI,OPENCODE,CLINE_ACTIVEand more. Its comment states our problem:1–3. The table
--non-interactive→{browser_url, verification_code, next_step}, exits; device mode persistsdevice_code/interval/expires_into disk,--complete-deviceresumes/stripecli/confirm?…; device path has no…_complete--request <msg> --json→{ticket_id, url, check_command, agent_next_steps};--check <id>→pending/authorized/denied--with-tokenon stdin;GH_TOKENgithub.com/login/device)--tokenrejected onlogin;VERCEL_TOKENverification_uri_complete--browserless; auto-detects$CI/$SSH_CONNECTION/no-DISPLAYverification_uri_completeand bare code below--device(RFC 8628),--browser=false,--callback-host/-port…_complete--manualpastes a token--token, stdin pipe,--no-browser(still needs a TTY)session_id+ ECDHpublic_key+token_name-i+--email/--password/--otpname= hostname)--yesonly; errors on non-TTYsetRawMode, no guard);--ssopastes a token back--no-browserprompts;EXPO_TOKEN/login-p; fallback = page shows a code you paste atPaste code here if promptedCLAUDE_CODE_OAUTH_TOKEN--device-auth;--with-api-key/--with-access-tokenread stdin, refuse a TTY; orssh -L 1455:localhost:1455agent loginNO_OPEN_BROWSER=1prints the URL, still waits;CURSOR_API_KEYfrom the dashboard--no-browsergcloud auth login --remote-bootstrap="…", B runs it, you paste the redirect URL back--jsonemits two blocks:{AuthURL, QR, BackendState:"NeedsLogin"}then{BackendState:"Running"};--auth-key file:…--api-key--use-device-code(az falls back automatically);--device-codeaka.ms/devicelogin,device.sso…,github.com/login/devicePatterns that recur
next_step; Netlify ships the agent's instructions in the payload asagent_next_steps: "Give the URL to the user so they can authorize. Then poll the check_command…". No prose to parse.isattyis the wrong gate — this ticket's exact bug. An agent's shell tool usually has a TTY. Only Stripe gets this right (interactiveHuman = stdinIsTerminal && DetectAIAgent(env) == ""). Turbo, railway, wix and az degrade on non-TTY-ish signals and mostly land well;wrangler loginblocks for 120 s in CI because its guard is on the implicit login path only; heroku crashes.verification_uri_complete; gh, aws, az, codex, doppler, copilot and Stripe's device path do not. Wrangler and Turborepo do both on purpose and cite the spec — wrangler quotes RFC 8628 §3.3.1 verbatim: "Clients MUST still display the user_code, as the authorization server will require the user to confirm it … as remote phishing mitigation." Railway's comment is the agent argument for the same thing: "a single URL survives being relayed through an agent transcript far better than a URL plus a separate code to transcribe."Heroku CLI login from <hostname>, flyos.Hostname(), supabasecli_<user>@<hostname>_<epoch>, StripeSTRIPE_DEVICE_NAME. Supabase's is the one open-source confirm page, and it sends the token name but does not display it: title "Authorize Supabase CLI", subtitle "Enter this verification code in Supabase CLI to finish signing in", an 8-character code in boxed cells with a Copy button, the account's email, a footer pointing at Access Tokens. No scopes, no expiry. That is the whole page (login.tsx) — a useful floor for patchy login end to end: the handoff, the confirm page, the token #131 Q2.device code expired; please run 'stripe login' againin the blocking path,…run 'stripe login --non-interactive' againin the two-step one. AlsoDevice code expired. Please run 'railway login' again./authorization denied by user/Device code expired before the request was approved. Please run 'wrangler login --device' again….On a remote or headless machine? Use 'codex login --device-auth' instead.; fly's non-TTY error isfly auth login requires an interactive terminal. In headless environments, set FLY_API_TOKEN to a token created with 'fly tokens create'.logout/statusbesidelogin.Shapes worth prototyping
A — Stripe's shape (recommended). One command, split by the signal ADR-0004 already has plus agent detection. In a real human TTY
patchy loginblocks and prints the URL and code. Under--json, a non-TTY, or a detected agent, it writes exactly one JSON document to stdout and exits 0:{ "verification_url": "https://…/login/device?code=WXYZ-4RT9", "verification_url_bare": "https://…/login/device", "user_code": "WXYZ-4RT9", "expires_at": "…", "interval": 5, "next": "patchy login --complete WXYZ-4RT9", "agent_next_steps": "Show the URL and code to the person, then run the next command." }patchy login --complete <code>polls and exits0,2(rejected) on deny or expiry,3on unreachable — the exit ladder already covers every terminal state, and #122'sPOST /api/login/device/tokenis already the poll. Stripe persists the pending device code to disk so--completeneeds no argument; worth trying both. This is the only shape here proven to work from inside an agent's shell tool.B — the fallback. One blocking command that prints the handoff to stderr before the poll starts (gh's shape) plus Codex's inline escape-hatch line. Cheaper, but it still depends on the agent's shell tool streaming stderr rather than buffering until exit — the exact failure this ticket opens with. Prototype A; keep B as the comparison in #131 Q1.
Either way: print both the pre-filled URL and the bare code, and keep confirm-not-type on the page.
Could not verify
device_name(docs say only "visible in the Dashboard").claude setup-tokenprints to stdout or stderr — docs say only "prints to the terminal"; not run, since it mints a real one-year credential.