Weave Code
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 8.2+ utility to detect if your app is running inside an AI agent or automated dev environment. Supports Claude, Cursor, Gemini, Codex, Replit, Devin, and more via env vars or file checks, with a simple API and helper function.

View on GitHub
Deep Wiki
Context7

A lightweight PHP utility to detect if your code is running inside an AI agent or automated development environment.

Requires PHP 8.2+

Installation

composer require shipfastlabs/agent-detector

Usage

use AgentDetector\AgentDetector;

$result = AgentDetector::detect();

if ($result->isAgent) {
    echo "Running inside: {$result->name}";
}

// Check for a specific known agent
if ($result->knownAgent() === \AgentDetector\KnownAgent::Claude) {
    echo "Hello from Claude!";
}

Or use the standalone function:

use function AgentDetector\detectAgent;

$result = detectAgent();

Supported Agents

Agent Detection Method
Custom AI_AGENT env var
Cursor CURSOR_AGENT env var
Gemini GEMINI_CLI env var
Codex CODEX_SANDBOX or CODEX_THREAD_ID env var
Augment CLI AUGMENT_AGENT env var
AMP AMP_CURRENT_THREAD_ID env var
Opencode OPENCODE_CLIENT or OPENCODE env var
Claude CLAUDECODE or CLAUDE_CODE env var
Replit REPL_ID env var
Devin /opt/.devin file exists

Custom Agent

Set the AI_AGENT environment variable to any value to identify your custom agent:

AI_AGENT=my-custom-agent php your-script.php

Contributing

Please see CONTRIBUTING for details on how to contribute, including adding support for new agents.

Testing

composer test

Agent Detector was created by Pushpak Chhajed under the MIT license.

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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests