一键导入
tdd-green
Execute GREEN phase of TDD for interactive development. Minimal implementation to make tests pass with gate tracking. Called by /green-tdd command.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Execute GREEN phase of TDD for interactive development. Minimal implementation to make tests pass with gate tracking. Called by /green-tdd command.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | tdd-green |
| description | Execute GREEN phase of TDD for interactive development. Minimal implementation to make tests pass with gate tracking. Called by /green-tdd command. |
| triggers | ["tdd green","tdd-green","green phase","implement tests","make tests pass"] |
| version | 1 |
| last_updated | "2026-01-09T00:00:00.000Z" |
Execute the complete GREEN phase (minimal implementation) for interactive TDD development workflow.
Skill(skill: "tdd-green", args: "[sprintdag-path]")
Examples:
Skill(skill: "tdd-green", args: "tasks/sprints/sprint-7/day-05")
Skill(skill: "tdd-green", args: "tasks/sprints/sprint-7/day-02")
| Arg | Format | Example |
|---|---|---|
sprintdag | tasks/sprints/sprint-X/day-Y | tasks/sprints/sprint-7/day-05 |
Note: Feature and operations are read from [sprintdag]/gates.json (created by tdd-red).
<promise>TDD_GREEN_COMPLETE</promise>[sprintdag]/gates.json updated with GREEN phase gates[sprintdag]/implementation/PROGRESS.md with step-by-step completion logGATE_GREEN_PREREQ_DONE = false # After Step 0
GATE_GREEN_EXPLORE_DONE = false # After Step 1
GATE_GREEN_MIGRATION_DONE = false # After Step 2 (or skipped)
GATE_GREEN_PLAN_DONE = false # After Step 3
GATE_GREEN_CODE_DONE = false # After Step 5
GATE_GREEN_TESTS_PASS = false # After Step 6 (all GREEN)
GATE_GREEN_COVERAGE_OK = false # After Step 7
Task Tracking:
// Check if task already exists (from /green-tdd command)
TaskList(); // Find task with metadata.phase="GREEN" and matching sprintdag
// If no task exists, create one with dependency on RED
const redTask = TaskList().find(
(t) => t.metadata?.phase === "RED" && t.metadata?.sprintdag === "[sprintdag]",
);
TaskCreate({
subject: "GREEN: [feature]",
description: "Implement minimal code for [feature]",
activeForm: "Implementing GREEN phase",
metadata: {
type: "phase",
phase: "GREEN",
sprintdag: "[sprintdag]",
feature: "[feature]",
startedAt: "[ISO_TIMESTAMP]",
},
});
// Set dependency and mark in_progress
TaskUpdate(taskId, { addBlockedBy: [redTask.id], status: "in_progress" });
Read: [sprintdag]/gates.json
red.GATE_RED_AUDIT_PASSED = trueExecute:
# Verify tests exist
ls app/src/server/**/*.test.ts
# Verify tests are RED (failing)
cd app && wasp test client run 2>&1 | grep -E "(FAIL|PASS)"
# Verify RED phase commit exists
git log --oneline -10 | grep "test:.*RED"
# Verify test-plan.md exists
cat [sprintdag]/tests/test-plan.md | head -20
Validation:
<promise>TDD_GREEN_BLOCKED</promise>After completion:
green.GATE_GREEN_PREREQ_DONE = trueWrite: [sprintdag]/implementation/PROGRESS.md
# GREEN Phase Progress: [FEATURE]
**Sprintdag:** [SPRINTDAG_PATH]
**Started:** [ISO_TIMESTAMP]
**Status:** IN_PROGRESS
## Step Completion Log
| Step | Description | Status | Completed At | Notes |
| ---- | ----------------------- | ------ | ------------ | --------------------------- |
| 0 | Prerequisites | ✅ | [TIMESTAMP] | RED phase verified complete |
| 1 | Explore Schema | ⏳ | - | - |
| 2 | Schema Migration | ⏳ | - | - |
| 3 | Plan Implementation | ⏳ | - | - |
| 4 | Architecture Review | ⏳ | - | - |
| 5 | Generate Implementation | ⏳ | - | - |
| 6 | Validation Loop | ⏳ | - | - |
| 7 | Coverage Validation | ⏳ | - | - |
| 8 | Write Artifacts | ⏳ | - | - |
| 9 | Git Commit | ⏳ | - | - |
| 10 | Output Promise | ⏳ | - | - |
## Gates Status
- [ ] GATE_GREEN_PREREQ_DONE
- [ ] GATE_GREEN_EXPLORE_DONE
- [ ] GATE_GREEN_MIGRATION_DONE
- [ ] GATE_GREEN_PLAN_DONE
- [ ] GATE_GREEN_CODE_DONE
- [ ] GATE_GREEN_TESTS_PASS
- [ ] GATE_GREEN_COVERAGE_OK
Blocked until: GATE_GREEN_PREREQ_DONE = true
Invoke:
Task(
subagent_type='Explore',
model='haiku',
prompt="""
Analyze schema requirements for [FEATURE]:
Operations: [OPERATIONS]
Check:
1. Are new entities needed?
2. Do existing entities need modification?
3. What are the relationships between entities?
4. Are enum values required?
5. Any parallel worktree schema changes to coordinate?
"""
)
After completion:
green.GATE_GREEN_EXPLORE_DONE = trueBlocked until: GATE_GREEN_EXPLORE_DONE = true
Invoke:
Task(
subagent_type='wasp-migration-helper',
model='haiku',
prompt="""
Analyze and execute schema migration for [FEATURE]:
1. CHECK if schema changes required based on exploration
2. IF changes needed:
- Edit schema.prisma (add/modify models, fields, enums)
- Run: wasp db migrate-dev --name "[feature]-schema"
- MANDATORY restart: ./scripts/safe-start.sh
- Verify types regenerated (check imports work)
3. IF no changes needed:
- Document "No schema changes required" in schema-coordination.md
ALWAYS document in schema-coordination.md:
- Schema changes made (or "none required")
- Multi-worktree coordination notes (if applicable)
- Types regenerated successfully: yes/no
"""
)
After completion:
green.GATE_GREEN_MIGRATION_DONE = true[sprintdag]/implementation/schema-coordination.mdBlocked until: GATE_GREEN_MIGRATION_DONE = true
Read: [sprintdag]/tests/test-plan.md for guidance
Invoke:
Task(
subagent_type='Plan',
model='haiku',
prompt="""
Plan minimal implementation for [FEATURE]:
Operations: [OPERATIONS]
Based on test-plan.md, for each operation:
1. Define function signature (args, return type)
2. Add auth check: if (!context.user) throw HttpError(401)
3. Add permission check (403)
4. Add entity lookup (404)
5. Add validation (400)
6. Implement business logic (minimal to pass tests)
Output: implementation-plan.md with code structure
"""
)
After completion:
green.GATE_GREEN_PLAN_DONE = true[sprintdag]/implementation/implementation-plan.mdBlocked until: GATE_GREEN_PLAN_DONE = true
Invoke:
Task(
subagent_type='wasp-backend-architect',
model='sonnet',
prompt="""
REVIEW implementation plan for [FEATURE]:
📋 CHECKLIST:
□ Error handling order correct? (Auth → Exists → Permission → Validate)
□ Multi-tenant isolation enforced?
□ Wasp operation patterns followed?
□ Performance implications acceptable?
□ Type safety maintained?
OUTPUT: "APPROVED" or "CONCERNS: [issues]"
"""
)
After completion:
Blocked until: GATE_GREEN_PLAN_DONE = true
Invoke:
Task(
subagent_type='wasp-code-generator',
model='haiku',
prompt="""
Generate MINIMAL implementation for [FEATURE]:
Operations: [OPERATIONS]
RULES:
- Only implement what tests require
- Follow existing patterns in codebase
- Use correct imports (wasp/entities, @prisma/client for enums)
- Add operations to main.wasp
- No premature optimization
- Error handling order: Auth → Exists → Permission → Validate
Output: Implementation files (operations.ts, main.wasp updates)
"""
)
After completion:
green.GATE_GREEN_CODE_DONE = trueBlocked until: GATE_GREEN_CODE_DONE = true
FOR attempt = 1 to 3:
→ Run tests: cd app && wasp test client run
IF ALL TESTS GREEN:
✅ GATE_GREEN_TESTS_PASS = true
→ Proceed to Step 7
→ BREAK loop
IF TESTS RED:
→ Analyze failure pattern:
* LOGIC: Fix business logic
* TYPE: Fix type annotations
* SCHEMA: Re-run migration
* IMPORT: Fix import paths
* AUTH: Add auth checks
→ Generate targeted fix (not blind retry)
→ Document in implementation/green-failures.md
→ Continue to next attempt
IF attempt > 3 AND STILL RED:
→ Invoke TEST_INCORRECT analysis (see Step 6a below)
Purpose: Determine if the issue is an implementation problem or a fundamentally incorrect test.
Step 6a.1: First Agent Analysis (wasp-backend-architect)
Task(
subagent_type='wasp-backend-architect',
model='sonnet',
prompt="""
Analyze GREEN phase failure for [FEATURE]:
CONTEXT:
- Implementation attempts: 3 (all failed)
- Failures documented in: implementation/green-failures.md
- Test plan: tests/test-plan.md
DETERMINE by analyzing the evidence:
1. Is the implementation approach correct per business requirements?
2. Does the test contain an INCORRECT ASSUMPTION about requirements?
VALID INCORRECT ASSUMPTION CATEGORIES (only these 4):
- INCORRECT_BUSINESS_RULE: Test assumes wrong business logic
- INCORRECT_TYPE_CONTRACT: Test assumes wrong schema/type relationship
- INCORRECT_ERROR_CODE: Test assumes wrong error code for scenario
- INCORRECT_SIDE_EFFECT: Test assumes wrong side effect trigger
OUTPUT one of:
- "IMPLEMENTATION_ISSUE: [specific fix needed]"
- "TEST_INCORRECT_CONFIRMED:
Category: [one of 4 valid categories]
Specific assumption: [exact statement of what test assumes incorrectly]
Evidence: [test line reference, expected vs actual behavior]"
"""
)
If IMPLEMENTATION_ISSUE:
→ Extend validation loop by 2 additional attempts
→ Apply suggested fix
→ Continue to attempt 4-5
→ If still failing after 5 attempts:
→ Output: <promise>TDD_GREEN_BLOCKED</promise>
If TEST_INCORRECT_CONFIRMED:
→ Proceed to Step 6a.2 (Second Agent Confirmation)
Step 6a.2: Second Agent Confirmation (test-quality-auditor)
Task(
subagent_type='test-quality-auditor',
model='opus',
prompt="""
SECOND OPINION on TEST_INCORRECT claim for [FEATURE]:
FIRST AGENT (wasp-backend-architect) CLAIMED:
Category: [CATEGORY from Step 6a.1]
Assumption: "[SPECIFIC_ASSUMPTION from Step 6a.1]"
Evidence: [EVIDENCE from Step 6a.1]
YOUR TASK:
1. Independently verify if the test assumption is actually incorrect
2. Check if this could still be an implementation issue
3. Verify the category is valid (one of 4)
4. Confirm the assumption statement is specific (not vague)
CRITICAL: Tests passed Architecture Review + Quality Audit in RED phase.
A TEST_INCORRECT claim means those reviews missed something.
Be rigorous in your verification.
OUTPUT one of:
- "CONFIRMED: Test assumption is incorrect. Category [X] is valid.
[Your independent reasoning why]"
- "REJECTED: This is an implementation issue, not a test issue.
Reason: [specific reason]
Suggested fix: [implementation fix]"
"""
)
If REJECTED (agents disagree):
→ Update gates.json: green.blocked_reason = "AGENTS_DISAGREE"
→ Document disagreement in implementation/green-failures.md
→ Output: <promise>TDD_GREEN_BLOCKED</promise>
If CONFIRMED (both agents agree):
→ Update gates.json:
- green.blocked_reason = "TEST_INCORRECT"
- green.blocked_at = [ISO_TIMESTAMP]
- green.validation_attempts = [attempt count]
→ Output TEST_REVISION_NEEDED with details:
<promise>TDD_TEST_REVISION_NEEDED</promise>
TEST REVISION REQUIRED
----------------------
Category: [CATEGORY]
Assumption: [SPECIFIC_ASSUMPTION]
Evidence: [EVIDENCE]
Run /tdd-red-revision to fix tests, then resume /green-tdd
Decision Tree Summary:
3 attempts failed
↓
wasp-backend-architect analysis
↓
┌─────────────────────────────────────────┐
│ IMPLEMENTATION_ISSUE │
│ → +2 attempts (total 5) │
│ → If still failing → TDD_GREEN_BLOCKED │
└─────────────────────────────────────────┘
↓ (if TEST_INCORRECT_CONFIRMED)
test-quality-auditor second opinion
↓
┌─────────────────────────────────────────┐
│ REJECTED (agents disagree) │
│ → TDD_GREEN_BLOCKED │
└─────────────────────────────────────────┘
↓ (if CONFIRMED)
┌─────────────────────────────────────────┐
│ Both agents agree │
│ → TDD_TEST_REVISION_NEEDED │
│ → User runs /tdd-red-revision │
│ → Resume GREEN after revision │
└─────────────────────────────────────────┘
After completion:
green.GATE_GREEN_TESTS_PASS = trueBlocked until: GATE_GREEN_TESTS_PASS = true
Execute:
cd app && wasp test client run --coverage
Read: [sprintdag]/tests/coverage-targets.json
Compare:
If coverage below target:
implementation/coverage-gaps.mdAfter completion:
green.GATE_GREEN_COVERAGE_OK = true[sprintdag]/implementation/coverage-actual.jsonWrite to [sprintdag]/implementation/:
implementation-notes.md - Implementation decisionscoverage-actual.json - Actual coverage achievedgreen-failures.md - Validation loop failures (if any)schema-coordination.md - Schema changesAfter completion:
Execute:
git add app/src/**/*.ts app/main.wasp app/schema.prisma [sprintdag]/implementation/ [sprintdag]/gates.json
git commit -m "feat: Implement [FEATURE]
Co-Authored-By: Claude <noreply@anthropic.com>"
After completion:
Update [sprintdag]/gates.json:
{
"sprintdag": "[SPRINTDAG_PATH]",
"feature": "[FEATURE]",
"operations": ["op1", "op2"],
"red": { ... },
"green": {
"GATE_GREEN_PREREQ_DONE": true,
"GATE_GREEN_EXPLORE_DONE": true,
"GATE_GREEN_MIGRATION_DONE": true,
"GATE_GREEN_PLAN_DONE": true,
"GATE_GREEN_CODE_DONE": true,
"GATE_GREEN_TESTS_PASS": true,
"GATE_GREEN_COVERAGE_OK": true,
"started_at": "[ISO_TIMESTAMP]",
"completed_at": "[ISO_TIMESTAMP]"
}
}
Output:
TDD GREEN PHASE COMPLETE: [FEATURE]
✅ Tests: X/X GREEN
✅ Coverage: Y% statements, Z% branches
✅ All 7 gates: ✅✅✅✅✅✅✅
✅ Committed: [hash]
✅ Artifacts: [sprintdag]/implementation/
<promise>TDD_GREEN_COMPLETE</promise>
Task Tracking (on completion):
TaskUpdate(taskId, {
status: "completed",
metadata: {
completedAt: "[ISO_TIMESTAMP]",
testsPassed: "[X/X]",
coverageStatements: "[Y%]",
coverageBranches: "[Z%]",
validationAttempts: "[N]",
commitHash: "[hash]",
gatesPath: "[sprintdag]/gates.json",
},
});
After completion:
If prerequisites fail:
⚠️ Prerequisites validation failed.
Missing: [list]
RED phase must be completed first.
<promise>TDD_GREEN_BLOCKED</promise>
If tests still RED after 5 attempts:
⚠️ Tests still failing after 5 attempts.
See implementation/green-failures.md
Escalating to user for guidance.
<promise>TDD_GREEN_BLOCKED</promise>
If skill was interrupted, check [sprintdag]/gates.json:
Example:
gates.json shows GATE_GREEN_PLAN_DONE = true, GATE_GREEN_CODE_DONE = false
→ Resume from Step 5 (Generate Implementation)
| Step | Agent | Model | Purpose | Gate |
|---|---|---|---|---|
| 1 | Explore (built-in) | haiku | Analyze schema impact | GATE_GREEN_EXPLORE_DONE |
| 2 | wasp-migration-helper | haiku | Schema migration | GATE_GREEN_MIGRATION_DONE |
| 3 | Plan (built-in) | haiku | Implementation strategy | GATE_GREEN_PLAN_DONE |
| 4 | wasp-backend-architect | sonnet | Architecture review | — |
| 5 | wasp-code-generator | haiku | Generate implementation | GATE_GREEN_CODE_DONE |
Reads from tdd-red:
[sprintdag]/gates.json - Feature, operations, RED phase status[sprintdag]/tests/test-plan.md - Implementation guidance[sprintdag]/tests/coverage-targets.json - Coverage validationCreates for tdd-refactor:
[sprintdag]/implementation/implementation-notes.md - Refactoring guidance[sprintdag]/implementation/coverage-actual.json - Coverage baseline[sprintdag]/gates.json - GREEN phase completionBrowser automation via ActionBook action manuals. Use for web interactions, deployment verification, visual testing, and admin UI tasks. 10x faster than raw browser automation with 100x token savings.
Complete code quality workflow with ESLint, Prettier, TypeScript, Husky hooks, and type safety standards. Run before every commit/push.
Comprehensive code review skill for Wasp applications. Use when reviewing code, PRs, or architectural changes. Covers Wasp-specific patterns, import rules, auth checks, TDD compliance, multi-tenant permissions, and performance. Integrates all CLAUDE.md critical rules.
Complete error handling patterns for Wasp applications. Use when implementing error handling, validation, or working with HTTP errors. Includes server-side operations errors, client-side error handling, Zod validation, and retry logic.
Type safety standards and linting philosophy for TypeScript/Wasp projects. 2-tier approach (production strict, tests pragmatic). Helper patterns, mock patterns, when 'any' is acceptable vs cheating.
Multi-tenant permission checking for Wasp applications. Use when implementing authorization, access control, or role-based permissions. Includes organization/department/role patterns and permission helper functions.