Feature Request: Add AGENT=claude Environment Variable
Summary
Add a standardized AGENT=claude environment variable to complement the existing CLAUDECODE=1 and CLAUDE_CODE_ENTRYPOINT=cli variables.
Prior Art
Both Goose and Amp have implemented this pattern with AGENT=goose and AGENT=amp respectively. Goose just added this recently: https://github.com/block/goose/pull/7017/
Motivation
Currently, detecting whether any AI agent is running requires checking multiple tool-specific variables:
if [[ $CLAUDECODE != 1 && $GOOSE_TERMINAL != 1 && -z $AGENT ]]; then
# Setup non-agent stuff
fi
With a standardized AGENT variable, this simplifies to:
if [[ -z $AGENT ]]; then
# Setup non-agent stuff
fi
Use Case
Scripts and tools that work with multiple AI coding assistants need a standardized way to detect the execution environment. While CLAUDECODE=1 exists, a generic AGENT=claude variable would:
- Follow emerging standards: Matches the pattern established by other AI coding tools
- Enable better interoperability: Scripts can check
$AGENTto adjust behavior across different AI assistants - Complement existing vars: Works alongside
CLAUDECODEandCLAUDE_CODE_ENTRYPOINTfor more specific detection
Example Usage
# Detect if running under any agent
if [ -n "$AGENT" ]; then
echo "Running under $AGENT"
fi
# Agent-specific behavior
if [ "$AGENT" = "claude" ]; then
# Claude-specific optimizations
fi
Implementation
This would be a simple addition to the environment variables Claude Code sets when spawning processes, similar to how CLAUDECODE=1 is currently set.
Suggested label: enhancement
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