laravel/agent-detector
Laravel Agent Detector is a lightweight PHP 8.2+ utility for detecting whether your code runs inside an AI agent or automated development environment, with known-agent checks and a simple standalone detectAgent() helper.
Agent-aware product behavior. Once you can answer "is this code being executed by an AI agent, and which one?", a whole class of product decisions becomes implementable rather than theoretical:
STDIN.isAgent is true. This is a defensible safety story for security reviews and enterprise procurement.Roadmap input. The supported-agent table is a free, continuously updated census of which coding agents developers are actually using. Monitoring its changelog over a few quarters is a cheap signal for "should we be agent-native yet, and for whom?" — Claude, Cursor, Copilot, Codex, Gemini, plus a long tail (Amp, Opencode, Devin, Replit, Kiro, Goose, Cline, Junie, OpenClaw).
Build vs. buy. The detection logic is trivial — a dozen environment-variable checks and one file-existence probe. The non-trivial asset is the maintained fingerprint registry: ~25 agents, community PRs adding new ones within weeks of launch, first-party Laravel namespace. You are buying a maintained taxonomy, not code. That justifies a dependency; it does not justify a build.
Adopt when:
composer require is genuinely zero.Look elsewhere or hold when:
EnvironmentContext::isAgent() interface so swapping it out (or absorbing it into your own code) is a one-file change.Mitigation for the fingerprint risk: pair adoption with the AI_AGENT custom variable, which lets your own agents, internal tooling, and CI self-identify deterministically. That converts a best-effort heuristic into a reliable contract for the traffic you control.
One line: A small first-party Laravel utility that tells our code whether it's being executed by an AI coding agent — and which one — so we can behave correctly when no human is watching.
For executives: Agent-driven development is becoming a normal way our users and our own engineers touch our product, and right now we can't tell it apart from human usage in our metrics or our logs. This package is a low-cost, MIT-licensed, zero-infrastructure way to close that blind spot: it lets us stop agent runs from hanging on prompts, add human-approval gates before destructive actions, and separate agent traffic from human traffic in analytics and quotas. Cost is a Composer dependency and a few conditional branches; risk is contained because it's a heuristic signal we wrap in our own interface and can replace in an afternoon.
For engineering: Adopt laravel/agent-detector behind an internal EnvironmentContext abstraction. Two integration points to start: (1) a global "non-interactive mode" that disables prompts and emits structured output whenever an agent is detected, and (2) an audit tag on log entries and jobs recording agent name. Set AI_AGENT in our own CI and internal agents so our own automation is deterministic rather than dependent on vendor fingerprinting. Explicitly do not use it for authorization — detection is spoofable, so any destructive-action gate must also check real permissions. Budget a small maintenance allowance: the upstream agent list changes monthly, so pin a minor version, review the changelog on upgrade, and keep the adapter under ~50 lines so replacing it — or vendoring the env-var table ourselves — is trivial if the package stalls.
How can I help you explore Laravel packages today?