Skip to content

Feature Request: Add AGENT=claude Environment Variable #24838

Description

@sw-square

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: aaif-goose/goose#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions