devflow-tdd-enforcer
Enforces TDD order in TASKS.md - Tests MUST be marked complete before Implementation tasks. Blocks violations in real-time.
Best use case
devflow-tdd-enforcer is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. Enforces TDD order in TASKS.md - Tests MUST be marked complete before Implementation tasks. Blocks violations in real-time.
Enforces TDD order in TASKS.md - Tests MUST be marked complete before Implementation tasks. Blocks violations in real-time.
Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.
Practical example
Example input
Use the "devflow-tdd-enforcer" skill to help with this workflow task. Context: Enforces TDD order in TASKS.md - Tests MUST be marked complete before Implementation tasks. Blocks violations in real-time.
Example output
A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.
When to use this skill
- Use this skill when you want a reusable workflow rather than writing the same prompt again and again.
When not to use this skill
- Do not use this when you only need a one-off answer and do not need a reusable workflow.
- Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/devflow-tdd-enforcer/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How devflow-tdd-enforcer Compares
| Feature / Agent | devflow-tdd-enforcer | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Enforces TDD order in TASKS.md - Tests MUST be marked complete before Implementation tasks. Blocks violations in real-time.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# 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.Related Skills
devflow-file-standards
File naming conventions, directory structure, and YAML frontmatter standards for CC-DevFlow. Consolidates shared conventions from all agents.
devflow-constitution-quick-ref
Quick reference guide to CC-DevFlow Constitution v2.0.0 with links to full text. Covers all 10 Articles and Phase -1 Gates.
cc-devflow-orchestrator
CC-DevFlow workflow router and agent recommender. Use when starting requirements, running flow commands, or asking about devflow processes.
devflow
End-to-end agent development process. Use when coordinating work, dispatching agents, or reviewing PRs.
git-workflow-enforcer
Ensures commits follow conventional commits, branch naming conventions, and PR templates. Use when creating commits, branches, or PRs, or when user mentions git workflow.
code-style-enforcer
Analyzes code for style consistency and applies project-specific formatting conventions beyond what linters catch. Use when reviewing code, ensuring style consistency, or when user requests code style improvements.
tdd-enforcer
Use when implementing new features. Enforces TDD workflow - write tests FIRST, then implementation. Ensures AAA pattern, proper coverage, and quality test design.
azure-quotas
Check/manage Azure quotas and usage across providers. For deployment planning, capacity validation, region selection. WHEN: "check quotas", "service limits", "current usage", "request quota increase", "quota exceeded", "validate capacity", "regional availability", "provisioning limits", "vCPU limit", "how many vCPUs available in my subscription".
raindrop-io
Manage Raindrop.io bookmarks with AI assistance. Save and organize bookmarks, search your collection, manage reading lists, and organize research materials. Use when working with bookmarks, web research, reading lists, or when user mentions Raindrop.io.
zlibrary-to-notebooklm
自动从 Z-Library 下载书籍并上传到 Google NotebookLM。支持 PDF/EPUB 格式,自动转换,一键创建知识库。
discover-skills
当你发现当前可用的技能都不够合适(或用户明确要求你寻找技能)时使用。本技能会基于任务目标和约束,给出一份精简的候选技能清单,帮助你选出最适配当前任务的技能。
web-performance-seo
Fix PageSpeed Insights/Lighthouse accessibility "!" errors caused by contrast audit failures (CSS filters, OKLCH/OKLAB, low opacity, gradient text, image backgrounds). Use for accessibility-driven SEO/performance debugging and remediation.