PHPackages                             shipfastlabs/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. shipfastlabs/agent-detector

ActiveLibrary

shipfastlabs/agent-detector
===========================

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

v1.1.0(2mo ago)372.5k↑94.7%34MITPHPPHP ^8.2.0CI passing

Since Feb 8Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/shipfastlabs/agent-detector)[ Packagist](https://packagist.org/packages/shipfastlabs/agent-detector)[ GitHub Sponsors](https://github.com/pushpak1300)[ RSS](/packages/shipfastlabs-agent-detector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (13)Versions (6)Used By (4)

 [![Agent Detector](docs/og.png)](docs/og.png)

 [![GitHub Workflow Status (master)](https://github.com/shipfastlabs/agent-detector/actions/workflows/tests.yml/badge.svg)](https://github.com/shipfastlabs/agent-detector/actions) [![Total Downloads](https://camo.githubusercontent.com/e49333941a66e59057887dae3c698680715abb31fa9ea3c8126d8c574a5288b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73686970666173746c6162732f6167656e742d6465746563746f72)](https://packagist.org/packages/shipfastlabs/agent-detector) [![Latest Version](https://camo.githubusercontent.com/ccf586ebb49f2273e20373983d3278060fc70f5fb2012a6d2d0dffd6fa5c9975/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73686970666173746c6162732f6167656e742d6465746563746f72)](https://packagist.org/packages/shipfastlabs/agent-detector) [![License](https://camo.githubusercontent.com/bf68efa8d0aff32640c80a7440019387e6d07b8979f3a095e9e6d32b60ee5101/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73686970666173746c6162732f6167656e742d6465746563746f72)](https://packagist.org/packages/shipfastlabs/agent-detector)

---

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)

```
composer require shipfastlabs/agent-detector
```

Usage
-----

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

[](#supported-agents)

AgentDetection MethodCustom`AI_AGENT` env varCursor`CURSOR_AGENT` env varGemini`GEMINI_CLI` env varCodex`CODEX_SANDBOX` 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 varReplit`REPL_ID` env varDevin`/opt/.devin` file exists### 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
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details on how to contribute, including adding support for new agents.

Testing
-------

[](#testing)

```
composer test
```

**Agent Detector** was created by **[Pushpak Chhajed](https://github.com/pushpak1300)** under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance86

Actively maintained with recent releases

Popularity34

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.2% of commits — single point of failure

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 ~10 days

Total

4

Last Release

68d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31663512?v=4)[Pushpak Chhajed](/maintainers/pushpak1300)[@pushpak1300](https://github.com/pushpak1300)

---

Top Contributors

[![pushpak1300](https://avatars.githubusercontent.com/u/31663512?v=4)](https://github.com/pushpak1300 "pushpak1300 (15 commits)")[![joetannenbaum](https://avatars.githubusercontent.com/u/2702148?v=4)](https://github.com/joetannenbaum "joetannenbaum (1 commits)")[![mateusjatenee](https://avatars.githubusercontent.com/u/10816999?v=4)](https://github.com/mateusjatenee "mateusjatenee (1 commits)")

---

Tags

phpautomationaiAgentdetectioncursorclaudedevin

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[llm-agents/agents

LLM Agents PHP SDK - Autonomous Language Model Agents for PHP

16410.9k9](/packages/llm-agents-agents)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)[cboxdk/statamic-mcp

MCP (Model Context Protocol) server for Statamic CMS v6 — gives AI assistants structured access to content, blueprints, assets, and more.

225.6k](/packages/cboxdk-statamic-mcp)

PHPackages © 2026

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