Skip to content

fix(writing-plans): require strict TDD task order in generated plans#629

Open
stablegenius49 wants to merge 1 commit intoobra:mainfrom
stablegenius49:pr-factory/issue-566-enforce-tdd-plan-structure
Open

fix(writing-plans): require strict TDD task order in generated plans#629
stablegenius49 wants to merge 1 commit intoobra:mainfrom
stablegenius49:pr-factory/issue-566-enforce-tdd-plan-structure

Conversation

@stablegenius49
Copy link

@stablegenius49 stablegenius49 commented Mar 6, 2026

Summary

  • make TDD ordering explicit and mandatory in skills/writing-plans/SKILL.md
  • add a mandatory task-structure validation section that blocks plan handoff when tasks are implementation-first
  • document allowed exceptions that require explicit justification in the saved plan

Validation

  • python3 static content check for required frontmatter and mandatory 5-step TDD sections

Closes #566

@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

The writing-plans skill is updated to mandate test-driven development discipline, requiring all tasks to follow a failing-test-first sequence with validation checks before plan execution.

Changes

Cohort / File(s) Summary
TDD Enforcement in Writing Plans
skills/writing-plans/SKILL.md
Adds mandatory 5-step TDD task workflow, introduces validation section enforcing failing-test-first sequences, prevents implementation-only tasks, and documents explicit exceptions with compliance checks required before saving plans.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Hops in circles, testing deep,
Red then green, no cheating peep,
Test must fail before you code,
That's the righteous, righteous road!
Plans now guard this sacred way,
TDD wins the day!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: requiring strict TDD task order in writing-plans skill, which is the primary focus of the PR.
Description check ✅ Passed The description directly relates to the changeset, outlining the main changes (TDD enforcement, task-structure validation, documented exceptions) and validation approach.
Linked Issues check ✅ Passed The PR fully addresses issue #566 requirements: adds mandatory 5-step TDD task structure validation, blocks plan handoff for implementation-first tasks, and documents allowed exceptions [#566].
Out of Scope Changes check ✅ Passed All changes are focused on the writing-plans skill to enforce TDD structure as required by the linked issue; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/writing-plans/SKILL.md`:
- Around line 100-111: The "Task Structure Validation (MANDATORY)" section's
Allowed exceptions list diverges from the canonical TDD skill's exceptions,
causing inconsistency; update the Allowed exceptions in this SKILL.md to match
the canonical TDD exceptions (e.g., include Throwaway prototypes, Generated
code, Configuration files) or add a brief explicit rationale explaining why this
plan-writing context needs different exceptions, and also add a note clarifying
that the "STOP and rewrite" guidance is manual (or link to an automated
validation task if one exists) so readers know enforcement is not automatic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3637ef1a-5cc2-45d5-b0f4-53e44b6249f5

📥 Commits

Reviewing files that changed from the base of the PR and between e4a2375 and 46ee509.

📒 Files selected for processing (1)
  • skills/writing-plans/SKILL.md

Comment on lines +49 to +57
## Task Structure (MANDATORY)

Every implementation task MUST follow this exact 5-step order:

1. **Step 1: Write the failing test** (include complete test code)
2. **Step 2: Run test to verify it fails** (include exact command + expected failure)
3. **Step 3: Write minimal implementation** (only enough to pass the new test)
4. **Step 4: Run test to verify it passes** (include exact command + expected success)
5. **Step 5: Commit**
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if the TDD skill defines a REFACTOR step
echo "=== Searching for REFACTOR in test-driven-development SKILL.md ==="
cat skills/test-driven-development/SKILL.md | rg -B 3 -A 3 "REFACTOR|refactor"
echo ""
echo "=== Full TDD skill file (checking size first) ==="
wc -l skills/test-driven-development/SKILL.md

Repository: obra/superpowers

Length of output: 1511


🏁 Script executed:

#!/bin/bash
# Check the writing-plans SKILL.md for the full task structure and related sections
echo "=== Writing-plans SKILL.md around the task structure (lines 40-120) ==="
sed -n '40,120p' skills/writing-plans/SKILL.md

Repository: obra/superpowers

Length of output: 2417


Add the REFACTOR step to the mandatory 5-step task structure.

The canonical TDD workflow defined in skills/test-driven-development/SKILL.md includes an explicit REFACTOR phase (RED-GREEN-REFACTOR). Your current 5-step structure implements RED-GREEN-COMMIT, systematically omitting refactoring from every task in every plan.

This creates a documented divergence from established TDD discipline. Plans generated under this structure will skip code quality improvements, even though you mandate TDD compliance in the planning workflow.

Proposed fix
 ## Task Structure (MANDATORY)
 
-Every implementation task MUST follow this exact 5-step order:
+Every implementation task MUST follow this exact 6-step order:
 
 1. **Step 1: Write the failing test** (include complete test code)
 2. **Step 2: Run test to verify it fails** (include exact command + expected failure)
 3. **Step 3: Write minimal implementation** (only enough to pass the new test)
 4. **Step 4: Run test to verify it passes** (include exact command + expected success)
-5. **Step 5: Commit**
+5. **Step 5: Refactor** (remove duplication, improve names, keep tests green)
+6. **Step 6: Commit**

Update the validation at line 102 to check for "exact 6-step TDD order" and update the template to show all 6 steps.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Task Structure (MANDATORY)
Every implementation task MUST follow this exact 5-step order:
1. **Step 1: Write the failing test** (include complete test code)
2. **Step 2: Run test to verify it fails** (include exact command + expected failure)
3. **Step 3: Write minimal implementation** (only enough to pass the new test)
4. **Step 4: Run test to verify it passes** (include exact command + expected success)
5. **Step 5: Commit**
## Task Structure (MANDATORY)
Every implementation task MUST follow this exact 6-step order:
1. **Step 1: Write the failing test** (include complete test code)
2. **Step 2: Run test to verify it fails** (include exact command + expected failure)
3. **Step 3: Write minimal implementation** (only enough to pass the new test)
4. **Step 4: Run test to verify it passes** (include exact command + expected success)
5. **Step 5: Refactor** (remove duplication, improve names, keep tests green)
6. **Step 6: Commit**

Comment on lines +100 to +111
## Task Structure Validation (MANDATORY)

Before saving the plan, verify every implementation task follows the exact 5-step TDD order.

- If a task starts with implementation work (for example: "add field", "update service", "implement method"), STOP and rewrite it into TDD order.
- If tests appear after implementation, STOP and rewrite.
- Do not hand off execution until every implementation task is TDD-compliant.

Allowed exceptions (must be explicitly justified in the plan):
- Pure documentation-only tasks
- Pure configuration-only tasks
- Schema/migration-only tasks (still require a separate test task to validate behavior)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Compare exception lists between TDD and writing-plans skills

echo "=== TDD skill exceptions ==="
rg -A 3 "Exceptions" skills/test-driven-development/SKILL.md

echo -e "\n=== writing-plans exceptions ==="
rg -A 5 "Allowed exceptions" skills/writing-plans/SKILL.md

Repository: obra/superpowers

Length of output: 453


Major: Exception list diverges from the canonical TDD skill.

The allowed exceptions at lines 108-111 differ significantly from those in skills/test-driven-development/SKILL.md:

TDD skill: Throwaway prototypes, Generated code, Configuration files
writing-plans: Pure documentation-only tasks, Pure configuration-only tasks, Schema/migration-only tasks

The lists have no overlap. This creates confusion about when TDD can legitimately be skipped across the two skills. Align the exception lists or explicitly document why they differ by context.

Additionally, this validation is manual guidance ("STOP and rewrite") rather than automated enforcement, so plans can still violate TDD if not followed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/writing-plans/SKILL.md` around lines 100 - 111, The "Task Structure
Validation (MANDATORY)" section's Allowed exceptions list diverges from the
canonical TDD skill's exceptions, causing inconsistency; update the Allowed
exceptions in this SKILL.md to match the canonical TDD exceptions (e.g., include
Throwaway prototypes, Generated code, Configuration files) or add a brief
explicit rationale explaining why this plan-writing context needs different
exceptions, and also add a note clarifying that the "STOP and rewrite" guidance
is manual (or link to an automated validation task if one exists) so readers
know enforcement is not automatic.

IgorTavcar added a commit to IgorTavcar/superpowers that referenced this pull request Mar 9, 2026
…bra#629)

Add mandatory 5-step TDD structure for every plan task: write test,
run test (expect fail), implement, run test (expect pass), commit.

Upstream PR: obra#629

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

# Issue: writing-plans skill doesn't enforce TDD structure, allowing Test-After-Development

1 participant