Agent skill

devflow-tdd-enforcer

Enforces TDD order in TASKS.md - Tests MUST be marked complete before Implementation tasks. Blocks violations in real-time.

Stars 232
Forks 15

Install this agent skill to your Project

npx add-skill https://github.com/aiskillstore/marketplace/tree/main/skills/dimon94/devflow-tdd-enforcer

SKILL.md

DevFlow TDD Enforcer

Purpose

Enforce Test-First Development (TDD) order by preventing users from marking implementation tasks complete before their corresponding test tasks.

Trigger: PreToolUse hook when editing devflow/requirements/**/TASKS.md

Enforcement Rule

Source: Extracted from planner agent's TDD mandate + Constitution Article VI

❌ BLOCKED Pattern (Violation)

markdown
- [x] **T010** [US1] Implement user registration endpoint
- [ ] **T011** [US1] Test user registration with valid data

Problem: Implementation marked done BEFORE test

Regex Pattern: \[x\].*Implementation.*\n.*\[ \].*Test

✅ CORRECT Pattern (TDD Sequence)

markdown
- [ ] **T010** [US1] Test user registration with valid data (write FAILING test)
- [ ] **T011** [US1] Implement user registration endpoint (make test PASS)

Or after completion:

markdown
- [x] **T010** [US1] Test user registration with valid data
- [x] **T011** [US1] Implement user registration endpoint

Blocking Message

When violation detected, PreToolUse hook returns exit code 2 (blocks file save):

⚠️ BLOCKED - TDD Violation Detected

📋 REQUIRED ACTION:
1. Re-order TASKS.md to follow TDD sequence
2. Mark test tasks [x] BEFORE implementation tasks
3. Review Constitution Article VI - Test-First Development

Reason: CC-DevFlow enforces TDD (Tests First → Implementation)
Source: planner agent mandate + Constitution Article VI
File: {file_path}

Current Issue:
  Line {N}: Implementation task marked complete
  Line {N+1}: Test task NOT marked complete

💡 SKIP: Add `@skip-tdd-check` comment or set SKIP_TDD_ENFORCER=1

Constitutional Basis

Article VI: Test-First Development

yaml
TDD MANDATE:
  - Write test FIRST (must fail)
  - Implement code SECOND (make test pass)
  - No implementation without corresponding test
  - Test coverage ≥80%

planner agent enforces

  • Generates TASKS.md with correct TDD order
  • Phase 2: All tests listed first
  • Phase 3+: Each user story has Test task before Implementation task
  • Inserts "⚠️ TEST VERIFICATION CHECKPOINT" between Phase 2 and Phase 3

devflow-tdd-enforcer guardrail prevents

  • Users from manually reversing that order
  • Implementation tasks marked complete before test tasks
  • Real-time detection during file editing

Additional Violation Patterns

Pattern 2: Phase 3+ User Story TDD Order

markdown
# ❌ BLOCKED
- [x] **T020** [US2] Implement login endpoint
- [ ] **T021** [US2] Test login with valid credentials

# ✅ CORRECT
- [x] **T020** [US2] Test login with valid credentials
- [x] **T021** **T021** [US2] Implement login endpoint

Regex Pattern: \[x\].*\[US\d+\].*Implement.*\n.*\[ \].*\[US\d+\].*Test

Pattern 3: Implementation without Test

markdown
# ❌ BLOCKED (if no corresponding test found)
- [ ] **T030** [US3] Implement password reset endpoint
# (No T029 or T031 test task found)

# ✅ CORRECT
- [ ] **T029** [US3] Test password reset with valid email
- [ ] **T030** [US3] Implement password reset endpoint

Skip Conditions

Users can bypass TDD enforcer in specific scenarios:

1. Session Skip (One-time per session)

  • Mechanism: sessionSkillUsed: true in skill-rules.json
  • Behavior: Guardrail only triggers once per Claude session
  • Use case: User acknowledged TDD violation, wants to continue

2. File Marker (Permanent skip for specific file)

  • Marker: Add @skip-tdd-check comment anywhere in TASKS.md
  • Example:
    markdown
    <!-- @skip-tdd-check: Hotfix deployment, will add tests in follow-up -->
    
  • Use case: Emergency hotfix, tests to be added later

3. Environment Variable (Temporary global skip)

  • Variable: SKIP_TDD_ENFORCER=1
  • Scope: Current terminal session
  • Use case: Batch operations, automated scripts

