/laraclaude:lc:unused-columns [analyze | fix | fix --dry-run | table-name | fix table-name]from laraclaude
Detects database columns defined in migrations or live schema that are never referenced in application code, helping identify cleanup candidates.
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.
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.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: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./lc:cache-opportunitiesDetect repeated queries and computations that should be cached.Other plugins' skills for the same job