Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .cursor/skills/debug-using-debugbar/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
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

1. Find the relevant request:
```bash
php artisan debugbar:find --issues --max=50
```
2. Inspect the request summary to identify which collectors have data:
```bash
php artisan debugbar:get {id}
```
3. Drill into the relevant collector based on the issue type:
```bash
php artisan debugbar:get {id} --collector=exceptions
```
4. For query issues, use dedicated query analysis:
```bash
php artisan debugbar:queries {id}
```
5. Trace the problem to source code using backtraces, then fix and re-test.

## Finding requests

```bash

# List recent requests (shows summary with status, duration, memory, query count)

php artisan debugbar:find

# Filter by URI pattern (fnmatch) and/or HTTP method

php artisan debugbar:find --uri="/api/*" --method=POST

# Only show requests with issues (exceptions, slow queries, duplicates, errors)

php artisan debugbar:find --issues --max=50

# Customize issue thresholds (defaults: --min-queries=50, --min-duration=1000, --min-duplicates=2)

php artisan debugbar:find --issues --min-queries=10 --min-duration=500

# Threshold options also work standalone, filtering on just that criteria

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

```bash

# Summary of all collectors (available collectors depend on config)

php artisan debugbar:get latest
php artisan debugbar:get {id}

# Full data for a specific collector

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

```bash

# Overview with duplicate detection and slow query flags

php artisan debugbar:queries {id}

# Backtrace and params for a specific statement

php artisan debugbar:queries {id} --statement=N

# EXPLAIN plan or re-execute a SELECT

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.
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@ Always use a sub-agent to read rule files and explore this skill's content.

1. Identify the file type and select relevant sections (e.g., migration → §16, controller → §1, §3, §5, §6, §10)
2. Check sibling files for existing patterns — follow those first per Consistency First
3. Verify API syntax with `search-docs` for the installed Laravel version
3. Verify API syntax with `search-docs` for the installed Laravel version
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ public function scopeOrderByLastLogin($query): void
->take(1)
);
}
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ class Customer extends Model
return $this->belongsToMany(Role::class);
}
}
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/blade-views.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ return view('dashboard', compact('users'))

## Use `@aware` for Deeply Nested Component Props

Avoids re-passing parent props through every level of nested components.
Avoids re-passing parent props through every level of nested components.
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ If Redis goes down, the app falls back to a secondary store automatically.

```php
'failover' => ['driver' => 'failover', 'stores' => ['redis', 'database']],
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ More declarative than overriding `newCollection()`.
```php
#[CollectedBy(UserCollection::class)]
class User extends Model {}
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ If the application already uses language files for localization, use `__()` for
```php
// Only when lang files already exist in the project
return back()->with('message', __('app.article_added'));
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@ return view('users.index', compact('users'));
@foreach ($users as $user)
{{ $user->profile->name }}
@endforeach
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@ Order::where('status', 'pending')->get();

Prefer Eloquent queries and relationships over `DB::table()` whenever possible — they already reference the model's table. When `DB::table()` or raw joins are unavoidable, always use `(new Model)->getTable()` to keep the reference traceable.

**Exception — migrations:** In migrations, hardcoded table names via `DB::table('settings')` are acceptable and preferred. Models change over time but migrations are frozen snapshots — referencing a model that is later renamed or deleted would break the migration.
**Exception — migrations:** In migrations, hardcoded table names via `DB::table('settings')` are acceptable and preferred. Models change over time but migrations are frozen snapshots — referencing a model that is later renamed or deleted would break the migration.
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ class InvalidOrderException extends Exception
return ['order_id' => $this->orderId];
}
}
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ Notification::route('mail', 'admin@example.com')->notify(new SystemAlert());

## Implement `HasLocalePreference` on Notifiable Models

Laravel automatically uses the user's preferred locale for all notifications and mailables — no per-call `locale()` needed.
Laravel automatically uses the user's preferred locale for all notifications and mailables — no per-call `locale()` needed.
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/http-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ Test failure scenarios too:
Http::fake([
'api.example.com/*' => Http::failedConnection(),
]);
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/mail.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Markdown mailables auto-generate both HTML and plain-text versions, use responsi

Content tests: instantiate the mailable directly, call `assertSeeInHtml()`.
Sending tests: use `Mail::fake()` and `assertSent()`/`assertQueued()`.
Don't mix them — it conflates concerns and makes tests brittle.
Don't mix them — it conflates concerns and makes tests brittle.
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ Schema::create('settings', function (Blueprint $table) { ... });

// Migration 2: seed_default_settings
DB::table('settings')->insert(['key' => 'version', 'value' => '1.0']);
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/queue-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ Use Laravel Horizon when you need monitoring, auto-scaling, failure tracking, or
],
],
],
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ public function store(StorePostRequest $request): RedirectResponse

return redirect()->route('posts.index');
}
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/scheduling.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Schedule::daily()
Schedule::command('emails:send --force');
Schedule::command('emails:prune');
});
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@ class Integration extends Model
];
}
}
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ if (count((array) $builder->getQuery()->joins) > 0)
Correct:
```php
if ($this->hasJoins())
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ Without `recycle()`, nested factories create separate instances of the same conc
Ticket::factory()
->recycle(Airline::factory()->create())
->create();
```
```
2 changes: 1 addition & 1 deletion .cursor/skills/laravel-best-practices/rules/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ public function after(): array
},
];
}
```
```
9 changes: 8 additions & 1 deletion .cursor/skills/pest-testing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Use `search-docs` for detailed Pest 4 patterns and documentation.

All tests must be written using Pest. Use `php artisan make:test --pest {name}`.

The `{name}` argument should include only the path and test name, but should not include the test suite.
- Incorrect: `php artisan make:test --pest Feature/SomeFeatureTest` will generate `tests/Feature/Feature/SomeFeatureTest.php`
- Correct: `php artisan make:test --pest SomeControllerTest` will generate `tests/Feature/SomeControllerTest.php`
- Incorrect: `php artisan make:test --pest --unit Unit/SomeServiceTest` will generate `tests/Unit/Unit/SomeServiceTest.php`
- Correct: `php artisan make:test --pest --unit SomeServiceTest` will generate `tests/Unit/SomeServiceTest.php`

### Test Organization

- Unit/Feature tests: `tests/Feature` and `tests/Unit` directories.
Expand Down Expand Up @@ -156,4 +162,5 @@ arch('controllers')
- Using `assertStatus(200)` instead of `assertSuccessful()`
- Forgetting datasets for repetitive validation tests
- Deleting tests without approval
- Forgetting `assertNoJavaScriptErrors()` in browser tests
- Forgetting `assertNoJavaScriptErrors()` in browser tests
- Prefixing `Feature/` or `Unit/` in `{name}` when using `make:test`
2 changes: 1 addition & 1 deletion .cursor/skills/tailwindcss-development/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ If existing pages and components support dark mode, new pages and components mus
- Using `@tailwind` directives instead of `@import "tailwindcss"`
- Trying to use `tailwind.config.js` instead of CSS `@theme` directive
- Using margins for spacing between siblings instead of gap utilities
- Forgetting to add dark mode variants when the project uses dark mode
- Forgetting to add dark mode variants when the project uses dark mode
Loading
Loading