Install
$ agentstack add skill-foysal50x-skills-laravel-eloquent ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Laravel Eloquent
Data-layer engineering rules: 45 rules across 8 sections, ordered by what actually takes an application down.
Assumes the layering from the laravel-patterns skill: all query construction lives in Query Classes and Repository implementations. These rules describe what goes inside those classes.
When to Apply
- Writing or reviewing a Query Class, Repository implementation or migration
- An endpoint is slow, times out, or exhausts memory
- A column comes back as a string when it should be an enum, date or array
- Writing an import, export, backfill or reporting query
- Adding a scope, global scope or soft deletes to a model
Pick the Rule
| About to write | Read | |----------------|------| | A query that reads relations | perf-eager-load-every-touched-relation, perf-prevent-lazy-loading | | A query returning many rows | paginate-always-paginate-lists, paginate-cursor-for-deep-pagination | | A new model | model-cast-every-column, model-final-and-typed, model-minimal-fillable | | A write touching more than one table | tx-wrap-multi-step-writes, tx-keep-transactions-short | | Raw SQL or a database expression | raw-never-interpolate-user-input, raw-only-inside-query-classes | | An update or insert over many rows | bulk-update-bypasses-events, bulk-upsert-instead-of-loop | | A filter used by several queries | scope-query-scopes-for-reusable-filters | | An existence check | perf-exists-not-count | | A pass over a large table | perf-chunk-large-result-sets, bulk-lazy-by-id-for-huge-sets | | A slow endpoint to diagnose | perf-index-filtered-columns, perf-avoid-wherehas-on-hot-paths | | One value from a has-many | perf-subquery-select-for-single-values | | Sorting by a related table's column | perf-order-by-correlated-subquery | | A count of related rows | perf-withcount-not-loaded-relations | | A migration | migration-never-edit-a-deployed-migration, migration-constrained-foreign-keys | | A backfill or default value | migration-separate-schema-from-data, migration-mirror-defaults-in-the-model |
Before You Write Code
- Every API named in these rules is verified against Laravel
^12.0 || ^13.0and PHP^8.3. If you need something these rules do not name, check the docs — never infer an API from its name. - Version-gated APIs are marked inline ("Laravel 13 only"). Read the project's
composer.jsonfirst; on Laravel 12 use the fallback the rule gives. - Where the project already differs from a rule, follow the project. Name the rule you set aside and why, rather than half-converting the codebase.
- When two rules collide, the higher-impact section wins — sections are ordered by impact.
- One example is not the whole rule. Open
rules/{slug}.mdbefore adapting it to a case the example does not show.
Rule Sections by Priority
| # | Section | Impact | Prefix | |---|---------|--------|--------| | 1 | Query Performance | CRITICAL | perf- | | 2 | Pagination | HIGH | paginate- | | 3 | Transactions and Consistency | HIGH | tx- | | 4 | Model Declaration | HIGH | model- | | 5 | Scopes, Global Scopes and Soft Deletes | MEDIUM-HIGH | scope- | | 6 | Migrations and Schema | MEDIUM-HIGH | migration- | | 7 | Raw SQL and Query Expressions | MEDIUM | raw- | | 8 | Bulk Operations | MEDIUM | bulk- |
Quick Reference
1. Query Performance (CRITICAL)
perf-eager-load-every-touched-relation— Every relation the output touches is inwith([...])perf-prevent-lazy-loading— Make lazy loading throw outside productionperf-select-only-needed-columns— Narrow the select on wide tablesperf-exists-not-count— Askexists()when you only need a booleanperf-chunk-large-result-sets— Chunk or stream instead ofget()perf-avoid-wherehas-on-hot-paths— ReplacewhereHaswith a join on hot pathsperf-index-filtered-columns— Index every column you filter, join or sort onperf-withcount-not-loaded-relations— Count withwithCount(), never a loaded collectionperf-subquery-select-for-single-values— Pull a single related value with a subqueryperf-order-by-correlated-subquery— Sort by a related value with a subquery, not a joinperf-set-relation-to-close-the-loop— Hand the parent back withsetRelation()
2. Pagination (HIGH)
paginate-always-paginate-lists— Never return an unbounded listpaginate-cursor-for-deep-pagination—cursorPaginate()for deep or fast-growing setspaginate-simple-when-no-total—simplePaginate()when the total is not renderedpaginate-full-only-when-count-required— Reservepaginate()for a required count
3. Transactions and Consistency (HIGH)
tx-wrap-multi-step-writes— Multi-step writes are atomictx-keep-transactions-short— No HTTP, mail or file I/O inside a transactiontx-dispatch-after-commit— Jobs and events fire after committx-lock-for-update-on-contention— Lock rows you read then modifytx-retry-on-deadlock— Passattempts:so deadlocks retry
4. Model Declaration (HIGH)
model-cast-every-column— Cast every date, enum, JSON and money columnmodel-custom-casts-for-value-objects— Value Objects get aCastsAttributesclassmodel-minimal-fillable—$fillableis a security boundarymodel-scope-attribute— Declare scopes with#[Scope](Laravel 12+)model-observed-by-attribute— Attach observers with#[ObservedBy]model-immutable-dates-and-timezones— Store UTC, cast immutable, convert at the edgemodel-final-and-typed—final,strict_types, typed relations,@propertydocblocks
5. Scopes, Global Scopes and Soft Deletes (MEDIUM-HIGH)
scope-query-scopes-for-reusable-filters— Small reusable constraints live on the modelscope-global-scope-for-default-filter— Global scope for a filter that must never be forgottenscope-global-or-named-not-both— One filter, one mechanismscope-soft-deletes-for-recoverable—SoftDeletesonly for genuinely recoverable recordsscope-explicit-trashed-queries— Name the query after what it includes
6. Migrations and Schema (MEDIUM-HIGH)
migration-never-edit-a-deployed-migration— Once it has run in production it is historymigration-separate-schema-from-data— Structure in one migration, data in anothermigration-constrained-foreign-keys—constrained()plus an explicit delete behaviourmigration-reversible-down— Write adown()that actually reversesup()migration-mirror-defaults-in-the-model— The same default in$attributes
7. Raw SQL and Query Expressions (MEDIUM)
raw-only-inside-query-classes— Raw SQL belongs in Query Classes and Repositoriesraw-tpetry-instead-of-db-raw— Type-safe expressions instead ofDB::raw()raw-conditional-aggregates-in-one-query— Dashboard counters in a single queryraw-custom-expression-helpers— Wrap driver-specific SQL in anExpressionclassraw-never-interpolate-user-input— Bindings for values, allow-lists for identifiers
8. Bulk Operations (MEDIUM)
bulk-upsert-instead-of-loop— Batch inserts and upsertsbulk-update-bypasses-events— Bulk writes skip model events; handle that deliberatelybulk-lazy-by-id-for-huge-sets—chunkById/lazyById, never offset paging while writing
Recommended Packages
Verified against Laravel 13:
| Need | Package | Constraint | |------|---------|------------| | Type-safe SQL expressions (replaces DB::raw()) | tpetry/laravel-query-expressions | ^1.6 | | Declarative, reusable model filters | indexzer0/eloquent-filtering | ^2.2.2 | | Excel import and export | rap2hpoutre/fast-excel | ^5.14 |
All three are used inside Query Classes and Repositories only. Drop to raw expressions when a declarative filter package hurts performance on a hot query.
Reference Material
references/n-plus-one-playbook.md— finding, fixing and preventing N+1references/pagination-decision.md— choosing between the three paginatorsreferences/checklist.md— pre-merge self-check for the data layer
How to Use
Load in this order and stop when the answer is clear:
- This file — the Quick Reference names every rule, and usually settles the question.
- One rule file for the reasoning and both examples (~366 tokens each):
rules/perf-eager-load-every-touched-relation.md
rules/tx-dispatch-after-commit.md
- A
references/file only when a rule points at one.
AGENTS.md is every rule compiled into one document (~12k tokens), for agents that read the AGENTS.md convention. Do not load it when the individual rule files are reachable.
Related Skills
laravel-patterns— where the query goes: Query Class, Repository, Action or inlinelaravel-rest-api— pagination and resources at the HTTP edgelaravel-async— caching query results and invalidating on model eventslaravel-testing— testing query rules against a real database
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: Foysal50x
- Source: Foysal50x/skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.