is-ai-agent
v0.1.0
Published
Detect if code is running under an AI coding agent
Downloads
32
Maintainers
Readme
is-ai-agent
Detect if your code is running under an AI coding agent.
Install
bun add is-ai-agentUsage
import { isAgent, isClaudeCode, isGeminiCli, isCodex, isOpenCode } from 'is-ai-agent'
// Check which agent (if any)
const agent = isAgent()
// Returns: 'claude' | 'gemini' | 'codex' | 'opencode' | null
if (agent) {
console.log(`Running under ${agent}`)
}
// Or use individual boolean checks
if (isClaudeCode()) {
// Claude Code specific behavior
}Supported Agents
| Agent | Env Var |
|-------|---------|
| Claude Code | CLAUDECODE=1 |
| Gemini CLI | GEMINI_CLI=1 |
| Codex CLI | CODEX_CI=1 |
| OpenCode | OPENCODE=1 |
Contributing
Want to add support for another agent? PRs welcome! Just add an entry to the agents map in index.ts.
License
MIT
