skills/laravel/laravel-eloquent/SKILL.md
Write performant Eloquent queries with eager loading, reusable scopes, and strict lazy-loading prevention in Laravel. Use when defining model relationships, creating query scopes, or processing large datasets with chunk/cursor.
npx skillsauth add hoangnguyen0403/agent-skills-standard laravel-eloquentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
$fillable, $casts, and relationships.preventLazyLoading(!app()->isProduction()) in AppServiceProvider.scopeActive(), scopeVerified() for reusable filters.with() for all relationship access.chunk() or cursor() instead of get().See implementation examples for model scopes, eager loading, and directory structure.
with() or $with for relationships. Never access relationship properties in loop without eager loading (N+1 Prevention).Eloquent::preventLazyLoading(!app()->isProduction()) in AppServiceProvider::boot() to throw LazyLoadingViolationException in local/dev.chunk(), lazy(), or cursor() for processing many records without memory issues (Memory Efficiency).scopeName(Builder $query): Builder methods in models for reusable query filters.User::active()->verified()->get()) to keep controllers from duplicating query logic.protected $fillable array; use $request->validated() for Model::create().protected $casts for dates, JSON, and custom types to ensure data consistency.with() or $with; never in loops.select *: Specify required columns to limit data transfer.development
Standardize SRS and FRS specifications for technical behavior, interfaces, data contracts, quality constraints, and verification mapping. Use when writing SRS, functional specification, system behavior requirements, API/data contracts, or non-functional thresholds.
development
Standardize BRD and BRD-lite discovery for business goals, stakeholder impact, current-to-future state, and measurable value outcomes. Use when creating BRD, business case, project justification, ROI narrative, or AS-IS to TO-BE scope.
development
Implements a strict Red-Green-Refactor loop to ensure zero production code is written without a prior failing test. Use when: creating new features, fixing bugs, or expanding test coverage.
testing
Standardize PRD discovery and drafting for product scope, user outcomes, requirement IDs, and acceptance criteria. Use when creating PRD, product requirements, feature specification, or acceptance criteria plan.