/laraclaude:lc:analyze-model [analyze | fix | fix --dry-run | ModelName | fix ModelName]from laraclaude
Analyzes Laravel Eloquent models for relationships, scopes, casts, fillable fields, observers, and mass-assignment issues. Can auto-fix common problems.
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.
Perform a comprehensive analysis of a Laravel Eloquent model, extracting all relevant information about its structure, relationships, behaviors, and potential issues.
| Subcommand | Description |
|---|---|
| (no argument) | List all models and ask which to analyze. Read-only report. |
fix | Analyze all models and auto-fix common issues (missing fillable, broken casts, etc.) with confirmation before each change. |
fix --dry-run | Show what fixes would be applied across all models without changing anything. |
[ModelName] | Analyze a specific model. Read-only report. |
fix [ModelName] | Analyze and fix issues in a specific model, with confirmation before each change. |
[ModelName] argument is provided:
app/Models/{ModelName}.php using Glob.app/Models/ directory.app/ directory for a class with that name.Glob to list all files in app/Models/*.php.Use Read to load the full model file. Extract the following sections:
#[KeptBy(...)], #[UsesOrigin(...)], etc.)$table property or conventional)casts() method -- list all casts with their typesFor each relationship method, extract:
Display as a structured list:
RELATIONSHIPS
==============
belongsTo:
- organization() -> Organization::class (FK: organization_id)
- office() -> Office::class (FK: office_id)
- user() -> User::class (FK: user_id)
hasMany:
- properties() -> Property::class (FK: client_id)
- operations() -> Operation::class (FK: client_seller_id)
belongsToMany:
- tags() -> Tag::class (pivot: client_tag, columns: [])
scopeActive, scopeForUser, etc.)booted() or via attributes)Attribute::make(get: ..., set: ...)getXAttribute(), setXAttribute()$appends arrayapp/Observers/{ModelName}Observer.php#[KeptBy(KeeperClass::class)] attributegetX() methods$actions array propertyhandle() method signatureboot(), booted() -- any event listeners or global scopesGrep to search for Schema::create('{table_name}'.$fillable:
$fillable (and not in standard exclusions like id, timestamps, etc.)$fillable but NOT in migration (possibly computed or from a different source)Scan for these common problems:
$fillable or $guarded.belongsTo relationship where the FK column doesn't have a foreign key constraint in the migration.$this->relationship without the relationship being commonly eager-loaded.SoftDeletes trait but migration doesn't have softDeletes(), or vice versa.Create a text-based relationship diagram showing how this model connects to others:
+------------------+
| Organization |
+------------------+
|
belongsTo
|
+----------+ +-----------+ +----------+
| Office |<-------| Client |------->| User |
+----------+ +-----------+ +----------+
belongsTo | | belongsTo
hasMany belongsToMany
| |
+-----------+ +------+
| Property | | Tag |
+-----------+ +------+
Keep the diagram focused on direct relationships (1 level deep). For models with many relationships, group by relationship type.
Output all findings in a well-structured format with clear section headers. Use code blocks for code snippets and tables for tabular data.
End with a summary:
MODEL SUMMARY: Client
======================
Table: clients
Traits: 5 (HasFactory, SoftDeletes, HasActions, HasKeepers, Notifiable)
Fillable fields: 22
Relationships: 12 (4 belongsTo, 5 hasMany, 2 belongsToMany, 1 morphMany)
Scopes: 3
Accessors: 4
Actions: 3
Potential issues: 2
fix or fix [ModelName])When running in fix mode, automatically apply fixes for detected issues with confirmation before each change:
$fillable array (excluding id, timestamps, soft deletes, and auto-generated fields).belongsTo methods for FK columns that lack corresponding relationship methods.SoftDeletes trait if migration has softDeletes() but model lacks the trait, or vice versa.Each fix requires explicit user confirmation before applying.
fix --dry-run)Show all the fixes that would be applied (same as fix mode) but do not write any changes. Display the before/after diff for each proposed change.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub edulazaro/laraclaude --plugin laraclaude32 skills in this plugin
/lc:analyze-errorPaste a Laravel stacktrace and get root cause analysis with suggested fix./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./lc:cache-opportunitiesDetect repeated queries and computations that should be cached./lc:check-foreign-keysDetect broken, orphaned, or missing foreign key constraints in Laravel migrations and models.Other plugins' skills for the same job