/filament-ai-skills:tdd-implementationfrom filament-ai-skills
Implements new features following the TDD Red-Green-Refactor cycle using Pest 4, Laravel 12, and Filament v5. Provides step-by-step protocol for writing failing tests, implementing minimum code, and running pint.
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 every time you implement a new feature, following the Red → Green → Refactor cycle. This skill works with Pest 4, Laravel 12 and Filament v5.
1. RED — Write a failing test
2. GREEN — Write the minimum code to make it pass
3. PINT — Run vendor/bin/pint --dirty
4. NEXT — Repeat for the next behaviour
Never skip the Red phase. Run the test before writing the implementation to confirm it fails for the right reason.
Before writing any test:
# Feature test (most tests should be feature tests)
php artisan make:test --pest Feature/{Domain}/{NameTest}
# Unit test (pure logic — no DB, no factories)
php artisan make:test --pest --unit Unit/{Domain}/{NameTest}
Fix double-nesting from artisan: if artisan creates tests/Feature/Feature/..., move the file manually.
test('model has correct mass-assignment protection', function (): void {
$model = new MyModel();
// Check per your project convention: $guarded or $fillable
expect($model->getGuarded())->toBe([]);
});
test('model has method doSomething', function (): void {
expect(method_exists(MyModel::class, 'doSomething'))->toBeTrue();
});
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
beforeEach(function (): void {
$this->user = User::factory()->create();
$this->actingAs($this->user);
// Multi-tenant: also set up tenant and Filament::setTenant($this->tenant)
});
test('action creates record', function (): void {
Livewire::test(ViewPage::class, ['record' => $this->record->id])
->callAction('myAction', ['field' => 'value'])
->assertNotified();
expect(MyModel::query()->where('field', 'value')->exists())->toBeTrue();
});
php artisan test --compact --filter=MyFeatureTest
Confirm tests fail with the expected error (class not found, method not found, assertion failure — not a PHP syntax error).
Create only what's needed to turn tests green:
php artisan test --compact --filter=MyFeatureTest
All tests must pass. If a test fails, fix the implementation — never change the test to fit wrong code.
vendor/bin/pint --dirty
Then run tests again to confirm pint didn't break anything.
php artisan test --compact tests/Feature/{Domain}/
Confirm no existing tests broke.
| File type | Location | Command |
|---|---|---|
| Model | app/Models/ | php artisan make:model ModelName --factory |
| Migration | database/migrations/ | php artisan make:migration create_table_name_table |
| Factory | database/factories/ | auto-created with --factory |
| Enum | app/Enum/ClassName.php | php artisan make:class App/Enum/ClassName → convert to enum |
| Filament Page | app/Filament/{Panel}/Pages/ | manual |
| Feature Test | tests/Feature/{Domain}/ | php artisan make:test --pest Feature/... |
| Unit Test | tests/Unit/{Domain}/ | php artisan make:test --pest --unit Unit/... |
Every new model must have:
declare(strict_types=1)final class/** @use HasFactory<XFactory> */$guarded = [] or $fillable = [...])casts() method (not $casts property) with explicit typesscopeName(Builder $query): BuilderLivewire::test(EditPage::class, ['record' => $record->id])
->assertFormFieldExists('field_name');
Livewire::test(ViewPage::class, ['record' => $record->id])
->assertActionExists('actionName')
->callAction('actionName', ['field' => 'value'])
->assertNotified();
Livewire::test(ViewPage::class, ['record' => $record->id])
->assertSee('Expected text');
RefreshDatabase on feature tests that use factoriesassertStatus(200) — use assertSuccessful()pint --test — run pint to fix directly# Single filter
php artisan test --compact --filter=TestName
# Full feature directory
php artisan test --compact tests/Feature/{Domain}/
# All tests
php artisan test --compact
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
tdd, test-driven-development, pest, laravel-testing, filament-testing
Other plugins' skills for the same job
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-detective