Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Tdd Workflow?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/karthikrshet-tdd-workflow)
---
name: tdd-workflow
description: Test-driven development loop (red, green, refactor). Use when adding behaviour or fixing a bug so the change is pinned by a test that failed first.
tags: [core, testing]
---
# Tdd Workflow
## When to use
- New functions, endpoints or components
- Bug fixes (write the reproducing test first)
- Refactoring code without tests (add characterisation tests first)
## Procedure
1. Write the smallest failing test for the next behaviour
2. Run it and read the failure; it must fail for the right reason
3. Write the minimum code to pass
4. Run the related suite
5. Refactor names and structure while green
6. Commit; repeat
## Example
```ts
it('rejects refunds larger than the captured amount', async () => {
await expect(refund(payment({ captured: 500 }), 600)).rejects.toThrow(RefundExceedsCapture);
});
```
## Checklist
- [ ] Test failed before the fix
- [ ] Test names describe behaviour
- [ ] No .only or skipped tests left
- [ ] Edge cases covered: empty, null, boundary, error
## Anti-patterns
- Writing tests after the code and calling it TDD
- Asserting on private internals
- Mocking the thing under test
- Huge tests with many reasons to fail