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 | Codex CLIchecked at 0.164.0 | Claude Codechecked at 2.1.310 | Cursor Agentchecked at 2026.10.12-d47ca18 | OpenCodechecked at 2.1.4 | pichecked at 1.4.0 |
|---|---|---|---|---|---|
| The variable to check |
|
|
|
Because an existing | |
| Which processes get it |
| Partly Commands the agent runs with its shell tool. Terminals OpenCode opens get only | |||
| Which session started the command |
Codex says these labels are for correlation, not authorization: shell startup files and child processes can change or remove them. |
| Partly Undocumented, but agent commands in 2026.10.12 get |
|
|
Relying on it
| Question | Codex CLIchecked at 0.164.0 | Claude Codechecked at 2.1.310 | Cursor Agentchecked at 2026.10.12-d47ca18 | OpenCodechecked at 2.1.4 | pichecked at 1.4.0 |
|---|---|---|---|---|---|
| Telling the agent's commands from yours | Partly Use | Use | Not documented Not documented. Cursor doesn't say whether a person's own terminal in the editor also gets | Partly Use | Partly Use |
| Signs that nobody will answer a prompt | Commands the model runs get | Partly Undocumented, but commands get Commands also get | Not documented Not documented. Cursor doesn't say whether agent commands get a dumb terminal, pager overrides or a CI flag. | Partly Agent commands run with standard input closed, so a prompt reads end-of-file. | Not documented Not documented. Pi's environment reference lists no terminal, pager or CI settings for agent commands. |
| Removing or overriding it | Not supported No. | Not documented Not documented. The reference describes a scrub that strips credentials from subprocesses, not a way to remove these markers. | Not documented Not documented. Cursor doesn't say whether | Partly A plugin's | A custom shell tool's |
Notes and sources
Codex CLI, 5 sources
The variable to check, 2
Which session started the command, 2
Telling the agent's commands from yours, 2
Signs that nobody will answer a prompt, 1
Removing or overriding it, 2
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
Removing or overriding it, 1
Cursor Agent, 2 sources
The variable to check, 2
- cursor-agent 2026.10.12 shell tool environment
Which processes get it, 2
- cursor-agent 2026.10.12 shell tool environment
Which session started the command, 2
- cursor-agent 2026.10.12 shell tool environment