tdd-workflow
Strict TDD state machine with Result types. 7-state workflow (PLANNING, RED, GREEN, REFACTOR, VERIFY, BLOCKED, VIOLATION). Every message MUST announce state. Integrates with fn(args, deps), vitest-mock-extended, and typed error handling.
What this skill does
# TDD Workflow
Strict test-driven development with Result types, dependency injection, and state machine governance.
## The Iron Law
```
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
```
Write code before the test? **Delete it. Start over.**
**No exceptions:**
- Don't keep it as "reference"
- Don't "adapt" it while writing tests
- Don't look at it
- Delete means delete
Implement fresh from tests. Period.
**Rationale:** Code written before tests is biased by implementation. TDD requires tests to drive design, not verify existing code.
## CRITICAL: STATE MACHINE GOVERNANCE
**EVERY SINGLE MESSAGE MUST START WITH YOUR CURRENT TDD STATE**
Format:
```
โช TDD: PLANNING
๐ด TDD: RED
๐ข TDD: GREEN
๐ต TDD: REFACTOR
๐ก TDD: VERIFY
โ ๏ธ TDD: BLOCKED
๐ฅ TDD: VIOLATION
```
**NOT JUST THE FIRST MESSAGE. EVERY. SINGLE. MESSAGE.**
When you read a file โ prefix with TDD state
When you run tests โ prefix with TDD state
When you explain results โ prefix with TDD state
When you ask a question โ prefix with TDD state
Example:
```
โช TDD: PLANNING
Writing test for getUser returning NOT_FOUND...
โช TDD: PLANNING
Running npm test to see it fail...
๐ด TDD: RED
Test fails correctly. Implementing minimum solution...
๐ข TDD: GREEN
Test passes. Checking if refactor needed...
```
## State Machine Diagram
```
user request
โ
โโโโโโโโโโโโ
โโโโโโ PLANNING โโโโโโ
โ โโโโโโโฌโโโโโ โ
โ โ โ
โ test fails โ
โ correctly โ
unclear โ โ โ blocker
โ โโโโโโโโโโโโ โ
โโโโโโ RED โ โ
โ โ โ
โ Test IS โ โ
โ failing โ โ
โโโโโโฌโโโโโโ โ
โ โ
test โ โ
passes โ โ
โ โ
โโโโโโโโโโโโ โ
โ GREEN โ โ
โ โ โ
โ Test IS โ โ
โ passing โ โ
โโโโโโฌโโโโโโโโโโโ
โ
refactoring โ
needed โ
โ
โโโโโโโโโโโโ
โโโโโโ REFACTOR โ
โ โ โ
โ โ Improve โ
โ โ design โ
โ โโโโโโฌโโโโโโ
โ โ
โ done โ
โ โ
โ โ
โ โโโโโโโโโโโโ
โ โ VERIFY โ
โ โ โ
โ โ Run full โ
fail โ โ suite + โ
โ โ lint + โ
โโโโโโ build โ
โโโโโโฌโโโโโโ
โ
pass โ
โ
โ
[COMPLETE]
```
## State: PLANNING
**Prefix:** `โช TDD: PLANNING`
**Purpose:** Write a failing test that proves the requirement.
### Pre-Conditions
- User has provided a task/requirement/bug report
- No other TDD cycle in progress
### The Delete Rule
If production code exists before the test:
1. **Delete it immediately**
2. Do not keep as "reference"
3. Do not "adapt" it
4. Start fresh from the test
**Rationale:** Code written before tests is biased by implementation. TDD requires tests to drive design, not verify existing code.
### Actions
1. Analyze requirement - what behavior needs testing?
2. Identify edge cases
3. Write test using fn(args, deps) pattern
4. Use vitest-mock-extended: `const deps = mock<GetUserDeps>()`
5. Run test (use Bash tool)
6. **VERIFY test fails correctly** (MANDATORY - see Verify RED below)
7. Show exact failure message verbatim
8. Justify why failure proves test is correct
### Verify RED - Watch It Fail
**MANDATORY. Never skip.**
```bash
npm test path/to/test.test.ts
```
Confirm:
- Test fails (not errors)
- Failure message is expected
- Fails because feature missing (not typos)
**Test passes?** You're testing existing behavior. Fix test.
**Test errors?** Fix error, re-run until it fails correctly.
### Post-Conditions (ALL required before transition)
- [ ] Test written with proper deps mocking
- [ ] Test executed
- [ ] Test FAILED correctly (not setup error) - **VERIFIED by watching it fail**
- [ ] Failure message shown verbatim
- [ ] Failure is "meaningful" (assertion failure, not import error)
### Validation Before Transition
```
Pre-transition validation:
โ Test written: [yes/no]
โ Test executed: [yes/no]
โ Test failed correctly: [yes - output above]
โ Meaningful failure: [yes - justification]
Transitioning to RED.
```
### Transitions
- PLANNING โ RED (test fails correctly)
- PLANNING โ BLOCKED (cannot write valid test)
## State: RED
**Prefix:** `๐ด TDD: RED`
**Purpose:** Test IS failing. Implement ONLY what the error message demands.
### Pre-Conditions
- Test written and executed
- Test IS FAILING correctly
- Failure is meaningful (not setup/syntax error)
### The Hardcode Rule
Before implementing, announce:
```
Minimal implementation check:
- Error demands: [what the error literally says]
- Could hardcoded value work? [yes/no]
- If yes: [what hardcoded value]
- If no: [why real logic is required]
```
| Error Says | Do This |
|-----------|---------|
| `expected err('NOT_FOUND')` | `return err('NOT_FOUND')` |
| `expected ok(user)` | `return ok(mockUser)` |
| `expected count: 0` | `return { count: 0 }` |
Only add logic when tests FORCE you to.
### Actions
1. Read error message - what does it literally ask for?
2. Announce minimal implementation check
3. Implement ONLY what error demands (hardcode if possible)
4. Run test
5. **VERIFY test PASSES** (MANDATORY - see Verify GREEN below)
6. Run typecheck (`npm run typecheck`)
7. Run lint (`npm run lint`)
8. Show all output verbatim
9. Transition to GREEN
### Verify GREEN - Watch It Pass
**MANDATORY. Never skip.**
```bash
npm test path/to/test.test.ts
```
Confirm:
- Test passes
- Other tests still pass
- Output pristine (no errors, warnings)
**Test fails?** Fix code, not test.
**Other tests fail?** Fix now.
### Post-Conditions (ALL required)
- [ ] Implemented ONLY what error demanded
- [ ] Test executed and PASSES
- [ ] Code compiles (no TypeScript errors)
- [ ] Code lints (no ESLint errors)
- [ ] All output shown verbatim
### Validation Before Transition
```
Post-condition validation:
โ Test PASSES: [yes - output above]
โ Code compiles: [yes - output above]
โ Code lints: [yes - output above]
โ Implementation minimal: [justification]
Transitioning to GREEN.
```
### Critical Rules
- NEVER transition to GREEN without test PASS + compile + lint
- NEVER anticipate future errors - address THIS error only
- NEVER change test to match implementation - fix the code
### Transitions
- RED โ GREEN (test passes, code compiles, code lints)
- RED โ BLOCKED (cannot make test pass)
- RED โ PLANNING (test failure reveals misunderstood requirement)
## State: GREEN
**Prefix:** `๐ข TDD: GREEN`
**Purpose:** Test IS passing. Assess code quality and decide next step.
### Pre-Conditions
- Test exists and PASSES
- Code compiles and lints
- Implementation is minimal
### Actions
1. Review implementation against patterns:
| Pattern | Check |
|---------|-------|
| fn(args, deps) | Is deps type explicit and minimal? |
| Result types | Are all error cases typed? |
| Validation | Is Zod at boundary only? |
| Naming | Domain-specific, not generic? |
2. Decide: Does code need refactoring?
3. If YES โ REFACTOR
4. If NO โ VERIFY
### Post-Conditions
- [ ] Test IS PASSING
- [ ] Code quality assessed
- [ ] Decision made: refactor or verify
### Transitions
- GREEN โ REFACTOR (improvements needed)
- GREEN โ VERIFY (code is clean)
- GREEN โ RED (test starts failing - regression)
## State: REFACTOR
**Prefix:** `๐ต TDD: REFACTOR`
**Purpose:** Tests ARE passing. Improve design while keeping green.
### Pre-Conditions
- Tests ARE 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.