lc-unused-columns
Detect database columns that are never referenced in the codebase.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Detect database columns that are never referenced in the codebase.
التثبيت باستخدام 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:unused-columns |
| description | Detect database columns that are never referenced in the codebase. |
| argument-hint | [analyze | fix | fix --dry-run | table-name | fix table-name] |
| user-invocable | true |
| allowed-tools | Read Grep Bash Edit Write Glob |
Find database columns that exist in migrations (or the live database) but are never referenced anywhere in the application codebase. These are candidates for removal.
| Subcommand | Description |
|---|---|
| (no argument) | Analyze all tables for unused columns. Read-only report. |
fix | Generate a migration to drop all confirmed unused columns. Asks for confirmation before each column. |
fix --dry-run | Show the migration that would be generated without writing anything. |
[table-name] | Analyze unused columns in a specific table only. |
fix [table-name] | Generate a drop-column migration for a specific table, with confirmation. |
If a [table-name] argument is provided, analyze only that table. If no argument, analyze all tables.
Glob to find all database/migrations/*.php files.$table->string('name') -- column: name$table->foreignId('user_id') -- column: user_id$table->timestamps() -- columns: created_at, updated_at$table->softDeletes() -- column: deleted_at$table->morphs('taggable') -- columns: taggable_type, taggable_id$table->rememberToken() -- column: remember_token$table->dropColumn('name') -- remove column from list$table->renameColumn('old', 'new')docker exec {container} php artisan tinker --execute="
\$columns = Schema::getColumnListing('{table}');
echo implode(PHP_EOL, \$columns);
"
The following columns are considered "always used" and should be excluded from the analysis:
id -- primary keycreated_at, updated_at -- timestampsdeleted_at -- soft deletesslug -- commonly used for URLsremember_token -- authenticationemail_verified_at -- email verificationpassword -- authenticationThese are still tracked but reported separately as "Standard columns (excluded from analysis)".
For each non-standard column, search the entire codebase for references using Grep. Search in these locations and patterns:
app/Models/*.php)$fillable array entries$casts array entries$hidden array entries$appends array entriesget{Column}Attribute, set{Column}Attribute, Attribute::make)scope methods that reference the column)$table-> references in model methodsresources/views/**/*.blade.php)$model->column_name accesswire:model="column_name" bindingswire:model.live="column_name" bindings{{ $column_name }} direct output@if($model->column_name) conditionsapp/Http/Controllers/**/*.php, app/Actions/**/*.php)$request->column_name or $request->input('column_name')->where('column_name', ...)->orderBy('column_name')->select('column_name')->pluck('column_name')->groupBy('column_name')'column_name' => $valueapp/Observers/*.php)$model->column_name access$model->isDirty('column_name')$model->wasChanged('column_name')app/Jobs/*.php, app/Services/*.php)database/migrations/*.php)database/seeders/*.php, database/factories/*.php)Column names that are common English words may match in unrelated contexts. Apply these filters:
$model->$field or $model->getAttribute($field). These are harder to detect statically -- flag columns that appear in arrays that might be iterated for dynamic access.->column->nested_key or ->column['key'].For each column, classify into:
For a specific table:
UNUSED COLUMNS ANALYSIS: properties
=====================================
Columns analyzed: 42 (excluding 5 standard columns)
UNUSED (0 references):
- legacy_portal_id | bigInteger, nullable | No references found
- old_reference_code | string(50), nullable | No references found
- temp_import_flag | boolean, default:false | No references found
MIGRATION_ONLY (referenced only in migrations):
- migration_batch_id | integer, nullable | Found in: 1 migration data update
POSSIBLY_UNUSED (needs review):
- internal_notes | text, nullable | Found in: 1 factory definition only
IN USE (45+ columns):
- name, address, price, ... (not listed individually)
STANDARD (excluded):
- id, created_at, updated_at, deleted_at, slug
For all tables (no argument):
UNUSED COLUMNS SUMMARY
========================
Table | Total Cols | Unused | Migration Only | Possibly Unused
---------------------|------------|--------|----------------|----------------
properties | 47 | 3 | 1 | 1
clients | 28 | 0 | 0 | 2
operations | 12 | 1 | 0 | 0
schedules | 15 | 0 | 0 | 0
...
TOTAL UNUSED COLUMNS: 8 across 4 tables
Then list all unused columns with details.
fix or fix [table-name])For each confirmed unused column, generate a migration to drop it:
Schema::table('properties', function (Blueprint $table) {
$table->dropColumn(['legacy_portal_id', 'old_reference_code', 'temp_import_flag']);
});
php -l.Each column removal requires explicit user confirmation.
fix --dry-run)Show the migration content that would be generated for each table, without writing any files.
$model->getAttribute($dynamicField) or similar dynamic patterns cannot be detected statically. Note this in the report.toArray() or resources. Check for $hidden and $visible model properties.vendor/ if unsure.google_id, stripe_id may be used by external service integrations. Cross-check with service configuration.type, name, status will have many grep matches. Use context-aware matching to avoid false positives -- search for '{column_name}' (quoted) and ->column_name patterns rather than just the bare word.'column_name' in arrays, ->column_name for property access, "column_name" in query strings.