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.
Log in to leave a comment.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
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.