laravel-tdd

iserter/laravel-claude-agents · updated Apr 25, 2026

$npx skills add https://github.com/iserter/laravel-claude-agents --skill laravel-tdd
0 commentsdiscussion
summary

Write the test first. Watch it fail. Write minimal code to pass.

skill.md

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 → Repeat

RED - 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_post

GREEN - Minimal Laravel Code

Write simplest Laravel code to pass the test.

Verify GREEN - Watch It Pass

php artisan test

REFACTOR - 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 TDD

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.758 reviews
  • Aditi Choi· Dec 24, 2024

    Keeps context tight: laravel-tdd is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Isabella Rao· Dec 24, 2024

    We added laravel-tdd from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Chen Ndlovu· Dec 24, 2024

    laravel-tdd reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Ganesh Mohane· Dec 20, 2024

    laravel-tdd has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Noor Torres· Dec 20, 2024

    laravel-tdd is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Aanya Park· Dec 16, 2024

    Registry listing for laravel-tdd matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Ama Chawla· Nov 15, 2024

    Registry listing for laravel-tdd matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Alexander Zhang· Nov 15, 2024

    laravel-tdd fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Nikhil Ghosh· Nov 15, 2024

    laravel-tdd has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Sakshi Patil· Nov 11, 2024

    laravel-tdd reduced setup friction for our internal harness; good balance of opinion and flexibility.

showing 1-10 of 58

1 / 6