GitHub
Skip to content

Coding agents

What a coding agent gets from a readerly command, which harnesses readerly knows by their env vars, and how a tool declares itself with AI_AGENT.

When the reader is a coding agent, readerly prints the agent format. This page covers what that output holds and how readerly knows which agent is running.

The acme check example from test/golden, as a coding agent gets it:

acme check: failed. 2 errors, 1 warning in 212 files (0.8s).
error ACME001 src/app.ts:14:3 Route handler reads process.env at module scope. fix: Read it inside the handler
error ACME004 src/db.ts:3:1 Top-level await in a server entry. fix: Move the call into the plugin setup
warn ACME010 vite.config.ts:8:5 Alias shadows a workspace package
next: acme check --fix   (applies 2 safe fixes)
next: acme explain <code>   (explains one code)
text
  • No color and no glyphs. No escape codes, no โœ–, no tree. Each diagnostic is one line, with its fix on the same line. why and docs appear only with --full.
  • The verdict on line 1. Hosts cut the middle of long output, so the first line says whether the run failed and what it counted.
  • No prompts. An agent can't answer one. When a prompt has a default, readerly uses it and adds a next: line with the flag that changes it, here acme check --fix. When it has none, out.confirm throws an action_required failure that names the flag, and out.fail() prints it with exit code 2. See Prompts and input.
  • A budget of 8,000 characters. That is under Claude Code's 30,000-character Bash output limit and Codex's 10,000-token cap. readerly keeps or drops whole lines: next: lines first, then errors, warnings, infos and logs. The last line names what it dropped and how to get it back:
hidden: 23 warn. rerun: acme check --full, or acme check --format json
text

--max-chars <n> sets another budget and --full removes it. Budget has the details.

Failures go to stdout in this format too, so an agent sees the error, the fix and the command to rerun in one read.

The harness registry in src/registry.ts lists each agent readerly knows. A bare marker name counts when the variable is set and not 0, false, no, off or empty; NAME=value must match exactly.

idStrong markersWeak markerssessionId fromAlso reads
claude-codeCLAUDECODECLAUDE_CODE_SESSION_IDCLAUDE_EFFORT as effort
codexCODEX_THREAD_ID, CODEX_SANDBOX, CODEX_CICODEX_THREAD_IDCODEX_VERSION as version
gemini*GEMINI_CLI
cline*CLINE_ACTIVE
opencodeOPENCODEOPENCODE_SESSION_ID
cursorCURSOR_AGENT, CURSOR_EXTENSION_HOST_ROLE=agent-execCURSOR_TRACE_IDCURSOR_CONVERSATION_ID
augment*AUGMENT_AGENT
amp*AMP_CURRENT_THREAD_IDAMP_CURRENT_THREAD_ID
copilot*
grok*GROK_SESSION_ID, GROK_AGENT_IDGROK_SESSION_ID
kiro*TERM_PROGRAM=kiro
goose*GOOSE_TERMINAL
replit*REPL_ID
windsurf*WINDSURF_CASCADE_TERMINAL
pi*
t3-codeT3CODE_THREAD_IDT3CODE_THREAD_ID

* Markers taken from the harness's source or docs, not from a live run.

copilot and pi have no marker. readerly finds them only through AI_AGENT, such as AI_AGENT=github_copilot_vscode_agent. A bare AGENT variable is one more weak marker for any harness: AGENT=goose reports goose, and AGENT=1 reports unknown.

When T3CODE_THREAD_ID is set and the agent is not T3 Code itself, AgentInfo.wrapper is { id: "t3-code", threadId }: a Claude Code run inside T3 Code reports both.

AgentInfo.strength says how readerly found the agent.

strengthSourceTrusted
declaredAI_AGENTAlways. It is checked before any marker.
strongA variable the harness sets only while a model runs the commandAlways, also in a TTY and in CI
weakA variable that can also sit in a person's shellOnly when stdout is not a TTY and the run is not in CI

The full order is in Readers.

A harness, or a wrapper script around one, declares itself by setting AI_AGENT. readerly reads the value like this:

  1. A value that doesn't match ^[A-Za-z0-9_.-]{1,64}$ gives the id unknown.
  2. readerly lowercases it and splits it on _. A last segment of agent or harness becomes mode.
  3. A version segment of digits joined by - or . becomes version, with - turned into ..
  4. The id is the longest registry prefix followed by _, - or the end of the value. Otherwise it is the rest of the value; 1, true, yes and on give unknown.
AI_AGENTidversionmode
claude-code_2-1-332_agentclaude-code2.1.332agent
codexcodex
opencode_1.4.2opencode1.4.2
github_copilot_vscode_agentcopilotagent
new-tool_3-0_agentnew-tool3.0agent
1unknown

AgentInfo.raw keeps the value as given. AI_AGENT=0 declares that no agent runs; see Readers.

A coding agent can run inside a CI job, such as Claude Code in GitHub Actions. A declared or strong agent wins over CI: the reader is agent, and Detection.ci still names the provider. A weak marker never wins in CI, so CURSOR_TRACE_ID in a GitHub Actions job leaves the reader ci.

An agent in CI gets the agent format and no GitHub annotations. Annotations go only with the text format, for the ci reader on GitHub Actions. See GitHub Actions.