hadyfayed/laravel-agent/db-optimize
Claude Code and agent skill by hadyfayed/laravel-agent
- community
Checking that the SKILL.md file is still in the repository.
Optimize database performance by analyzing queries, detecting N+1 and Big O issues, suggesting indexes, and recommending query tuning; when improving database speed (NOT for database conventions; use laravel-database).
Install
npx vskill@latest install hadyfayed/laravel-agent/db-optimizeSKILL.md
The same SKILL.md was published earlier as hadyfayed/laravel-agent/db-optimize.
Task
Analyze a Laravel application for database performance issues and recommend optimizations.
Input
- target (optional): Controller, service, table, or path to analyze; all by default
Steps
- Detect N+1 Query Patterns
``bash grep -r "foreach.*->" app/ | grep -v "with(" ``
- Lazy loading inside loops
- Missing eager loading in queries
- Nested relationship loading without
with()
- Detect Big O Complexity Issues
``bash grep -r "foreach.*foreach" app/ grep -r "\.contains(" app/ grep -r "in_array(" app/ ``
- O(n²) nested loops
- O(n²) contains() in loops
- O(n²) array searches
- O(n) queries in loops
- Analyze Index Coverage
- Foreign keys without indexes
- Columns in WHERE clauses without indexes
- Composite indexes for multi-column queries
- ORDER BY and GROUP BY without indexes
- Identify Missing Eager Loading
- Controllers returning Model::all() or Model::get()
- Relationships accessed in views/resources
- Relationship counts without withCount()
- Polymorphic relationships without morphWith()
- Detect Slow Query Patterns
- SELECT * on large tables
- Unbounded queries (no limit, paginate, or chunk)
- Missing column selection
- Unnecessary joins
- Inefficient aggregations
- Check Schema Efficiency
- Inefficient column types (int for user_id, string for timestamps)
- Missing constraints (NOT NULL, UNIQUE)
- Missing default values
- Overlapping indexes
Output Report
Generate a prioritized markdown report with:
- N+1 Queries — file, line, relationship, and eager loading fix
- Big O Issues — nested loops, contains() in loops, array searches, and fixes
- Missing Indexes — table, column(s), query pattern, and SQL recommendations
- Optimization Checklist — eager loading, withCount(), schema efficiency
Pattern Reference
For detailed patterns and solutions, see laravel-database skill's performance reference:
- N+1 query patterns — detection and fixes with eager loading strategies
- Big O complexity patterns — O(n²) loops, nested searches, and optimization techniques
- Index design and strategy — single-column, composite, and covering indexes
This skill's role is to detect and report these issues; laravel-database owns the canonical pattern library.
Options
Security
- Security scanPassed, 95 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/db-optimize/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/db-optimize)