一键导入
test-driven-development
TDD workflow — write failing tests first, then implement, then refactor
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
TDD workflow — write failing tests first, then implement, then refactor
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | test-driven-development |
| description | TDD workflow — write failing tests first, then implement, then refactor |
Red → Green → Refactor workflow for writing tests before implementation. Use when building new features, fixing bugs, or when the user explicitly requests TDD. Complements 41_workflow_testing.md which covers test standards; this skill covers the process.
it('calculates order total including tax', function () {
$order = Order::factory()->create(['subtotal' => 10000]);
$total = (new CalculateOrderTotal)($order);
expect($total)->toBe(10800); // 8% tax
});
Then start the next cycle with the next requirement slice.
Break features into the smallest testable behaviors:
| ❌ Too broad | ✅ Thin slices |
|---|---|
| "Order processing works" | "Calculates subtotal from line items" |
| "Applies percentage discount" | |
| "Adds tax to discounted total" | |
| "Rejects orders with zero items" |
Tests should read as specifications:
// Backend (Pest)
it('rejects orders without a shipping address')
it('applies the highest applicable discount')
it('sends confirmation email after payment succeeds')
// Frontend (Vitest)
it('disables submit button while form is submitting')
it('shows validation errors below each invalid field')
it('redirects to dashboard after successful login')
For bugs, the cycle is slightly different:
TDD isn't always the best approach:
In these cases, write tests after but still write them.
41_workflow_testing.md.Structured brainstorming for exploring new features or solving complex problems
Scope, architect, and plan new tasks
Multi-angle code review before merging
Summarize the day's work and put it in context
Wrap up work — atomic commits and push to origin
Full end-to-end (E2E) testing skill utilizing the browser. Make sure to use this skill whenever the user asks to "test the app", "run end to end tests", "verify the UI", "check if the app works", or wants you to use the browser to interact with and test the application flow. This skill orchestrates creating a test plan, getting user approval, navigating the application using the browser, independently fixing obstacles, and generating a progressive test report.