/laraclaude:lc:analyze-error [analyze | fix | fix --dry-run]from laraclaude
Parses a Laravel stacktrace to diagnose root cause, reads relevant source files (models, migrations, views, routes), and suggests or applies fixes with dry-run support.
Ships in laraclaude. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Parse a Laravel stacktrace or error message, identify the root cause, read the relevant source files, and provide a specific fix.
| Subcommand | Description |
|---|---|
| (no argument) | Paste an error after invoking. Analyzes and reports root cause with suggested fix. |
fix | Analyze the error and apply the suggested fix, with confirmation before each change. |
fix --dry-run | Analyze the error and show exactly what changes would be made without applying them. |
In all modes, the user pastes the error output after invoking the skill.
The user will paste an error after invoking this skill. Parse the error output to extract:
Illuminate\Database\QueryException, ErrorException, BadMethodCallExceptionIf the error is a standard Laravel error page (HTML), extract the relevant information from the HTML structure. If it is a CLI error, parse the text output.
Read to load the file where the error occurred, focusing on the line number from the stacktrace with surrounding context (approximately 20 lines before and after).app/, routes/, resources/, database/, config/) -- that is where the fix needs to happen.Based on the error type, read additional files for context:
config/auth.php)Classify the error into one of these common patterns and provide specific diagnosis:
| Pattern | Exception | Root Cause |
|---|---|---|
SQLSTATE[42S02] | QueryException | Table doesn't exist -- migration not run or wrong table name |
SQLSTATE[42S22] | QueryException | Column doesn't exist -- typo, migration not run, or column removed |
SQLSTATE[23000] | QueryException | Integrity constraint violation -- duplicate entry, null in NOT NULL, FK violation |
SQLSTATE[42000] | QueryException | Syntax error in SQL -- usually from raw queries or incorrect query builder usage |
SQLSTATE[HY000]: 1215 | QueryException | Cannot add FK constraint -- type mismatch or referenced table missing |
SQLSTATE[22001] | QueryException | Data too long -- string exceeds column length |
| Pattern | Exception | Root Cause |
|---|---|---|
Call to undefined relationship | BadMethodCallException | Relationship method doesn't exist on model |
Property does not exist | ErrorException | Accessing undefined property (possible missing relationship or accessor) |
Mass assignment | MassAssignmentException | Column not in $fillable or $guarded is blocking it |
Model not found | ModelNotFoundException | findOrFail() or firstOrFail() with non-existent ID |
Call to a member function on null | ErrorException | Accessing method on null relationship result |
| Pattern | Exception | Root Cause |
|---|---|---|
Undefined variable | ErrorException | Variable not passed from controller/component to view |
Property not found on component | Livewire error | Wire:model bound to non-existent property |
Component not found | ComponentNotFoundException | Livewire component class missing or not registered |
View not found | InvalidArgumentException | Blade file doesn't exist at expected path |
| Pattern | Exception | Root Cause |
|---|---|---|
Unauthenticated | AuthenticationException | User not logged in, session expired, or wrong guard |
This action is unauthorized | AuthorizationException | Policy check failed |
Route [login] not defined | RouteNotFoundException | Missing named route for auth redirect |
| Pattern | Exception | Root Cause |
|---|---|---|
Typed property must not be accessed before initialization | Error | Livewire property declared with type but no default value |
Cannot access offset of type null | TypeError | Trying to array-access a null value |
Argument #N must be of type X, Y given | TypeError | Wrong argument type passed to method |
Enum case not found | ValueError | Invalid value for PHP enum cast |
For each error, provide:
// BEFORE (line 45 in app/Models/Property.php):
return $this->office->name;
// AFTER:
return $this->office?->name;
After identifying the primary fix, check if the same pattern exists elsewhere:
Grep to search for similar problematic patterns in other files.In fix mode:
Edit to apply the change.In fix --dry-run mode:
In default mode (no subcommand):
Illuminate\Database\QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'properties.group_id' in 'where clause'
(Connection: mysql, SQL: select * from `properties` where `properties`.`group_id` = 1)
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:829
...
at app/Http/Controllers/PropertyController.php:25
Extract: Exception class, SQL state, column name, table, and the app file from the trace.
[2026-04-06 10:15:23] production.ERROR: Call to a member function format() on null
{"exception":"[object] (Error(code: 0): ... at /var/www/html/app/Models/Schedule.php:45)"}
Extract from JSON structure within the log line.
Livewire\Exceptions\PropertyNotFoundException
Property [$selectedUser] not found on component: [calendar]
These reference the Livewire component name, which maps to a Blade file in resources/views/livewire/.
If the error is related to Vite, assets, or frontend compilation, check:
vite.config.js configurationpackage.json dependenciesnpm run dev is runningBased on the project's CLAUDE.md, watch for these specific patterns:
database/schema/mysql-schema.sql.group_id instead of organization_id, Group instead of Organization.DatabaseNotification should use App\Models\Notification instead.__() instead of text() will not work with Laratext.ERROR ANALYSIS
===============
Exception: Illuminate\Database\QueryException
Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'properties.group_id'
ROOT CAUSE
===========
The 'properties' table was renamed from 'group_id' to 'organization_id' in the
Organization rename migration (2025_12_25_023229), but this query still uses the
old column name.
LOCATION
=========
File: app/Http/Controllers/PropertyController.php
Line: 25
Code: Property::where('group_id', $organizationId)->get();
FIX
====
Change 'group_id' to 'organization_id':
// Line 25
- Property::where('group_id', $organizationId)->get();
+ Property::where('organization_id', $organizationId)->get();
RELATED ISSUES
===============
Found 3 other files with the same pattern:
- app/Services/PropertyService.php:42
- app/Jobs/SyncPropertyJob.php:18
- resources/views/livewire/properties/index.blade.php:33
Apply fix? [Waiting for confirmation]
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub edulazaro/laraclaude --plugin laraclaude32 skills in this plugin
/lc:analyze-modelDeep analysis of a Laravel Eloquent model - relationships, scopes, casts, fillable, observers, keepers, actions./lc:api-docsGenerate API documentation from routes, controllers, and form requests./lc:blade-auditDetect hardcoded text without @text(), duplicate CSS classes, unused Blade components, and accessibility issues./lc:boost-inspectRuntime-verified Laravel inspection using the Laravel Boost MCP server (Tinker, Database Query/Schema, Last Error) instead of static grep. Falls back to Docker/Tinker if Boost is not installed.Other plugins' skills for the same job