Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Agent Detector Laravel Package

shipfastlabs/agent-detector

Lightweight PHP utility that detects whether your code is running inside an AI agent or automated dev environment. Identify Claude, Cursor, Gemini, Codex and more via env vars or a standalone detectAgent() helper.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • AI/Automation-Aware Feature Flags: Enable/disable features (e.g., rate limits, experimental APIs) when running in AI environments (e.g., Copilot, Claude, Cline, Goose, Windsurf, Zed Agent) to prevent misuse or unintended behavior.
  • Dynamic Content Personalization: Serve AI-generated vs. human-optimized content (e.g., tutorials, docs) based on the detected agent — now including Grok, Kimi, Junie, Qwen Code, Crush, and Jules.
  • Security & Compliance: Block or log AI agent interactions for sensitive operations (e.g., admin panels, payment flows) to mitigate automation risks across a wider set of agents — including cloud agents like Copilot cloud agent and Jules, which operate without a local env var you control.
  • Developer Tooling: Integrate with IDEs and CLI tools (e.g., Replit, Windsurf, Zed Agent, Kiro IDE, Cline, Goose, OpenClaw) to provide agent-specific hints, debugging, or optimizations (e.g., "This code was generated by Claude—review for edge cases").
  • Cost Optimization: Route AI-generated requests to cheaper endpoints or mock services during development, with broader agent coverage (including Qwen Code and Crush) enabling more accurate routing.
  • Roadmap Prioritization: Justify investment in AI tooling (e.g., Copilot plugins) by quantifying adoption via detection metrics across an expanded agent set — now spanning local CLIs, IDE agents, and cloud-hosted agents.
  • Build vs. Buy: Replace custom agent-detection scripts with a maintained, Laravel-ecosystem package to reduce tech debt — now with coverage for nearly 30 agents across IDE, CLI, and cloud categories.

When to Consider This Package

Adopt if:

  • Your PHP/Laravel app interacts with AI agents, CLI tools, IDE agents, or automated environments (e.g., Copilot, Copilot cloud agent, Replit, Codex, Cline, Goose, Windsurf, Zed Agent, Kiro IDE, Grok, Kimi, Junie, Qwen Code, Crush, ZCode, Jules, OpenClaw) and needs to differentiate behavior.
  • You require lightweight, environment-variable-based detection (no browser fingerprinting or heavy parsing).
  • Your team uses multiple AI tools (e.g., Claude, Gemini, v0, Cline, Grok, Qwen Code) and needs consistent identification across IDE and CLI surfaces.
  • You’re building developer tools, IDE plugins, or CI/CD integrations where agent context matters.
  • You want to future-proof for emerging agents (e.g., custom AI_AGENT support, plus newly added agents like ZCode, Qwen Code, Crush, Windsurf, Zed Agent, Kiro IDE, Copilot cloud agent, and Jules).

Look elsewhere if:

  • You need browser-based agent detection (e.g., for web apps; use User-Agent parsers like Mobile Detect).
  • Your use case requires deep behavioral analysis (e.g., mouse movements, typing patterns) beyond env vars.
  • You’re constrained to PHP < 8.2 (package requires PHP 8.2+).
  • You prefer vendor-locked solutions (e.g., GitHub Copilot’s native APIs) over open-source tools.
  • You need cloud-agent attestation — detection still relies on env vars the agent must set, so cloud agents you don't control may not surface reliably.

How to Pitch It (Stakeholders)

For Executives: *"This package lets us automatically detect AI agents (like GitHub Copilot, Claude, Replit, Cline, Goose, Windsurf, Zed Agent, Grok, Kimi, Qwen Code, Jules, and more) in our Laravel apps using simple environment variables. We can use this to:

  • Protect sensitive features from automated misuse (e.g., block AI-generated admin actions).
  • Personalize developer experiences (e.g., serve AI-optimized docs or hints).
  • Reduce costs by routing AI traffic to mock services during testing.
  • Stay ahead as AI tooling evolves—it’s maintained by Laravel’s team and now supports nearly 30 agents across IDEs, CLIs, and cloud tools. No code changes needed for basic detection; integrates in minutes. Governance is streamlined too—the package now inherits the Laravel org-wide security policy. ROI: Immediate security/compliance wins + long-term flexibility for AI integrations."

For Engineers: *"This is a zero-dependency, PHP 8.2+ library to detect AI agents via env vars (e.g., COPILOT_MODEL, CLAUDE_CODE). Key perks:

  • Plug-and-play: One-liner to check AgentDetector::detect()->isAgent.
  • Extensible: Add custom agents via AI_AGENT env var or extend the KnownAgent enum.
  • Lightweight: No external APIs or heavy parsing—just env var checks.
  • Laravel-native: Uses the same namespace/style as other Laravel packages. New in v2.0.5: Detection for ZCode, Qwen Code, Crush, Windsurf, Zed Agent, Kiro IDE, Copilot cloud agent, and Jules — plus the security policy now defers to the org-wide default (one fewer file to maintain). Use cases: Feature gating, logging, or tooling that needs to know if code is AI-generated. Example:
if (AgentDetector::detect()->knownAgent() === KnownAgent::Claude) {
    // Enable Claude-specific optimizations
}
```*
*Alternatives*: Rolling your own env var checks or using heavier libraries like `browser-detect` (overkill for this use case)."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk