How a script, hook or CLI can tell it was started by each harness, and which session started it. Children inherit these variables, so treat them as hints that an agent is involved, not as proof that no person is watching.
Detecting the harness
| Question | Claude Codechecked at 2.1.310 |
|---|---|
| The variable to check |
|
| Which processes get it |
|
| Which session started the command |
|
Relying on it
| Question | Claude Codechecked at 2.1.310 |
|---|---|
| Telling the agent's commands from yours | Use |
| Signs that nobody will answer a prompt | Partly Undocumented, but commands get Commands also get |
| Removing or overriding it | Not documented Not documented. The reference describes a scrub that strips credentials from subprocesses, not a way to remove these markers. |
Notes and sources
Claude Code, 3 sources
The variable to check, 3
- Claude Code 2.1.310 Bash tool environment
- Claude Code 2.1.310 child environment in the shipped binary
Which processes get it, 1
Which session started the command, 1
Telling the agent's commands from yours, 1
Signs that nobody will answer a prompt, 3
- Claude Code 2.1.310 Bash tool environment
- Claude Code 2.1.310 child environment in the shipped binary