agentsclimarketplace

Tdd laravel

Skill ceilidhboy/skills/skills/tdd-laravel

Agent skills for Laravel and PHP development. Installable via npx skills@latest add ceilidhboy/skills

Install
npx -y skills add ceilidhboy/skills --skill tdd-laravel

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Test-driven development with red-green-refactor loop using Pest PHP. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, asks for test-first development, or needs guidance on writing testable code with Pest.

SKILL.md

10.8 KB, as published. Nobody here has run it

Test-Driven Development

πŸ›‘ CRITICAL: The Refactor Phase Is Mandatory

After EVERY red-green cycle, you MUST:

  1. Complete the refactor checklist (see refactor-checklist.md)
  2. Propose refactors to the user with specific code examples
  3. Get explicit user approval before making any changes
  4. Execute approved refactors and verify tests still pass
  5. Display the completed checklist to the user before proceeding

Do NOT skip refactoring. Do NOT proceed to the next test without user approval of refactoring.

The TDD Mantras are:

  • πŸ•‰οΈ RED β†’ GREEN β†’ REFACTOR (with user approval) β†’ RED β†’ GREEN β†’ REFACTOR (with user approval) β†’ ...
  • πŸ›‘ Production code may not be written or modified unless we have a RED test and are trying to make it GREEN.

When activating the TDD skill, you MUST state the above TDD mantras to demonstrate that you understand the red-green-refactor cycle with mandatory user approval of refactoring along with requiring a red test before writing or modifying any production code.


πŸ›‘ CRITICAL: Pre-Action Verbalization Requirement

Before writing ANY test, you MUST verbalize the following statement:

"I am writing ONE test for [specific behavior]. I will not write or modify production code unless it's to make a failing red test pass (green). I will write the simplest code possible. I will present a checkpoint before proceeding to any next step."

This verbalization must:

  1. State specifically what behavior this ONE test covers
  2. Explicitly acknowledge the rule: no production code except to make a RED test GREEN
  3. Commit to writing the simplest code
  4. Commit to presenting checkpoints

You must NOT write more than one test before getting user approval to proceed.


Checkpoints and User Approval

⚠️ CRITICAL: You MUST use the question tool for all checkpoints. Do not output plain text options.

Present checkpoints using the question tool with multiple: false. The user clicks or presses a number to select. Never ask the user to type an answer when they can select from options.

There are three types of checkpoints in the TDD cycle:

1. RED Checkpoint (After writing test)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CHECKPOINT - TDD Cycle #[N] RED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
File:  [path]:[line]  (current test)
Test:  [test name]
Phase: RED
Result: βœ— Test fails (as expected)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Options after RED:

  1. "Write the simplest code to make the test pass" - Proceed to GREEN phase (write minimal code only)
  2. "Stop and discuss" - User wants to review/refine the test before proceeding
  3. "Type your own answer" - User has custom feedback

2. GREEN Checkpoint (After test passes)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CHECKPOINT - TDD Cycle #[N] GREEN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
File:  [path]:[line]  (current test)
Test:  [test name]
Phase: GREEN
Code:  [one-line code summary]
Result: βœ“ Test passes
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Options after GREEN:

  1. "Next test" - Proceed to RED phase for next test
  2. "Refactor" - Enter REFACTOR phase
  3. "Stop and discuss" - Pause to discuss

3. REFACTOR Checkpoint (After refactor)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CHECKPOINT - TDD Cycle #[N] REFACTOR
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
File:  [path]:[line]  (current test)
Phase: REFACTOR
Changes: [summary of refactor]
Result: βœ“ Tests still pass
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Options after REFACTOR:

  1. "Continue refactoring" - More refactoring, stay in REFACTOR phase
  2. "Next test" - Proceed to RED phase for next test
  3. "Stop and discuss" - Pause to discuss

πŸ›‘ ABSOLUTE RULE: Stop Points After Every Phase

After completing RED, GREEN, or REFACTOR phase, you MUST stop and use the question tool to get user approval before any tool use.

Do NOT:

  • Write any code
  • Run any commands
  • Make any changes
  • Proceed to next phase

until the user has clicked an option and you have received their response.

Do NOT:

  • Write any code
  • Run any commands
  • Make any changes
  • Proceed to next phase

until the user has clicked an option and you have received their response.


Quick Start

TDD follows the red-green-refactor cycle:

  1. RED: Write a test that fails
  2. GREEN: Write the simplest code that passes (not optimal code)
  3. REFACTOR: Clean up, extract duplication, apply patterns (with user approval)
  4. Repeat for next behavior

Triangulation: How Code Evolves to Perfection

The critical insight: Don't try to write perfect code in the GREEN phase. Write the simplest thing that works, then let multiple tests guide you to the best solution.

