[DOCS] Document the AI_AGENT environment variable
Status Open
Maintainer reply None cached
Activity 0 comments · opened Oct 2, 2026
Documentation Type
Missing documentation (feature not documented)
Documentation Location
https://code.claude.com/docs/en/env-vars
Section/Topic
AI_AGENT environment variable
What's Wrong or Missing?
Since 2.1.120, Claude Code sets AI_AGENT in subprocesses (e.g. claude-code_2-1-284_agent), but it's only mentioned in the changelog.
It's now the cross-vendor agent marker: VS Code Copilot, pi, OpenCode, and others set it, and tools like gh, Jest, Vitest, and Composer change behavior based on it. Some consumers match the exact value, and the version suffix already breaks them (herdrdev/herdr#4631).
Suggested Improvement
Add an AI_AGENT row next to CLAUDECODE that covers:
- The value format, and which parts are stable
- Which subprocesses receive it (tools, hooks, MCP servers, IDE terminals)
- Whether an
AI_AGENTvalue inherited from an outer agent is kept or overwritten
Previously requested in #53071 (stale-closed). Cross-vendor context: agentsmd/agents.md#136.
Impact
Medium - Makes feature difficult to understand