Feature Request: Add AGENT=claude Environment Variable

Resolved 💬 3 comments Opened Feb 10, 2026 by sw-square Closed Mar 30, 2026

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:

  1. Follow emerging standards: Matches the pattern established by other AI coding tools
  2. Enable better interoperability: Scripts can check $AGENT to adjust behavior across different AI assistants
  3. Complement existing vars: Works alongside CLAUDECODE and CLAUDE_CODE_ENTRYPOINT for 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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