Performance Optimizer Skill
Use this skill when the user reports "slow pages" or asks to "optimize" code.
Checklist
- Database (The Usual Suspect)
-
N+1 Detection: Look for loops calling relationships.
-
Bad: @foreach ($users as $user) {{ $user->posts->count() }} @endforeach
-
Fix: User::withCount('posts')->get()
-
Indexes: Ensure searching columns (slugs, foreign keys, status) are indexed.
- Livewire / Filament
-
Computed Properties: Use #[Computed] for expensive calculations that don't need to run on every dehydrate.
-
Lazy Loading: Use lazy() on heavy components.
#[Computed] public function heavyData() { return ...; }
- Caching
-
Cache Facade: Cache::remember('key', 60, fn() => ...) for unrelated data.
-
Model Caching: If generic, use the model's booted method to clear cache on updates.
- Cloudflare / HTTP
- Check headers for Cache-Control .