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-database

SKILL.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

bash
/laravel-agent:db:optimize
/laravel-agent:db:diagram

Conventions Checklist

Migrations
  • [ ] Declare strict_types=1 at the top
  • [ ] Use return new class extends Migration (anonymous class syntax)
  • [ ] Always define down() — drop or reverse exactly what up() 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 (never float)
  • [ ] Use softDeletes() on user-facing entities
  • [ ] Never store nullable booleans — use tinyInteger with a default instead
Eloquent Models
  • [ ] Declare $fillable or $guarded explicitly — never leave both unset
  • [ ] Type-hint relationship return types (HasMany, BelongsTo, etc.)
  • [ ] Use $casts for 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() or groupBy()
  • [ ] 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

  1. N+1 Queries — always eager load with with()
  2. Big O Issues — avoid nested loops; use keyBy()/groupBy() for O(1) lookups
  3. Missing Indexes — add indexes for WHERE and ORDER BY columns
  4. SELECT \* — only select needed columns
  5. No Chunking — use chunk() for large datasets
  6. In-Loop Queries — batch queries outside loops
  7. `contains()` in Loops — use flip()->has() for O(1) lookups
  8. No Foreign Keys — always use constraints
  9. 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

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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/hadyfayed/laravel-agent/laravel-database/badge)](https://verified-skill.com/skills/hadyfayed/laravel-agent/laravel-database)

Something wrong with this skill or its page? Tell us.