Guides Test-Driven Development for Laravel apps using Pest PHP: write failing tests first for features, bug fixes, controllers, models, APIs, then minimal code to pass and refactor.
How this skill is triggered — by the user, by Claude, or both
Slash command
/laravel-claude-agents:laravel-tddThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Write the test first. Watch it fail. Write minimal code to pass.
Write the test first. Watch it fail. Write minimal code to pass.
This skill adapts TDD principles specifically for Laravel applications using Pest PHP, Laravel's testing features, and framework-specific patterns.
Always for Laravel:
Exceptions (ask your human partner):
RED → Verify RED → GREEN → Verify GREEN → REFACTOR → Repeat
Write one minimal test showing what the Laravel feature should do.
Feature Test Example:
<?php
use App\Models\User;
use App\Models\Post;
test('authenticated user can create post', function () {
$user = User::factory()->create();
$this->actingAs($user)
->post('/posts', [
'title' => 'My First Post',
'content' => 'Post content here',
])
->assertRedirect('/posts');
expect(Post::where('title', 'My First Post')->exists())->toBeTrue();
expect(Post::first()->user_id)->toBe($user->id);
});
php artisan test --filter=authenticated_user_can_create_post
Write simplest Laravel code to pass the test.
php artisan test
After green only:
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('creates post in database', function () {
$user = User::factory()->create();
$this->actingAs($user)
->post('/posts', ['title' => 'Test', 'content' => 'Content']);
$this->assertDatabaseHas('posts', ['title' => 'Test']);
});
test('user cannot delete others posts', function () {
$user = User::factory()->create();
$post = Post::factory()->create();
$this->actingAs($user)
->delete("/posts/{$post->id}")
->assertForbidden();
});
test('creates post via API', function () {
$user = User::factory()->create();
$this->actingAs($user, 'sanctum')
->postJson('/api/posts', ['title' => 'API Post', 'content' => 'Content'])
->assertCreated();
});
Every Laravel feature → Test exists and failed first
Otherwise → Not TDD
npx claudepluginhub iserter/laravel-claude-agents --plugin laravel-claude-agentsGuides Laravel TDD with Pest/PHPUnit: RED-GREEN-REFACTOR cycle using model factories, HTTP feature tests, parallel runners; verify failures before implementation.
Write tests with Pest 3/PHPUnit, feature tests, unit tests, mocking, fakes, and factories. Use when testing controllers, services, models, or implementing TDD.
Guides Laravel TDD with PHPUnit and Pest, covering factories, database testing, fakes, and 80%+ coverage targets. Activates for new features, bug fixes, or refactoring in Laravel apps.