laravel-tdd by iserter/laravel-claude-agents
npx skills add https://github.com/iserter/laravel-claude-agents --skill laravel-tdd先写测试。观察测试失败。编写最少代码使其通过。
本技能专门针对使用 Pest PHP、Laravel 测试功能以及框架特定模式的 Laravel 应用程序,调整了 TDD 原则。
始终适用于 Laravel:
例外情况(请咨询您的人类伙伴):
RED → 验证 RED → GREEN → 验证 GREEN → REFACTOR → 重复
编写一个最小化的测试,展示 Laravel 功能应该做什么。
功能测试示例:
<?php
use App\Models\User;
use App\Models\Post;
test('authenticated user can create post', function () {
$user = User::factory()->create();
$this->actingAs($user)
->post('/posts', [
'title' => 'My First Post',
'content' => 'Post content here',
])
->assertRedirect('/posts');
expect(Post::where('title', 'My First Post')->exists())->toBeTrue();
expect(Post::first()->user_id)->toBe($user->id);
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
php artisan test --filter=authenticated_user_can_create_post
编写最简单的 Laravel 代码以使测试通过。
php artisan test
仅在绿色阶段之后:
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('creates post in database', function () {
$user = User::factory()->create();
$this->actingAs($user)
->post('/posts', ['title' => 'Test', 'content' => 'Content']);
$this->assertDatabaseHas('posts', ['title' => 'Test']);
});
test('user cannot delete others posts', function () {
$user = User::factory()->create();
$post = Post::factory()->create();
$this->actingAs($user)
->delete("/posts/{$post->id}")
->assertForbidden();
});
test('creates post via API', function () {
$user = User::factory()->create();
$this->actingAs($user, 'sanctum')
->postJson('/api/posts', ['title' => 'API Post', 'content' => 'Content'])
->assertCreated();
});
Every Laravel feature → Test exists and failed first
Otherwise → Not TDD
每周安装次数
219
代码仓库
GitHub 星标数
29
首次出现
Jan 22, 2026
安全审计
安装于
codex193
opencode192
gemini-cli179
github-copilot173
cursor157
claude-code152
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.
Always for Laravel:
Exceptions (ask your human partner):
RED → Verify RED → GREEN → Verify GREEN → REFACTOR → Repeat
Write one minimal test showing what the Laravel feature should do.
Feature Test Example:
<?php
use App\Models\User;
use App\Models\Post;
test('authenticated user can create post', function () {
$user = User::factory()->create();
$this->actingAs($user)
->post('/posts', [
'title' => 'My First Post',
'content' => 'Post content here',
])
->assertRedirect('/posts');
expect(Post::where('title', 'My First Post')->exists())->toBeTrue();
expect(Post::first()->user_id)->toBe($user->id);
});
php artisan test --filter=authenticated_user_can_create_post
Write simplest Laravel code to pass the test.
php artisan test
After green only:
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('creates post in database', function () {
$user = User::factory()->create();
$this->actingAs($user)
->post('/posts', ['title' => 'Test', 'content' => 'Content']);
$this->assertDatabaseHas('posts', ['title' => 'Test']);
});
test('user cannot delete others posts', function () {
$user = User::factory()->create();
$post = Post::factory()->create();
$this->actingAs($user)
->delete("/posts/{$post->id}")
->assertForbidden();
});
test('creates post via API', function () {
$user = User::factory()->create();
$this->actingAs($user, 'sanctum')
->postJson('/api/posts', ['title' => 'API Post', 'content' => 'Content'])
->assertCreated();
});
Every Laravel feature → Test exists and failed first
Otherwise → Not TDD
Weekly Installs
219
Repository
GitHub Stars
29
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex193
opencode192
gemini-cli179
github-copilot173
cursor157
claude-code152
Spring Boot工程师技能指南:微服务架构、安全加固与云原生开发实战
4,200 周安装