Overview
The@bunli/plugin-ai-detect plugin detects AI coding assistants by checking environment variables. This is useful for:
- Adjusting CLI output for AI agents
- Enabling machine-readable formats automatically
- Tracking AI usage in telemetry
- Customizing behavior based on the execution context
Installation
Usage
Detected Agents
The plugin detects the following AI coding assistants:| Agent | Environment Variables |
|---|---|
| Claude | CLAUDECODE, CLAUDE_CODE |
| Cursor | CURSOR_AGENT |
| Codex | CODEX_CI, CODEX_THREAD_ID, CODEX_SANDBOX |
| Amp | AMP_CURRENT_THREAD_ID, AGENT=amp |
| Gemini | GEMINI_CLI |
| OpenCode | OPENCODE=1 |
Options
Custom Agents
Add detection for custom AI agents:Environment Info Extension
The plugin extends Bunli’s environment info:Extended Interface
Plugin Store
The plugin maintains a typed store:Real-World Examples
Adjust Output Format
Telemetry Tracking
Disable Prompts
Verbose Logging
Source Code
Full plugin implementation:packages/plugin-ai-detect/src/index.ts
Next Steps
Shell Completions
Generate shell completion scripts
Config Plugin
Load configuration from files
Creating Plugins
Build your own plugins
Plugin Hooks
Learn about lifecycle hooks