packages/agent-info/README.md
Detects whether the current process was invoked by an AI coding agent, and which one.
Agents make themselves known through environment variables — CLAUDECODE, GEMINI_CLI,
CURSOR_AGENT, and so on. This package fingerprints the environment against a table of
those markers and reports a single name drawn from a closed set, so callers get a value
they can safely record rather than an arbitrary string from the environment.
It is pure, dependency-free TypeScript. It reads nothing but the environment object it is given, touches no filesystem or network, and has no runtime dependencies.
import { detectAgent } from '@packages/agent-info'
detectAgent() // 'claude' when run under Claude Code
detectAgent({ GEMINI_CLI: '1' }) // 'gemini'
detectAgent({}) // undefined
Parameters
env: NodeJS.ProcessEnv — the environment to inspect. Defaults to process.env.Returns the detected AgentName, or undefined when no agent is indicated.
import { isAgent } from '@packages/agent-info'
if (isAgent()) {
// running under some agent, named or not
}
Parameters
env: NodeJS.ProcessEnv — the environment to inspect. Defaults to process.env.Returns true when any agent is detected.
The closed set of names detectAgent can return:
auggie, claude, codex, cursor, devin, gemini, goose, junie, kiro,
opencode, pi, replit, other.
other is reported when the generic AI_AGENT variable is set to something the table
does not recognize — an agent is present, but not one this package can name.
cursor.AI_AGENT often carries a version
(Claude Code sets claude-code_2-1-221_agent); it is reduced to a known name or
other, so no unvetted environment string reaches a caller.This package is part of the Cypress project and is licensed under the MIT License.