Expand description
Detect whether the current process is being invoked by an AI coding agent, and identify which one.
Detection order:
- The proposed standard
AGENTenv var (see agentsmd/agents.md#136). - Tool-specific env vars (
CLAUDECODE,CURSOR_AGENT, …). - Filesystem signals (e.g.
/opt/.devin).
if is_ai_agent::is_ai_agent() {
// emit structured output
}
if let Some(agent) = is_ai_agent::detect() {
eprintln!("running under {}", agent.name);
}Structs§
- Agent
- A detected AI agent and the signal that revealed it.
Enums§
- AgentId
- Canonical identifier for a known agent, or
Unknownwhen an agent is present but its specific identity can’t be determined (e.g.AGENT=1). - Signal
- What signal triggered the detection.
Functions§
- detect
- Detect the AI agent, if any.
- detect_
with - Detection with injectable lookups, useful for tests and for callers that want to consult a captured environment instead of the live process.
- is_
ai_ agent - Returns
trueif any AI agent signal is present.