Skip to content

feat: add global --agent flag with auto-detection for AI coding agents#4960

Merged
avallete merged 1 commit intodevelopfrom
feat/agent-detection
Mar 17, 2026
Merged

feat: add global --agent flag with auto-detection for AI coding agents#4960
avallete merged 1 commit intodevelopfrom
feat/agent-detection

Conversation

@Rodriguespn
Copy link
Contributor

Summary

  • Adds a global --agent flag (auto/yes/no, default auto) that detects whether the CLI is being invoked by an AI coding agent
  • Auto-detection checks environment variables set by known agents (Claude Code, Cursor, Copilot, Gemini, Codex, Devin, Replit, Augment, OpenCode, Antigravity) following the same approach as Vercel's detect-agent package
  • When agent mode is active, db query defaults to JSON output wrapped in a security envelope (untrusted data boundary). When in human mode, defaults to table output with no envelope
  • Explicit --output flag always takes precedence over the auto-detected default
  • The agent detection lives in its own package (internal/utils/agent) so it can be reused by other commands in the future

cc: @mattrossman @gregnr

Introduces a global --agent flag (auto/yes/no) that detects whether the
CLI is being invoked by an AI coding agent based on environment variables.
When agent mode is active, db query defaults to JSON output with a
security envelope (untrusted data boundary). When in human mode, it
defaults to table output without the envelope. Explicit --output always
takes precedence.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@Rodriguespn Rodriguespn requested a review from avallete March 16, 2026 17:45
@Rodriguespn Rodriguespn self-assigned this Mar 16, 2026
@coveralls
Copy link

Pull Request Test Coverage Report for Build 23157830869

Details

  • 56 of 80 (70.0%) changed or added relevant lines in 5 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 61.869%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/root.go 0 1 0.0%
internal/db/query/query.go 20 22 90.91%
internal/utils/agent/agent.go 36 38 94.74%
internal/utils/agent.go 0 8 0.0%
cmd/db.go 0 11 0.0%
Files with Coverage Reduction New Missed Lines %
internal/utils/git.go 5 57.14%
Totals Coverage Status
Change from base Build 23149550253: -0.01%
Covered Lines: 7913
Relevant Lines: 12790

💛 - Coveralls

@Rodriguespn Rodriguespn marked this pull request as ready for review March 16, 2026 17:59
@Rodriguespn Rodriguespn requested a review from a team as a code owner March 16, 2026 17:59
@avallete avallete merged commit 0351926 into develop Mar 17, 2026
15 checks passed
@avallete avallete deleted the feat/agent-detection branch March 17, 2026 09:27
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.

3 participants