| name | debug-using-debugbar |
| description | Use this skill to optimize requests or debug Laravel application issues — slow pages, N+1 queries, exceptions, failed requests, or unexpected behavior — by inspecting data captured by Laravel Debugbar via Artisan CLI commands. Use when the user asks to investigate a bug, diagnose a slow request, find duplicate queries, check what happened on a previous request, or optimize database performance, even if they don't explicitly mention "debugbar" or "profiling."
|
| compatibility | Requires Laravel with fruitcake/laravel-debugbar installed and debug mode enabled. |
Debugging and optimizing workflow
- Find the relevant request:
php artisan debugbar:find --issues --max=50
- Inspect the request summary to identify which collectors have data:
php artisan debugbar:get {id}
- Drill into the relevant collector based on the issue type:
php artisan debugbar:get {id} --collector=exceptions
- For query issues, use dedicated query analysis:
php artisan debugbar:queries {id}
- Trace the problem to source code using backtraces, then fix and re-test.
Finding requests
php artisan debugbar:find
php artisan debugbar:find --uri="/api/*" --method=POST
php artisan debugbar:find --issues --max=50
php artisan debugbar:find --issues --min-queries=10 --min-duration=500
php artisan debugbar:find --min-queries=20
--issues flags: exceptions, non-2xx status, high query count, slow queries, duplicate query groups, slow request duration, and failed queries. Issue filtering applies on top of the fetched result set — increase --max to scan further back.
Inspecting a request
php artisan debugbar:get latest
php artisan debugbar:get {id}
php artisan debugbar:get {id} --collector=exceptions
Pick the collector by issue type:
- Error/500 →
exceptions · Slow page → queries, time · Auth → auth, gate · Cache → cache
Analyzing queries
php artisan debugbar:queries {id}
php artisan debugbar:queries {id} --statement=N
php artisan debugbar:queries {id} --statement=N --explain
php artisan debugbar:queries {id} --statement=N --result
Duplicate queries are a strong N+1 signal. Use --statement=N to get the backtrace and find the origin.
Gotchas
- Always start with
debugbar:find --issues rather than debugbar:find — the issue flags surface the most actionable requests immediately.
- The
{id} is the request ID from the debugbar:find output, or use latest to inspect the most recent request.
- Collector availability depends on the app's debugbar config — the summary from
debugbar:get shows which collectors have data.
--explain and --result only work on SELECT queries. They re-execute against the current database, so results may differ from the original request.
debugbar:clear removes all stored data — use it to reset between debugging sessions, not mid-investigation.