opencode
opencode copied to clipboard
feat: set AGENT=1 environment variable to identify AI agent execution
Summary
Sets the env var AGENT=1 at startup to identify when processes are run by an AI agent.
Context
Claude Code Implementation
Claude Code sets CLAUDECODE=1 environment variable for similar purposes. This is useful when you want to:
- Block AIs from touching certain sensitive scripts
- Enable stricter pre-commit hooks when code is being modified by AI
- Provide clear identification of AI-driven operations
Bun Test Integration
Bun's test runner already supports AI agent detection through the AGENT=1 environment variable:
- When
AGENT=1is detected, Bun shows concise, AI-friendly test reports - This improves the AI's ability to parse and understand test results
- Documentation: https://bun.com/docs/cli/test#ai-agent-integration