laravel-tdd
This skill guides you through TDD methodology tailored for Laravel development, using Pest PHP and Laravel's testing tools. Learn the red-green-refactor cycle with Laravel-specific patterns for controllers, models, authorization, APIs, and database operations. Apply TDD consistently across features and bugfixes to build reliable Laravel applications.
Laravel-TDD teaches test-driven development practices tailored to Laravel applications using Pest PHP.
AI-generated summary based on this skill's SKILL.md
Install
iSerter/laravel-claude-agents/laravel-tdd · repository language: PHP
git clone https://github.com/iSerter/laravel-claude-agents
cp -r laravel-claude-agents/skills/laravel-tdd ~/.claude/skills/laravel-tddnpx skillfed install iSerter/laravel-claude-agents/laravel-tddFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What is laravel-tdd and how does it help with testing?
laravel-tdd is a skill that guides you through Test-Driven Development methodology tailored for Laravel applications. It teaches you the red-green-refactor cycle using Pest PHP and Laravel's testing tools, helping you write reliable code by testing first. You'll learn patterns for testing controllers, models, APIs, authorization, and database operations to build robust Laravel applications.
How do I write tests for Laravel using Pest PHP?
laravel-tdd covers writing and structuring tests using Pest PHP in Laravel. Pest provides a clean, expressive syntax for testing Laravel features. The skill teaches you how to organize unit and feature tests, use Laravel's testing utilities, set up test databases, and leverage Pest's fluent API to write clear, maintainable tests for your Laravel codebase.
What is the red-green-refactor cycle and how does it apply to Laravel?
laravel-tdd explains the red-green-refactor cycle—a core TDD practice where you write a failing test (red), write minimal code to pass it (green), then improve the code (refactor). Applied to Laravel, this workflow ensures you build features incrementally with test coverage, reducing bugs and making refactoring safer across controllers, models, and business logic.
How to write tests for Laravel controllers and APIs?
laravel-tdd teaches testing Laravel features like controllers, models, and APIs. You'll learn to write feature tests that simulate HTTP requests, assert responses, validate JSON structures, and test authorization. The skill covers testing API endpoints, controller logic, middleware, and error handling using Laravel's testing helpers and Pest's expressive assertions.
What Laravel TDD workflow should I follow for development?
laravel-tdd guides you through a consistent TDD workflow: write a failing test first, implement the feature to pass it, then refactor. This test-first approach applies to new features, bugfixes, and database operations. By following this cycle throughout your Laravel development, you ensure comprehensive test coverage and maintainable, reliable code from the start.
Does laravel-tdd cover testing models and database operations?
Yes, laravel-tdd includes Laravel model testing and database testing patterns. You'll learn to test model relationships, scopes, mutators, and validation. The skill covers using test factories, seeders, and database transactions to isolate tests, ensuring your database operations work correctly while keeping tests fast and independent.
SKILL.md
rendered from the published skill — quoted content, verbatim
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 <?php
use App\Models\User; use App\Models\Post;
test('authenticated user can create post', function () {
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
skills/laravel-tdd/SKILL.md