test
Test-driven development methodology (RED-GREEN-REFACTOR). Use when implementing features, fixing bugs, or changing behavior - write failing test first, then minimal code to pass.
What this skill does
# Test-Driven Development
Write the test first. Watch it fail. Write minimal code to pass.
**Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
---
## When to Use
**Always use for:**
- New features
- Bug fixes
- Behavior changes
- Refactoring
**Exceptions (confirm with user):**
- Throwaway prototypes
- Generated code
- Configuration files
**Workflow Integration:**
- **Multiple independent tasks from a scope?** → Use `implement` skill (it runs the scope execution pipeline)
- **Single implementation task?** → Use `implement` skill (it dispatches tester + implementer subagents)
- **This skill is for subagents** — tester subagents invoke this skill to follow TDD methodology. The orchestrator never invokes this skill directly to write tests.
---
## The Iron Law
```
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
```
Wrote code before the test? Delete it. Start over. No exceptions.
---
## Red-Green-Refactor Cycle
### 1. RED - Write Failing Test
Write one minimal test showing what should happen.
**Requirements:**
- One behavior per test
- Clear name describing behavior
- Real code (avoid mocks unless unavoidable)
### 2. Verify RED - Watch It Fail
**MANDATORY. Never skip.**
Run the test. Confirm:
- Test fails (not errors from typos)
- Failure message matches expectation
- Fails because feature is missing
**Test passes immediately?** You're testing existing behavior. Fix the test.
### 3. GREEN - Minimal Code
Write the simplest code to pass the test.
**DO:** Just enough to pass, simple implementation
**DON'T:** Add features, refactor other code, add configurability
### 4. Verify GREEN - Watch It Pass
**MANDATORY.**
Run the test. Confirm:
- Test passes
- Other tests still pass
- No errors or warnings
### 5. REFACTOR - Clean Up
Only after green:
- Remove duplication
- Improve names
- Extract helpers
Keep tests green. Don't add behavior.
### 6. Repeat
Next failing test for next behavior.
---
## Common Rationalizations
| Excuse | Reality |
|--------|---------|
| "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
| "I'll test after" | Tests passing immediately prove nothing. |
| "Already manually tested" | Ad-hoc is not systematic. No record, can't re-run. |
| "Deleting X hours is wasteful" | Sunk cost fallacy. Unverified code is debt. |
| "Need to explore first" | Fine. Throw away exploration, then TDD. |
| "Test hard to write" | Hard to test = hard to use. Simplify design. |
---
## Red Flags - Stop and Start Over
- Code written before test
- Test passes immediately
- Can't explain why test failed
- "Just this once" rationalization
- Keeping code "as reference"
**All of these mean:** Delete code. Start with TDD.
---
## Verification Checklist
Before marking work complete:
- [ ] Every new function has a test
- [ ] Watched each test fail before implementing
- [ ] Each test failed for expected reason
- [ ] Wrote minimal code to pass each test
- [ ] All tests pass
- [ ] No errors or warnings in output
---
## TDD Evidence Format (For Subagent Verification)
When implementing as a subagent, you MUST output this evidence block:
```yaml
tdd_evidence:
tests_written:
- name: "test_feature_x"
file: "tests/test_x.py"
red_output: "FAILED - [actual failure message]"
green_output: "PASSED - 1 passed in 0.05s"
implementation_files:
- path: "src/feature.py"
all_tests_pass: true
test_command: "pytest tests/test_x.py -v"
final_output: "[full test output]"
```
**This is REQUIRED for SubagentStop hook verification.**
---
## Domain Context
Domain skills inject specifics into this generic methodology:
- **code**: Language-specific test conventions via loqui, test frameworks
- **doc**: Documentation validation, link checking
When invoked via a domain skill, follow the domain-specific test guidance provided.
---
## Integration
**Use with:**
- `implement` (debug operation) - Write failing test to reproduce bug before fixing
- `implement` (execute operation) - Subagents follow TDD for each task
- `implement` (verify operation) - Run tests before claiming completion
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.