PHPackages                             laravel/agent-detector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. laravel/agent-detector

ActiveLibrary[Framework](/categories/framework)

laravel/agent-detector
======================

Detect if code is running in an AI agent or automated development environment

v2.0.2(1mo ago)741.5M↓13.8%118MITPHPPHP ^8.2.0CI passing

Since Feb 8Pushed 5d ago1 watchersCompare

[ Source](https://github.com/laravel/agent-detector)[ Packagist](https://packagist.org/packages/laravel/agent-detector)[ Docs](https://github.com/laravel/agent-detector)[ RSS](/packages/laravel-agent-detector/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (6)Versions (15)Used By (8)

Laravel Agent Detector
======================

[](#laravel-agent-detector)

 [![GitHub Workflow Status (main)](https://github.com/laravel/agent-detector/actions/workflows/tests.yml/badge.svg)](https://github.com/laravel/agent-detector/actions) [![Total Downloads](https://camo.githubusercontent.com/dbf28574fe64b8bee2b4d6ee042ed0aeb140c9db714c0c7d16af9e7e589a3e19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2f6167656e742d6465746563746f72)](https://packagist.org/packages/laravel/agent-detector) [![Latest Version](https://camo.githubusercontent.com/fc3f2062e12943d2c6db38faa697e1ee85ec0ee8ed12ae541308e5a4f2aabfba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2f6167656e742d6465746563746f72)](https://packagist.org/packages/laravel/agent-detector) [![License](https://camo.githubusercontent.com/d23737d167a1796e882c1551f74e1d8c8cbc0b80c00754fe2cda2dd2636d5eb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c61726176656c2f6167656e742d6465746563746f72)](https://packagist.org/packages/laravel/agent-detector)

Introduction
------------

[](#introduction)

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

> **Requires [PHP 8.2+](https://php.net/releases/)**

Installation
------------

[](#installation)

To get started, install Agent Detector via the Composer package manager:

```
composer require laravel/agent-detector
```

Usage
-----

[](#usage)

```
use Laravel\AgentDetector\AgentDetector;
use Laravel\AgentDetector\KnownAgent;

$result = AgentDetector::detect();

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

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

Or use the standalone function:

```
use function Laravel\AgentDetector\detectAgent;

$result = detectAgent();
```

Supported Agents
----------------

[](#supported-agents)

AgentDetection MethodCustom`AI_AGENT` env varCursor`CURSOR_AGENT` env varGemini`GEMINI_CLI` env varCodex`CODEX_SANDBOX`, `CODEX_CI`, or `CODEX_THREAD_ID` env varAugment CLI`AUGMENT_AGENT` env varAMP`AMP_CURRENT_THREAD_ID` env varOpencode`OPENCODE_CLIENT` or `OPENCODE` env varClaude`CLAUDECODE` or `CLAUDE_CODE` env varCowork`CLAUDE_CODE_IS_COWORK` with `CLAUDECODE` or `CLAUDE_CODE` env varCopilot`AI_AGENT=github-copilot`, `AI_AGENT=github-copilot-cli`, `COPILOT_MODEL`, `COPILOT_ALLOW_ALL`, `COPILOT_GITHUB_TOKEN`, or `COPILOT_CLI` env varReplit`REPL_ID` env varDevin`/opt/.devin` file existsAntigravity`ANTIGRAVITY_AGENT` env varPi`PI_CODING_AGENT` env varKiro CLI`KIRO_AGENT_PATH` env varv0`AI_AGENT=v0` env var### Custom Agent

[](#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
```

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Thank you for considering contributing to Agent Detector! You can read the contribution guide [here](.github/CONTRIBUTING.md).

Code of Conduct
---------------

[](#code-of-conduct)

In order to ensure that the Agent Detector community is welcoming to all, please review and abide by the [Code of Conduct](.github/CODE_OF_CONDUCT.md).

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](.github/SECURITY.md) on how to report security vulnerabilities.

License
-------

[](#license)

Agent Detector is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance96

Actively maintained with recent releases

Popularity57

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Total

11

Last Release

41d ago

Major Versions

v1.1.4 → v2.0.02026-04-27

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/463230?v=4)[Taylor Otwell](/maintainers/taylorotwell)[@taylorotwell](https://github.com/taylorotwell)

---

Top Contributors

[![pushpak1300](https://avatars.githubusercontent.com/u/31663512?v=4)](https://github.com/pushpak1300 "pushpak1300 (22 commits)")[![joetannenbaum](https://avatars.githubusercontent.com/u/2702148?v=4)](https://github.com/joetannenbaum "joetannenbaum (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![nunomaduro](https://avatars.githubusercontent.com/u/5457236?v=4)](https://github.com/nunomaduro "nunomaduro (2 commits)")[![jackbayliss](https://avatars.githubusercontent.com/u/13621738?v=4)](https://github.com/jackbayliss "jackbayliss (1 commits)")[![mateusjatenee](https://avatars.githubusercontent.com/u/10816999?v=4)](https://github.com/mateusjatenee "mateusjatenee (1 commits)")[![chris-ware](https://avatars.githubusercontent.com/u/19684457?v=4)](https://github.com/chris-ware "chris-ware (1 commits)")[![ssnepenthe](https://avatars.githubusercontent.com/u/10903810?v=4)](https://github.com/ssnepenthe "ssnepenthe (1 commits)")[![clesecq](https://avatars.githubusercontent.com/u/22601105?v=4)](https://github.com/clesecq "clesecq (1 commits)")[![cosmastech](https://avatars.githubusercontent.com/u/42181698?v=4)](https://github.com/cosmastech "cosmastech (1 commits)")[![FlorianHyver](https://avatars.githubusercontent.com/u/47179554?v=4)](https://github.com/FlorianHyver "FlorianHyver (1 commits)")

---

Tags

phpautomationaiAgentdetectioncursorclaudedevin

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/laravel-agent-detector/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-agent-detector/health.svg)](https://phpackages.com/packages/laravel-agent-detector)
```

###  Alternatives

[laravel/pao

Agent-optimized output for PHP testing tools

6351.4M81](/packages/laravel-pao)[mohamed-ashraf-elsaed/claude-agent-sdk-laravel

Anthropic Claude Agent SDK for PHP &amp; Laravel — build AI agents with tool use, sandboxing, MCP servers, subagents, hooks, and structured output via the Claude Code CLI

151.1k](/packages/mohamed-ashraf-elsaed-claude-agent-sdk-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
