Agent skill
laravel-performance-eager-loading
Prevent N+1 queries by eager loading; enable lazy-loading protection in non-production; choose selective fields
Install this agent skill to your Project
npx add-skill https://github.com/noartem/skills/tree/main/skills/laravel-performance-eager-loading
SKILL.md
Eager Loading and N+1 Prevention
Load Relations Explicitly
Post::with(['author', 'comments'])->paginate();
- Use
load()/loadMissing()after fetching models when needed - Select only required columns for both base query and relations
Guard Against Lazy Loading in Dev/Test
Add to a service provider (non-production):
Model::preventLazyLoading(! app()->isProduction());
Verify
- Use a query logger or debugbar to confirm relation queries are minimized
- Add tests that assert counts or avoid unexpected query spikes
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
laravel-transactions-and-consistency
Wrap multi-write operations in transactions; use dispatchAfterCommit and idempotency patterns to ensure consistency
laravel-filesystem-uploads
Store and serve files via Storage; set visibility, generate URLs, and handle streaming safely
laravel-task-scheduling
Schedule tasks with safety; use withoutOverlapping, onOneServer, and visibility settings for reliable cron execution
laravel-dependencies-trim-packages
Remove unneeded Composer packages and assets to improve boot time, memory, and security surface
laravel-controller-tests
Write focused controller tests using HTTP assertions; keep heavy logic in Actions/Services and unit test them
laravel-strategy-pattern
Use the Strategy pattern to select behavior at runtime; bind multiple implementations to a shared interface
Didn't find tool you were looking for?