lc-analyze-model
Deep analysis of a Laravel Eloquent model - relationships, scopes, casts, fillable, observers, keepers, actions.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Deep analysis of a Laravel Eloquent model - relationships, scopes, casts, fillable, observers, keepers, actions.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Create a Larascraper scraper (v2 or v3) for a target website, chaining browser actions (click, type, wait, scroll), conditional flow (when/repeatUntil), captcha solving, and file/PDF downloads. Detects the installed major and generates the matching style.
Add or edit a Laracrate file collection in config/laracrate.php with the correct anatomy (disk, access, types, variants, previews, extract/embed, flags, per-model scoping).
Runtime-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.
Scaffold spatie/laravel-permission setup - add the HasRoles trait to a model and generate a roles & permissions seeder.
Audit spatie/laravel-permission usage - permissions used in code but undefined, defined but unused, unprotected routes, guard mismatches, and cache pitfalls.
Extract business logic from a controller or Livewire component method into a Laractions Action class.
| name | lc:analyze-model |
| description | Deep analysis of a Laravel Eloquent model - relationships, scopes, casts, fillable, observers, keepers, actions. |
| argument-hint | [analyze | fix | fix --dry-run | ModelName | fix ModelName] |
| user-invocable | true |
| allowed-tools | Read Grep Bash Edit Write Glob |
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.