$ recombobulate _
home / tips / write-tests-first-with-tdd-workflow
write-tests-first-with-tdd-workflow

Claude Code is excellent at TDD. Start by describing what you want to test:

"Write a Pest test for a VoteButtons Livewire component that verifies:
- authenticated users can upvote
- clicking upvote twice toggles it off
- guests are redirected to login"

Claude will generate the test file:

test('authenticated user can upvote a tip', function () {
    $user = User::factory()->create();
    $tip = Tip::factory()->published()->create();

    $this->actingAs($user);

    Livewire::test('vote-buttons', ['tip' => $tip])
        ->call('upvote');

    expect($tip->fresh()->score)->toBe(1);
});

test('guest is redirected when trying to vote', function () {
    $tip = Tip::factory()->published()->create();

    Livewire::test('vote-buttons', ['tip' => $tip])
        ->call('upvote')
        ->assertRedirect(route('login'));
});

Run the tests to confirm they fail:

php artisan test --compact --filter=VoteTest

Then tell Claude to implement the component to make the tests pass. This workflow catches edge cases early and gives you confidence in the implementation.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago