/filament-ai-skills:null-safe-checkfrom filament-ai-skills
Verifies and fixes null-safe issues in PHP files before a commit. Scans for dangerous patterns like ->relation->property and suggests ?-> replacements, prioritizing Eloquent relationships, closures, and decoded JSON.
Ships in filament-ai-skills. 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.
Activate this skill before every commit or when an error like this occurs:
ErrorException: Attempt to read property "X" on nullCall to a member function X() on nullAccess to an undefined property ... ::$X# Staged files (for pre-commit)
git diff --name-only --cached | grep '\.php$'
# Modified files (working tree)
git diff --name-only | grep '\.php$'
Use Grep to find these patterns in the PHP files:
| Dangerous pattern | Safe pattern |
|---|---|
->relation->property | ->relation?->property |
->relation->method() | ->relation?->method() |
fn ($x) => $x->rel->prop | fn ($x) => $x->rel?->prop |
$group->first()->rel->prop | $group->first()->rel?->prop ?? 'default' |
filter(fn ($i) => $i->rel->prop) | filter(fn ($i) => $i->rel?->prop) |
Search regex:
->[a-zA-Z_]+->
Prioritize these contexts — most prone to null:
nullable() in migration, HasOne, BelongsTo)filter(), map(), groupBy() over collections$group->first()->relation->property — first item in group may have null relationgetStateUsing(fn ($record) => $record->relation->property) in table columns// ❌ Before
$record->author->name
$record->category->label
$record->vehicle->plate
// ✅ After
$record->author?->name
$record->category?->label
$record->vehicle?->plate
// ❌ Before
$group->first()->order->customer->name
// ✅ After — null-safe at each potentially null level
$group->first()->order?->customer?->name ?? 'N/A'
// ❌ Before
->filter(fn ($post) => $post->author->active && $post->author->email)
// ✅ After
->filter(fn ($post) => $post->author?->active && $post->author?->email)
// ❌ Before
->getStateUsing(fn ($record) => $record->order->status === 'paid' ? $record->amount : null)
// ✅ After
->getStateUsing(fn ($record) => $record->order?->status === 'paid' ? $record->amount : null)
// ⚠️ PHPStan warns: "Using nullsafe property access on non-nullable type"
// If the property is NOT NULL in the database and the relationship is mandatory,
// do not use ?-> — use -> directly.
// Check the migration to determine if the FK is nullable:
// $table->foreignId('author_id')->nullable() → use ?->
// $table->foreignId('author_id') → use ->
./vendor/bin/phpstan analyse --level=5 {file}
vendor/bin/pint --dirty
1. git diff --name-only --cached | grep '\.php$'
2. For each file:
a. Grep for pattern `->[a-zA-Z_]+->` (non-null-safe chains)
b. Analyze context of each match
c. Check migration if FK is nullable
d. Fix with Edit tool
3. vendor/bin/pint --dirty
4. php artisan test --compact (optional, if relevant tests exist)
5. Confirm no more ErrorException from null
// ❌ Causes ErrorException when item does not have 'author'
$posts->filter(fn ($post) => $post->author->active)
// ✅
$posts->filter(fn ($post) => $post->author?->active)
// ❌
->getStateUsing(fn ($record) => $record->order->type === 'sale' ? $record->amount : null)
// ✅
->getStateUsing(fn ($record) => $record->order?->type === 'sale' ? $record->amount : null)
// ❌
'author_name' => $group->first()->post->author->name,
// ✅
'author_name' => $group->first()->post?->author?->name ?? 'N/A',
?-> blindly everywhere — PHPStan will warn about unnecessary null-safe?-> on relations defined as NOT NULL in the migration?-> from relations that are already correctly typed?? null — it is redundant; simply omit the ??What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub felipearnold/filament-ai-skills --plugin filament-ai-skills18 skills in this plugin
/deep-code-reviewAnálise técnica profunda de código PHP/Laravel já implementado (não staged). 3 dimensões: segurança (OWASP), qualidade (SOLID, CC, DRY), padrões (PHP 8.4, Laravel 12, Filament v5). Foco em "como melhorar" — refactor, design, arquitetura. Gera relatório com scores e plano de ação. **Use pre-commit-review pra checklist rápido antes de commit.** Ativa: analisar implementação em profundidade, revisar feature pronta, audit de segurança, refatorar código existente, melhorar arquitetura, review profundo, análise completa, avaliar qualidade de feature, scoring de código./eloquent-query-checkVerifies and fixes direct static calls on Eloquent models, ensuring they always go through ::query() before methods like find, where, create, all, etc. Activate when: query(), Model::find, Model::create, Model::where, Model::all, eloquent query, static model call, model without query, fix model./error-detectiveOther plugins' skills for the same job