hadyfayed/laravel-agent/laravel-database
Claude Code and agent skill by hadyfayed/laravel-agent
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Reference on Laravel database conventions — migrations, Eloquent relationships, N+1 and Big-O query optimization, indexing; when learning or reviewing database code (NOT for optimizing performance; use db-optimize).
Install
npx vskill@latest install hadyfayed/laravel-agent/laravel-databaseSKILL.md
The same SKILL.md was published earlier as hadyfayed/laravel-agent/laravel-database.
Laravel Database Skill
Apply Laravel database best practices when writing migrations, designing schemas, fixing slow queries, or reviewing Eloquent code.
When to Use
- Creating or modifying migrations
- Fixing N+1 query problems
- Fixing Big O complexity issues (O(n²), nested loops)
- Optimizing slow queries
- Designing database schemas
- Adding indexes
- Setting up Eloquent relationships
Quick Start
Conventions Checklist
Migrations
- [ ] Declare
strict_types=1at the top - [ ] Use
return new class extends Migration(anonymous class syntax) - [ ] Always define
down()— drop or reverse exactly whatup()creates - [ ] Use
foreignId(...)->constrained()->cascadeOnDelete()for FK columns - [ ] Add composite indexes for columns that appear together in
WHERE+ORDER BY - [ ] Use
decimal(10, 2)for monetary amounts (neverfloat) - [ ] Use
softDeletes()on user-facing entities - [ ] Never store nullable booleans — use
tinyIntegerwith a default instead
Eloquent Models
- [ ] Declare
$fillableor$guardedexplicitly — never leave both unset - [ ] Type-hint relationship return types (
HasMany,BelongsTo, etc.) - [ ] Use
$castsfor dates, enums, and JSON columns - [ ] Add
scopeActive()/scopeOrdered()query scopes rather than inline where chains
Queries
- [ ] Eager-load all relationships needed in a loop — no lazy loading in loops
- [ ] Select only the columns you need (
->select(['id', 'name'])) - [ ] Use
chunk()/chunkById()for operations on large datasets - [ ] Use
->count()not->get()->count() - [ ] Replace
contains()in a loop with->flip()->has()orgroupBy() - [ ] Batch updates with
whereIn(...)->update(...)instead of per-row queries
Transactions
- [ ] Wrap multi-step write sequences in
DB::transaction() - [ ] Never mix reads and writes in a transaction unless the read is a lock check
Indexes
- [ ] Index every foreign key column
- [ ] Add a composite index when two columns always appear together in
WHERE - [ ] Use
unique()for columns that enforce business uniqueness
Common Pitfalls
- N+1 Queries — always eager load with
with() - Big O Issues — avoid nested loops; use
keyBy()/groupBy()for O(1) lookups - Missing Indexes — add indexes for
WHEREandORDER BYcolumns - SELECT \* — only select needed columns
- No Chunking — use
chunk()for large datasets - In-Loop Queries — batch queries outside loops
- `contains()` in Loops — use
flip()->has()for O(1) lookups - No Foreign Keys — always use constraints
- No Transactions — wrap related write operations
Package Integration
- beyondcode/laravel-query-detector — N+1 detection
- barryvdh/laravel-debugbar — query profiling
- spatie/laravel-query-builder — API query building
Related Commands
/laravel-agent:db:optimize— analyze and optimize database queries/laravel-agent:db:diagram— generate database schema diagram
Related Skills
laravel-performance— query optimization and caching
Additional references
- Migrations & relationships → references/migrations.md
- N+1 & Big-O optimization, indexing → references/performance.md
- Version upgrades & legacy import → references/upgrades-and-legacy.md
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/laravel-database/SKILL.md
Popularity
- Repository stars
- 13
- Repository forks
- 1
- 7-day trend score
- 13
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hadyfayed/laravel-agent/laravel-database)