Laravel's AgentDetector detects whether an AI coding agent is interacting with your app, and PAO optimizes CLI output for agents.
AI coding agents (Cursor, Claude Code, Devin) are now part of regular development workflows. Laravel provides first-party tools to detect agents and optimize terminal output for LLM parsing.
Agent Detection
use Laravel\AgentDetector\Facades\AgentDetector;
$detection = AgentDetector::detect();
if ($detection->isAgent) {
// Inspect agent name (e.g. 'claude-code', 'cursor', 'devin')
logger()->info('AI agent session', ['agent' => $detection->name]);
}
How PAO Works
- First-Party: Ships with PAO (
laravel/pao) included by default in new Laravel applications. - Output Optimization: PAO automatically switches verbose Artisan CLI output into compact JSON when an agent is detected.
- Human Invariant: Human developers see standard terminal formatting with zero workflow change.
Related Tips
View all tips →Squash Legacy Database Migrations Carefully
Use php artisan schema:dump to collapse hundreds of old migration files into a single SQL schema file while preserving new migrations.
Use config() Instead of env() in Application Code
Call env() only inside configuration files and use config() throughout your application code to prevent missing values when configuration is cached.