Skip to main content

Module agent

Module agent 

Source
Expand description

AI coding agent detection for agent-specific profiles.

This module detects which AI coding agent is invoking dcg, enabling per-agent trust levels and configuration overrides.

§Detection Methods

  1. Environment variables (primary): Most agents set identifying env vars
  2. Explicit flag: --agent=<name> CLI flag for manual override
  3. Parent process inspection (fallback): Check process tree for agent names

§Supported Agents

  • Claude Code: CLAUDE_CODE=1 or CLAUDE_SESSION_ID env var
  • Augment Code: AUGMENT_AGENT=1 or AUGMENT_CONVERSATION_ID env var
  • Aider: AIDER_SESSION=1 env var
  • Continue: CONTINUE_SESSION_ID env var
  • Codex CLI: CODEX_CLI=1 env var
  • Gemini CLI: GEMINI_CLI=1 env var
  • Copilot CLI: COPILOT_CLI=1 or COPILOT_AGENT_START_TIME_SEC env var

§Usage

use destructive_command_guard::agent::{Agent, detect_agent};

let agent = detect_agent();
println!("Detected agent: {}", agent);

Structs§

DetectionResult
Result of agent detection with metadata.

Enums§

Agent
Known AI coding agents that dcg can detect and configure per-agent policies for.
DetectionMethod
How an agent was detected.

Functions§

clear_cache
Clear the agent detection cache.
detect_agent
Detect the current AI coding agent, using cache if available.
detect_agent_with_details
Detect the current AI coding agent with full details.
from_explicit
Create a detection result from an explicit agent name.