opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: set AGENT=1 environment variable to identify AI agent execution

Open swen128 opened this issue 5 months ago • 0 comments

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=1 is 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

swen128 avatar Aug 09 '25 10:08 swen128