Relationship with Other Components

mark-task-complete.sh (Script)

  • Purpose: Marks tasks complete in正常 workflow (via /flow-dev)
  • Validation: Batch validation at phase completion
  • Timing: After task execution

devflow-tdd-enforcer (Guardrail)

  • Purpose: Real-time prevention of manual TDD violations
  • Validation: Per-edit, blocks save if violation detected
  • Timing: During file editing (PreToolUse hook)

Relationship: Complementary (双重保险)

  • Script ensures正常流程 follows TDD
  • Guardrail prevents手动编辑 from breaking TDD

Constitution Article VI

  • Defines: TDD philosophy and mandates
  • Enforcement: planner agent (generation time) + devflow-tdd-enforcer (edit time)

Configuration

In .claude/skills/skill-rules.json:

json
{
  "devflow-tdd-enforcer": {
    "type": "guardrail",
    "enforcement": "block",
    "priority": "critical",
    "description": "Enforces TDD order, extracted from planner agent rules",
    "fileTriggers": {
      "pathPatterns": ["devflow/requirements/**/TASKS.md"],
      "contentPatterns": [
        "\\[x\\].*Implementation.*\\n.*\\[ \\].*Test",
        "\\[x\\].*\\[US\\d+\\].*Implement.*\\n.*\\[ \\].*\\[US\\d+\\].*Test"
      ]
    },
    "blockMessage": "⚠️ BLOCKED - TDD Violation\n\nTasks must follow TDD order:\n1. [ ] Test (write failing test)\n2. [ ] Implementation (make test pass)\n\n📋 ACTION: Re-order TASKS.md\nSource: planner agent mandate + Constitution Article VI\n\n💡 SKIP: @skip-tdd-check or SKIP_TDD_ENFORCER=1",
    "skipConditions": {
      "sessionSkillUsed": true,
      "fileMarkers": ["@skip-tdd-check"],
      "envOverride": "SKIP_TDD_ENFORCER"
    }
  }
}

Design Principle

This guardrail does NOT contain:

  • ❌ Complete TDD methodology (that's in planner agent)
  • ❌ Task generation logic (that's in planner agent)
  • ❌ Full Constitution Article VI (that's in project-constitution.md)

This guardrail ONLY contains:

  • ✅ Prohibition rule extraction (from planner agent)
  • ✅ Real-time violation detection (content pattern matching)
  • ✅ Blocking mechanism (PreToolUse hook, exit code 2)
  • ✅ Links to source documentation

Rationale: Avoid duplication ("不重不漏" principle). planner agent owns TDD generation logic, guardrail owns real-time enforcement.

Expand your agent's capabilities with these related and highly-rated skills.

aiskillstore/marketplace

perigon-backend

Perigon ASP.NET Core + EF Core + Aspire conventions

232 15
Explore
aiskillstore/marketplace

perigon-agent

Pointers for Copilot/agents to apply Perigon conventions

232 15
Explore
aiskillstore/marketplace

perigon-angular

Angular 21+ standalone/Material/signal conventions for Perigon WebApp

232 15
Explore
aiskillstore/marketplace

fastapi-mastery

Comprehensive FastAPI development skill covering REST API creation, routing, request/response handling, validation, authentication, database integration, middleware, and deployment. Use when working with FastAPI projects, building APIs, implementing CRUD operations, setting up authentication/authorization, integrating databases (SQL/NoSQL), adding middleware, handling WebSockets, or deploying FastAPI applications. Triggered by requests involving .py files with FastAPI code, API endpoint creation, Pydantic models, or FastAPI-specific features.

232 15
Explore
aiskillstore/marketplace

context7-efficient

Token-efficient library documentation fetcher using Context7 MCP with 86.8% token savings through intelligent shell pipeline filtering. Fetches code examples, API references, and best practices for JavaScript, Python, Go, Rust, and other libraries. Use when users ask about library documentation, need code examples, want API usage patterns, are learning a new framework, need syntax reference, or troubleshooting with library-specific information. Triggers include questions like "Show me React hooks", "How do I use Prisma", "What's the Next.js routing syntax", or any request for library/framework documentation.

232 15
Explore
aiskillstore/marketplace

browser-use

Browser automation using Playwright MCP. Navigate websites, fill forms, click elements, take screenshots, and extract data. Use when tasks require web browsing, form submission, web scraping, UI testing, or any browser interaction.

232 15
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results