cyberneticlibrary

Detect if code runs in an AI agent

detect-agentskillsetup L10
vercel/vercel
What it does

Detect AI agent runtime environment

Best for

Adapt behavior when code runs in Claude Code, Cursor, or other AI-driven editors

Inputs
  • · process environment variables
  • · AI_AGENT env var
Outputs
  • · {isAgent: bool, agent: {name: string}}
Preconditions

Node.js environment with npm

Failure modes
  • · Unknown agent type returns isAgent=false
Trust signals
  • · Vercel-published npm package
  • · Detects 9+ agent types
  • · AI_AGENT standard proposed