⌨️CLAUDECODE
Also known as CLAUDECODE=1, CLAUDE_CODE_CHILD_SESSION
Set to 1 in each program Claude Code starts, so a script knows.
Think of it like
It is like a name tag that says I came with Claude.
Example
Jack's test script opens a browser, which stalls Claude. The script now skips the browser when this is set.
Why it matters
Some scripts should act a bit differently for an AI than for a person, such as no prompts.
Definition
Example code
bash
if [ -n "$CLAUDECODE" ]; then
echo "Running inside Claude Code"
fiCommon mistake
Key takeaways
- 1Set to 1. By Claude Code.
- 2In what it starts. Bash, hooks, MCP.
- 3For scripts. To detect it.