Skip to main content

Crate is_ai_agent

Crate is_ai_agent 

Source
Expand description

Detect whether the current process is being invoked by an AI coding agent, and identify which one.

Detection order:

  1. The proposed standard AGENT env var (see agentsmd/agents.md#136).
  2. Tool-specific env vars (CLAUDECODE, CURSOR_AGENT, …).
  3. 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 Unknown when 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 true if any AI agent signal is present.