laravel-eloquent
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.
- 01GitHub stars
- 583
- 02Installs
- New
- 03Files scanned
- 3
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 cad5bafad3eb598a… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Laravel Eloquent
Priority: P0 (CRITICAL)
Workflow: Add Model with Safe Queries
- Define model — Set
$fillable,$casts, and relationships. - Enable strict loading — Call
Model::preventLazyLoading(!app()->isProduction())in AppServiceProvider. - Add scopes — Create
scopeActive(),scopeVerified()for reusable filters. - Eager-load in queries — Use
with()for all relationship access. - Process large datasets — Use
chunk()orcursor()instead ofget().
Scope + Eager Loading Example
See implementation examples for model scopes, eager loading, and directory structure.
Implementation Guidelines
Query Efficiency & Performance
- N+1 Prevention: Always use
with()or$withfor relationships. Never access relationship properties in loop without eager loading (N+1 Prevention). - Strict Loading: Call
Model::preventLazyLoading(!app()->isProduction())inAppServiceProvider::boot()to throwLazyLoadingViolationExceptionin local/dev. - Large Datasets: Use
chunk(),lazy(), orcursor()for processing many records without memory issues (Memory Efficiency).
Query Logic & Scopes
- Reusable Scopes: Define
scopeName(Builder $query): Buildermethods in models for reusable query filters. - Chaining: Chain scopes (e.g.,
User::active()->verified()->get()) to keep controllers from duplicating query logic.
Models & Security
- Mass Assignment: Always define
protected $fillablearray; use$request->validated()forModel::create(). - Casting: Use
protected $castsfor dates, JSON, and custom types to ensure data consistency.
Anti-Patterns
- No lazy loading: Eager-load with
with()or$with; never in loops. - No business logic in Models: Move to Services or Actions.
- No raw SQL strings: Use Query Builder or Eloquent methods.
- No
select *: Specify required columns to limit data transfer.
References
Files
3- SKILL.md
352ba8ed932.5 KB - evals/evals.json
2038342ee63.8 KB - references/implementation.md
6d56d70d1b1.2 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from HoangNguyen0403/agent-skills-standard8
Enforce universal mobile UX principles for touch-first interfaces including touch targets, safe areas, and mobile-specific interaction patterns. Use when building mobile screens, handling touch interactions, or validating safe area compliance.
Optimize React Native rendering for smooth 60fps mobile experiences. Use when optimizing React Native app performance, reducing re-renders, or fixing frame drops.
Upgrade an Android project to Android Gradle Plugin (AGP) 9. Use when migrating to AGP 9, updating Gradle build files, migrating to built-in Kotlin, or adopting the new AGP DSL.
Apply Clean Architecture layering, modularization, and Unidirectional Data Flow in Android projects. Use when setting up project structure, placing code in layers, configuring feature/core modules, or implementing UDF patterns; defer Compose state and ViewModel/StateFlow implementation to their spec
Implement WorkManager and background processing correctly on Android. Use when creating Worker classes, scheduling tasks, choosing between WorkManager and Foreground Services, or setting up Hilt in workers; defer FCM and notification delivery to android-notifications.
Build high-performance declarative UI with Jetpack Compose. Use when writing Composable functions, optimizing recomposition, hoisting state, or working with LazyColumn and side effects; defer deep-link and navigation routing to android-navigation.
Migrate an Android XML View to Jetpack Compose following a structured 10-step workflow. Use when converting XML layouts to Compose, setting up Compose in an existing View-based project, or incrementally adopting Compose.
Write correct coroutine scopes, lifecycle collection, and dispatcher injection in Android production code. Use for suspend functions, coroutine scopes, and dispatcher mechanics; defer ViewModel StateFlow/LiveData architecture, Fragment lifecycle recipes, persistence/notifications, and unit-test reci
Related ai-ml skillsscan passed
Pair a remote AI agent with your browser. Use for: pair with agent, connect remote agent. (gstack)
Connects AI agents to Windows desktops on Amazon WorkSpaces Applications (AppStream 2.0) fleets and image builders through the Agent Access MCP server, and guides reliable desktop automation. Covers the MCP endpoint and SigV4 signing, naming the session (stack and user ID, streaming URL, or AD SAML/
Long-context MoE training guidance for Megatron Bridge. Covers CP sizing, selective recompute, dispatcher choices, and practical patterns from DSV3, Qwen3, and Qwen3-Next long-context experiments.