detect() runs once, reads only the environment and the streams, and returns the reader with the signal that decided it. --verbose prints that signal on stderr.
AI_AGENT set to 0, false, no, off or empty rules an agent out, whatever markers are set: CI, then the TTY, decides. A tool can skip all of this with detection: { agent: true } or false.
Terminal
Section titled "Terminal"A person, with stdout on a TTY. The text format, in color, with prompts and a progress line, and long lists cut at 50 rows. The reason is stdout.isTTY.
Any of 15 CI providers, such as GitHub Actions, GitLab or Vercel, or a bare CI=true. The text format, never a prompt, and every row. On GitHub Actions, the errors and warnings that have a file also go to stderr as annotations, at most 10 of each. The reason names the provider, such as CI:github-actions.
A coding agent's strong marker wins over CI, so an agent running in CI still gets the agent report.
A coding agent, found by AI_AGENT or by a variable its harness sets. The agent format: a verdict first, then the diagnostics, kept under 8000 characters, with a hidden: line naming what was left out and how to see it. No color, prompts or progress. The reason is AI_AGENT, marker:<name> or weak:<name>.
Another program, with stdout not on a TTY and no other signal. The text format without color or prompts, and every row. The reason is stdout not a TTY. A program that parses the output should ask for --format json or --format jsonl.
Agents
Section titled "Agents"A harness names itself with AI_AGENT, and readerly matches the longest known prefix: AI_AGENT=claude-code_2-1_agent is Claude Code 2.1. Without it, a strong marker is set only while the agent runs the command. A weak marker can sit in a person's shell too, so it counts only off a TTY and outside CI. A harness that sets AGENT=<name> is caught the same way.
Claude Code
AI_AGENT=claude-code · strong CLAUDECODECodex
AI_AGENT=codex · strong CODEX_THREAD_ID, CODEX_SANDBOX, CODEX_CICursor
AI_AGENT=cursor · strong CURSOR_AGENT, CURSOR_EXTENSION_HOST_ROLE=agent-exec · weak CURSOR_TRACE_IDOpenCode
AI_AGENT=opencode · strong OPENCODET3 Code
AI_AGENT=t3-code · weak T3CODE_THREAD_IDGemini CLI
AI_AGENT=gemini · strong GEMINI_CLI · from docsCline
AI_AGENT=cline · strong CLINE_ACTIVE · from docsAugment
AI_AGENT=augment · strong AUGMENT_AGENT · from docsAmp
AI_AGENT=amp · strong AMP_CURRENT_THREAD_ID · from docsGitHub Copilot
AI_AGENT=github_copilot · from docsGrok
AI_AGENT=grok · weak GROK_SESSION_ID, GROK_AGENT_ID · from docsKiro
AI_AGENT=kiro · weak TERM_PROGRAM=kiro · from docsGoose
AI_AGENT=goose · weak GOOSE_TERMINAL · from docsReplit
AI_AGENT=replit · weak REPL_ID · from docsWindsurf
AI_AGENT=windsurf · weak WINDSURF_CASCADE_TERMINAL · from docsPi
AI_AGENT=pi · from docs"From docs" means the markers come from the harness's source or docs, not from a run of it. Missing an agent? AI_AGENT=<name> works for any harness, and its name shows in --verbose.