The Process

  1. First test (degenerate): Write the simplest test. Make it pass with hardcoded values if needed.
  2. Second test (different case): Now you can't hardcode - write actual logic (still simple, may be oversimplified).
  3. Third test (more complex): Oversimplified logic breaks. Now you write more general, correct code.
  4. Refactor after each test: With multiple tests as a safety net, improve code quality and apply SOLID principles.

Why This Works

Each new test triangulates you toward the best solution. The code naturally converges on the cleanest, most general implementation because:

  • You're always writing the simplest thing that works
  • Multiple tests prevent overengineering (you only add complexity when forced by a failing test)
  • Refactoring is safe (tests catch regressions)

Without TDD: You anticipate all cases upfront and write overly complex code. With TDD: Tests guide you to the right level of complexity naturally.

Core Principles

  • Tests verify behavior, not implementation β€” See philosophy.md
  • Vertical slices, not horizontal β€” See anti-patterns.md
  • One test at a time β€” Each test responds to what you learned from the previous cycle
  • Minimal code to pass β€” Don't anticipate future tests
  • Deep modules with real dependencies β€” Test through real interfaces, not mocks of internal parts β€” See deep-modules.md
  • Integration-style testing β€” Exercise real code paths through public APIs, not implementation details

⚠️ CRITICAL: Feature Tests Required for Laravel Code

Any test that uses Eloquent models, facades, or the Laravel application container MUST be a Feature test, not a Unit test.

Unit tests do not load the Laravel application. If your test uses Model::factory(), app(), Mail::, Storage::, or any other Laravel feature, it must be in tests/Feature/, not tests/Unit/.

Degenerate Tests: Your Safety Net

Always write the degenerate (negative) test first before the positive test.

Why?

The degenerate test becomes your safety net that catches accidental behavior. Once it's GREEN, it will immediately go RED if you accidentally implement the behavior you're trying to avoid.

Example

When implementing "fire event when PDF fields change":

  1. First (degenerate): Write test "event does NOT fire when non-PDF fields change" β†’ GREEN (no code yet)
  2. Second (positive): Write test "event fires when PDF fields change" β†’ RED (event not implemented)
  3. Implement: Fire event (simplest thing) β†’ First test goes RED (oops, firing for all changes)
  4. Refine: Only fire for PDF-relevant fields β†’ Both tests GREEN

The degenerate test caught your mistake in step 3 and guided you to the correct implementation.

Default Testing Pattern: Deep Modules with Real Dependencies

This project's default approach is integration-style testing with real dependencies:

  • Create real data using factories (e.g., Property::factory()->create())
  • Use real dependencies - Inject actual actions and services, not mocks
  • Test observable behavior - Verify what the system does through its public interface
  • Avoid mocking internal collaborators - Only mock at system boundaries (external APIs, time, randomness)

Why this approach?

  • Catches real integration issues that mocks would hide
  • Tests are simpler to write (no complex mock setup)
  • Tests survive refactoring because they test behavior, not implementation
  • More confidence in the code working end-to-end

When to mock:

  • External APIs (payment gateways, email services, etc.)
  • Time/randomness (use now(), fake())
  • File system operations (use Storage::fake())
  • Never mock your own classes or internal collaborators

See deep-modules.md and mocking.md for detailed guidance.

The Workflow

See workflow.md for detailed step-by-step guidance on:

  • Planning before you code
  • Writing tracer bullets
  • The incremental loop
  • When and how to refactor

Important: Single Task Responsibility

See single-task-responsibility skill.

While implementing a task, if you discover you're addressing multiple distinct responsibilities, STOP immediately and consult the user. Each task should have a single, well-defined responsibility.

Refactor Checklist

See refactor-checklist.md for the mandatory checklist you must complete after every GREEN phase.

You MUST display the completed checklist to the user with all items marked complete before proceeding to the next task.

Reference Materials

Gives 1 of the 12 instructions most tdd skills give

Counted across 439 of the 443 authors here whose files we hold, read 2026-08-06

  • write minimal code to pass the testin 302 of 439, across 218 files
  • write a failing test firsthere, and in 176 of 439, across 112 files
  • refactor code only after tests passin 171 of 439, across 101 files
  • watch the test fail before writing codein 142 of 439, across 93 files
  • test one behavior per testin 106 of 439, across 44 files
  • refactor code while keeping tests greenin 99 of 439, across 86 files
  • delete code written before testsin 98 of 439, across 54 files
  • run tests after each refactor stepin 85 of 439, across 54 files
  • Use real code instead of mocks unless unavoidablein 64 of 439, across 21 files
  • confirm the test fails for the right reasonin 64 of 439, across 60 files
  • reproduce bugs with a test before fixingin 53 of 439, across 36 files
  • write tests before implementationin 48 of 439, across 39 files

Said here and by no other author read

  • use the question tool for all checkpoints
  • stop after every red green or refactor phase
  • write the degenerate negative test first
  • write feature tests for laravel code
  • state the TDD mantras upon activation
  • verbalize intent before writing any test

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.