hadyfayed/laravel-agent/db-optimize

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.

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

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

  1. 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()
  1. 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
  1. 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
  1. Identify Missing Eager Loading
  • Controllers returning Model::all() or Model::get()
  • Relationships accessed in views/resources
  • Relationship counts without withCount()
  • Polymorphic relationships without morphWith()
  1. Detect Slow Query Patterns
  • SELECT * on large tables
  • Unbounded queries (no limit, paginate, or chunk)
  • Missing column selection
  • Unnecessary joins
  • Inefficient aggregations
  1. 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

bash
# Analyze entire application
/db:optimize
# Analyze specific controller
/db:optimize app/Http/Controllers/OrderController
# Analyze specific model relationships
/db:optimize app/Models/Order
# Analyze service layer
/db:optimize app/Services

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

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/db-optimize/badge)](https://verified-skill.com/skills/hadyfayed/laravel-agent/db-optimize)

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