0087-laravel-tdd

Require failing Pest tests before implementing Laravel production code.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0087-laravel-tdd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 0087-laravel-tdd
Source: https://github.com/MrJmpl3/codex_____data_____configuration/tree/main/skills/0087-laravel-tdd
Command: npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0087-laravel-tdd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It reduces uncertainty and regressions by forcing you to define expected behavior with a failing test before writing Laravel code.

Core Features & Use Cases

  • Laravel-first TDD cycle: RED → verify RED → GREEN → verify GREEN → REFACTOR, iterated until the behavior is correct and maintainable.
  • Framework-specific test patterns: Feature tests, database verification with RefreshDatabase, authorization checks, and API testing with auth guards.
  • When to use: Apply to new Laravel features and bug fixes such as controllers, models, services, endpoints, validation, policies, queues, middleware, and Artisan commands.

Quick Start

Write a minimal Pest test for the Laravel feature you want to implement, run the test to confirm it fails, then write the smallest Laravel code needed to make it pass.

Frequently Asked Questions about 0087-laravel-tdd

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I start doing TDD in Laravel with Pest?

To start TDD in Laravel, write a minimal Pest test defining your expected behavior, run it to confirm it fails, then implement the smallest code to make it pass. This enforces a RED/GREEN verification cycle before feature implementation.

What's the best way to test Laravel API endpoints with auth guards?

The best way to test Laravel API endpoints with auth guards is using feature tests with the actingAs helper. This ensures your API testing validates authentication and authorization rules before the endpoint logic is fully implemented.

Does TDD work for fixing Laravel bugs in jobs and middleware?

Yes, TDD works for fixing Laravel bugs in jobs, middleware, and Artisan commands. You write a failing Pest test reproducing the bug, then patch the production code until the test passes, ensuring correct behavior without regressions.

How do I verify database state during Laravel feature testing?

You verify database state during Laravel feature testing by applying the RefreshDatabase trait and asserting database records match expectations. This ensures your tests confirm database mutations accurately within an isolated testing environment.

Can I test authorization policies using a Laravel TDD workflow?

Yes, you can test authorization policies using a Laravel TDD workflow. Define expected access control outcomes in a failing Pest test, then implement the policy logic to satisfy the test and verify authorized user actions.

Why should I write a failing test before implementing Laravel controllers?

Writing a failing test before implementing Laravel controllers reduces uncertainty and regressions. It forces you to define exact feature expectations upfront, ensuring the controller logic built afterward strictly satisfies verified behavioral requirements.