
Laravel Tdd
- 346 installs
- 42 repo stars
- Updated April 19, 2026
- iserter/laravel-claude-agents
laravel-tdd is a Laravel agent skill that enforces Pest PHP test-driven development—write failing tests first, implement minimal code, then refactor controllers, models, and API endpoints.
About
laravel-tdd is an agent skill from iserter/laravel-claude-agents that adapts classic test-driven development to Laravel applications using Pest PHP and Laravel's built-in testing helpers. It guides the red-green-refactor loop: write one minimal failing feature or unit test, run php artisan test to confirm failure, implement the smallest Laravel code to pass, then refactor into services, policies, and query scopes. Coverage spans controllers, Eloquent models, form validation, authorization policies, queue jobs, Artisan commands, middleware, database migrations, and HTTP API endpoints. The skill mandates RefreshDatabase, model factories, actingAs for auth tests, and a verification checklist covering migration tests, relationship assertions, validation rules, authorization, and database state. Developers reach for laravel-tdd when adding Laravel features or bugfixes and want tests written before production code—not for throwaway prototypes or cosmetic view-only edits.
- Red-green-refactor workflow for Laravel features
- PHPUnit/Pest patterns for HTTP, models, and services
- Factories, fakes, and database isolation practices
- Covers policies, form requests, and API contracts
- Keeps tests aligned with Laravel conventions and folders
Laravel Tdd by the numbers
- 346 all-time installs (skills.sh)
- +4 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #28 of 65 PHP & Laravel skills by installs in the Skillselion catalog
- Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/iserter/laravel-claude-agents --skill laravel-tddAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 346 |
|---|---|
| repo stars | ★ 42 |
| Last updated | April 19, 2026 |
| Repository | iserter/laravel-claude-agents ↗ |
How do you do TDD in Laravel with Pest?
Implement Laravel features test-first with PHPUnit/Pest—red-green-refactor loops for controllers, services, models, policies, and HTTP/API behavior.
Who is it for?
Laravel backend developers enforcing red-green-refactor cycles with Pest PHP on features, bugfixes, and API endpoints.
Skip if: Throwaway Laravel prototypes, pure configuration edits, or cosmetic Blade view tweaks that need no behavioral tests.
When should I use this skill?
User implements a Laravel feature or bugfix and should write Pest tests before controller, model, or policy code.
What you get
Passing Pest PHP test suite, factory-backed feature tests, and verified database and authorization coverage.
- Pest feature and unit tests
- Minimal passing Laravel implementation
- Verified test checklist results
By the numbers
- Verification checklist covers 9 Laravel testing areas including auth and DB state
- Applies to 9 Laravel artifact types from controllers through middleware
Files
Test-Driven Development for Laravel
Overview
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.
When to Use
Always for Laravel:
- New features (controllers, models, services)
- Bug fixes
- API endpoints
- Database migrations and models
- Form validation
- Authorization policies
- Queue jobs
- Artisan commands
- Middleware
Exceptions (ask your human partner):
- Throwaway prototypes
- Configuration files
- View-only changes (no logic)
The Laravel TDD Cycle
RED → Verify RED → GREEN → Verify GREEN → REFACTOR → RepeatRED - Write Failing Test
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);
});Verify RED - Watch It Fail
php artisan test --filter=authenticated_user_can_create_postGREEN - Minimal Laravel Code
Write simplest Laravel code to pass the test.
Verify GREEN - Watch It Pass
php artisan testREFACTOR - Clean Up Laravel Code
After green only:
- Extract services for complex logic
- Create policies for authorization
- Add query scopes for reusability
- Use events for side effects
Laravel-Specific Test Patterns
Database Testing
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']);
});Authorization Testing
test('user cannot delete others posts', function () {
$user = User::factory()->create();
$post = Post::factory()->create();
$this->actingAs($user)
->delete("/posts/{$post->id}")
->assertForbidden();
});API Testing
test('creates post via API', function () {
$user = User::factory()->create();
$this->actingAs($user, 'sanctum')
->postJson('/api/posts', ['title' => 'API Post', 'content' => 'Content'])
->assertCreated();
});Verification Checklist
- [ ] Migration test passes
- [ ] Model relationships tested
- [ ] Controller actions tested
- [ ] Validation rules tested
- [ ] Authorization tested
- [ ] Database state verified
- [ ] All tests passing
- [ ] Used RefreshDatabase
- [ ] Used factories
Remember
Every Laravel feature → Test exists and failed first
Otherwise → Not TDDRelated skills
How it compares
Pick laravel-tdd over generic PHPUnit skills when enforcing strict test-first Pest workflows with Laravel factories, policies, and RefreshDatabase conventions.
FAQ
Which test runner does laravel-tdd use?
laravel-tdd uses Pest PHP on top of Laravel's testing stack. Developers run php artisan test or filtered Pest commands to confirm red failure before writing minimal passing Laravel code.
What Laravel layers does laravel-tdd cover?
laravel-tdd covers controllers, Eloquent models, migrations, form validation, authorization policies, queue jobs, Artisan commands, middleware, and HTTP API endpoints with factory and RefreshDatabase patterns.