eloquent-audit

Scan Laravel PHP source files for Eloquent N+1 and optimization issues.

1|Updated Apr 30, 2026
One-click install
npx skills add https://github.com/jonaaix/laravel-livewire-base --skill eloquent-audit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: eloquent-audit
Source: https://github.com/jonaaix/laravel-livewire-base/tree/main/.ai/skills/eloquent-audit
Command: npx skills add https://github.com/jonaaix/laravel-livewire-base --skill eloquent-audit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Auditors and teams often miss Eloquent inefficiencies and misconfigurations, leading to N+1 queries and unnecessary data loading. This Skill provides a structured approach to analyze Eloquent usage across a Laravel project and deliver actionable recommendations.

Core Features & Use Cases

  • Scans controllers, services, Livewire components, tests, and API resources for eager loading opportunities and relationship misuse.
  • Flags missing casts, unsafe query patterns, and mass-assignment risks in models, improving data integrity and runtime performance.
  • Produces a consolidated findings report with concrete refactoring steps and best-practice guidance for common Eloquent scenarios.

Quick Start

Run the audit across your Laravel project to generate a findings report immediately.

Frequently Asked Questions about eloquent-audit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find and fix N+1 query problems in a Laravel Eloquent project?

To find and fix Laravel Eloquent N+1 query problems, this audit scans controllers, Livewire components, and services for eager loading opportunities. It flags inefficient relationship access and reports findings with actionable refactoring steps and configurable thresholds.

What is the best way to audit Eloquent models for missing casts and mass-assignment risks?

Auditing Eloquent models for missing casts and mass-assignment risks involves scanning your models to flag unsafe query patterns and data integrity issues. This process produces a consolidated findings report with concrete recommendations to improve data integrity and runtime performance.

Can I scan Laravel API resources and repositories for Eloquent query optimization opportunities?

Yes, you can scan Laravel API resources and repositories for Eloquent query optimization. The audit evaluates serialization and query patterns across your codebase, identifying unnecessary data loading and providing best-practice guidance to improve performance and correctness.

Does the Eloquent audit exclude vendor and node_modules directories when scanning PHP source files?

Yes, the Eloquent audit enforces scope by excluding vendor, node_modules, and storage directories when scanning PHP source files. This ensures the analysis targets your application code in controllers, models, migrations, and tests without processing external dependencies.

How do I configure N+1 detection thresholds for a Laravel codebase audit?

Configuring N+1 detection thresholds for a Laravel codebase audit allows you to set limits for query optimization analysis. The audit applies these thresholds while scanning your PHP source files, reporting only the Eloquent usage patterns that exceed your defined configuration.