Skip to content

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

Closed
swen128 wants to merge 1 commit into
anomalyco:devfrom
swen128:feat/add-agent-env-var
Closed

feat: set AGENT=1 environment variable to identify AI agent execution#1749
swen128 wants to merge 1 commit into
anomalyco:devfrom
swen128:feat/add-agent-env-var

Conversation

@swen128

@swen128 swen128 commented Aug 9, 2025

Copy link
Copy Markdown

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:

Sets process.env["AGENT"] = "1" at startup so all child processes can detect
they're being run by an AI agent. This allows scripts and tools to adapt
their behavior accordingly.

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>
@github-actions
github-actions Bot force-pushed the dev branch 3 times, most recently from f1dc981 to 3e15a39 Compare November 22, 2025 18:07
@github-actions
github-actions Bot force-pushed the dev branch 3 times, most recently from f8ee907 to 6a9856d Compare November 27, 2025 01:29
@swen128 swen128 closed this by deleting the head repository Dec 7, 2025
bussard76 pushed a commit to bussard76/openwork that referenced this pull request May 12, 2026
Co-authored-by: src-opn <src-opn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant