TDD Enforcement Algorithm
БесплатноБез исполняемых скриптовНе проверенAlgorithmic decision tree enforcing test-first development via boolean conditions instead of imperatives
Об этом скилле
TDD Enforcement Algorithm
Overview
Agents follow algorithmic decision trees (100% compliance) better than imperative instructions (0-33% compliance) for enforcing test-first development. Boolean conditions remove interpretation: "Does failing test exist? NO → STOP" vs "You MUST write tests first" (agent: "for complex code, mine is simple").
Core principle: Binary checks before implementation. Recovery mandates deleting untested code (no sunk cost exceptions).
When to Use
Use this algorithm when:
- About to write implementation code (functions, methods, classes)
- Code exists without tests (recovery path)
- Under pressure (time, sunk cost, authority) where TDD bypass tempting
- Need deterministic enforcement (no acceptable exceptions)
Use upstream TDD skill when:
- This algorithm says proceed (test exists, now implement)
- Learning RED-GREEN-REFACTOR methodology
- Understanding why TDD matters
Relationship:
- This skill: WHEN to use TDD (decision algorithm)
- Upstream skill: HOW to use TDD (implementation details)
Decision Algorithm: When to Write Tests First
1. Check for implementation code
Are you about to write implementation code?
- PASS: CONTINUE
- FAIL: GOTO 6
2. Check for prototype exception
Does throwaway prototype exception apply (user approved)?
- PASS: GOTO 6
- FAIL: CONTINUE
3. Check for failing test
Does a failing test exist for this code?
- PASS: GOTO 6
- FAIL: CONTINUE
4. Write failing test first
STOP writing implementation code. Write failing test first.
5. Verify test fails
Run project test command
- PASS (test runs and fails as expected): GOTO 6
- FAIL (test passes or doesn't run): GOTO 4 (fix test)
6. Proceed with implementation
Test exists OR not writing code OR approved exception - proceed
Recovery Algorithm: Already Wrote Code Without Tests?
7. Check for implementation code
Have you written ANY implementation code?
- PASS: CONTINUE
- FAIL: GOTO 10
8. Check for tests
Does that code have tests that failed first?
- PASS: GOTO 10
- FAIL: CONTINUE
9. Delete untested code
Delete the untested code. Execute: git reset --hard OR rm [files]. Do not keep as "reference".
- PASS: STOP
- FAIL: STOP
10. Continue
Tests exist OR no code written - continue
INVALID Conditions (NOT in algorithm, do NOT use)
These rationalizations are NOT VALID ALGORITHM CONDITIONS:
- "Is code too simple to test?" → NOT A VALID CONDITION
- "Is there time pressure?" → NOT A VALID CONDITION
- "Did I manually test it?" → NOT A VALID CONDITION
- "Will I add tests after?" → NOT A VALID CONDITION
- "Is deleting X hours wasteful?" → NOT A VALID CONDITION
- "Am I being pragmatic?" → NOT A VALID CONDITION
- "Can I keep as reference?" → NOT A VALID CONDITION
- "Is this exploratory code?" → NOT A VALID CONDITION (ask for throwaway prototype exception)
- "Tests after achieve same goal?" → NOT A VALID CONDITION
- "I already know it works?" → NOT A VALID CONDITION
All of these mean: Run the algorithm. Follow what it says.
Self-Test
Q1: You're about to write function calculateTotal(). What does Step 3 ask?
Answer: "Does a failing test exist?" If NO → Go to Step 4 (STOP, write test first)
Q2: I wrote 100 lines without tests. What does Recovery Step 3 say?
Answer: Delete the untested code. Execute: git reset --hard OR rm [files]
Q3: "This code is too simple to need tests" - is this a valid algorithm condition?
Answer: NO. Listed under INVALID conditions
Q4: Can I keep untested code as "reference" while writing tests?
Answer: NO. Recovery Step 3 says "Delete... Do not keep as 'reference'"
Five Mechanisms That Work
1. Boolean Conditions (No Interpretation)
Imperative: "You MUST write tests first" Agent rationalization: "For complex code. Mine is simple."
Algorithmic: "Does a failing test exist? → YES/NO" Agent: Binary check. Either test exists or it doesn't. No interpretation.
2. Explicit Invalid Conditions List
Imperative: "Regardless of simplicity or time pressure..." Agent: Still debates what "simple" means
Algorithmic: "Is code too simple to test?" → NOT A VALID CONDITION Agent: Sees rationalization explicitly invalidated. Can't use it.
3. Deterministic Execution Path with STOP
Imperative: Multiple MUST statements → agent balances priorities
Algorithmic:
Step 4: STOP writing implementation code
Write failing test first
Result: Single path. No choices. STOP prevents continuing.
4. Self-Test Forcing Comprehension
Quiz with correct answers:
Q1: About to write function. Step 3 asks?
Answer: Does a failing test exist?
Agents demonstrate understanding before proceeding. Catches comprehension failures early.
5. Unreachable Steps Proving Determinism
Step 5: [UNREACHABLE - if you reach here, you violated Step 4]
Demonstrates algorithm is deterministic. Reaching Step 5 = violat
Установить TDD Enforcement Algorithm в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл TDD Enforcement Algorithm?
Algorithmic decision tree enforcing test-first development via boolean conditions instead of imperatives
Как установить скилл TDD Enforcement Algorithm?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл TDD Enforcement Algorithm запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic