/tdd-mastery
Test-Driven Development Iron Law. Write the test first. Watch it fail. Write minimal code to pass. No exceptions.
$ npx -y skills add xenitv1/claude-code-maestro --skill tdd-mastery --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition β
- You can call itInvoke it directly when you want it.
- Slash command
/tdd-mastery
Context preview
The summary Claude sees to decide when to auto-load this skill.
Test-Driven Development Iron Law. Write the test first. Watch it fail. Write minimal code to pass. No exceptions.
SKILL.md
tdd-mastery.SKILL.mdname: tdd-mastery
description: Test-Driven Development Iron Law. Write the test first. Watch it fail. Write minimal code to pass. No exceptions.
<domain_overview>
π§ͺ TDD MASTERY: THE IRON LAW
> **Philosophy:** If you didn't watch the test fail, you don't know if it tests the right thing. TDD is not optionalβit's the foundation of trustworthy code. **TEST-FIRST INTEGRITY MANDATE (CRITICAL):** Never write production code before a test exists and has been seen failing. AI-generated code often attempts to write implementation and tests simultaneously or implementation first. You MUST strictly adhere to the Red-Green-Refactor cycle. Any code submitted without a preceding failing test or that generates tests after the implementation must be rejected as "Legacy Code on Arrival".
---
π¨ THE IRON LAW
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
Write code before the test? **Delete it. Start over.**
**No exceptions:**
- Don't keep it as "reference"
- Don't "adapt" it while writing tests
- Don't look at it
- Delete means delete
Implement fresh from tests. Period. </domain_overview> <core_workflow>
π΄ RED-GREEN-REFACTOR CYCLE
Phase 1: RED - Write Failing Test
Write one minimal test showing what should happen.
**Good Example:**
test('retries failed operations 3 times', async () => {
let attempts = 0;
const operation = () => {
attempts++;
if (attempts < 3) throw new Error('fail');
return 'success';
};
const result = await retryOperation(operation);
expect(result).toBe('success');
expect(attempts).toBe(3);
});*Clear name, tests real behavior, one thing*
**Bad Example:**
test('retry works', async () => {
const mock = jest.fn()
.mockRejectedValueOnce(new Error())
.mockResolvedValueOnce('success');
await retryOperation(mock);
expect(mock).toHaveBeenCalledTimes(2);
});*Vague name, tests mock not code*
**Requirements:**
- One behavior per test
- Clear, descriptive name
- Real code (mocks only if unavoidable)
Phase 2: VERIFY RED - Watch It Fail
**MANDATORY. Never skip.**
npm test path/to/test.test.ts
# or
pytest tests/path/test.py::test_name -v
Confirm:
- Test fails (not errors)
- Failure message is expected
- Fails because feature missing (not typos)
**Test passes?** You're testing existing behavior. Fix test.
**Test errors?** Fix error, re-run until it fails correctly.
Phase 3: GREEN - Minimal Code
Write **simplest code** to pass the test.
**Good:**
async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
for (let i = 0; i < 3; i++) {
try {
return await fn();
} catch (e) {
if (i === 2) throw e;
}
}
throw new Error('unreachable');
}*Just enough to pass*
**Bad:**
async function retryOperation<T>(
fn: () => Promise<T>,
options?: {
maxRetries?: number;
backoff?: 'linear' | 'exponential';
onRetry?: (attempt: number) => void;
}
): Promise<T> {
// YAGNI - You Aren't Gonna Need It
}*Over-engineered*
Don't add features, refactor other code, or "improve" beyond the test.
Phase 4: VERIFY GREEN - Watch It Pass
**MANDATORY.**
npm test path/to/test.test.ts
Confirm:
- Test passes
- Other tests still pass
- Output pristine (no errors, warnings)
**Test fails?** Fix code, not test.
**Other tests fail?** Fix now.
Phase 5: REFACTOR - Clean Up
After green only:
- Remove duplication
- Improve names
- Extract helpers
Keep tests green. Don't add behavior.
Phase 6: COMMIT
git add tests/path/test.ts src/path/file.ts
git commit -m "feat: add specific feature with tests"
**Repeat** for next behavior.
--- </core_workflow>
<quality_standards>
π GOOD TEST QUALITIES
| Quality | Good | Bad | |---------|------|-----| | **Minimal** | One thing. "and" in name? Split it. | `test('validates email and domain and whitespace')` | | **Clear** | Name describes behavior | `test('test1')` | | **Shows intent** | Demonstrates desired API | Obscures what code should do | | **Real behavior** | Tests actual code | Tests mock behavior |
---
π« COMMON RATIONALIZATIONS (ALL INVALID)
| Excuse | Reality | |--------|---------| | "Too simple to test" | Simple code breaks. Test takes 30 seconds. | | "I'll test after" | Tests passing immediately prove nothing. | | "Already manually tested" | Ad-hoc β systematic. No record, can't re-run. | | "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is debt. | | "Keep as reference" | You'll adapt it. That's testing after. Delete means delete. | | "Need to explore first" | Fine. Throw away exploration, start with TDD. | | "Test hard = skip test" | Hard to test = hard to use. Simplify design. | | "TDD will slow me down" | TDD faster than debugging. Pragmatic = test-first. | | "Existing code has no tests" | You're improving it. Add tests for existing code. |
---
π¨ RED FLAGS - STOP AND START OVER
If you catch yourself:
- Writing code before test
- Test passes immediately
- Can't explain why test failed
- Tests added "later"
- "Just this once"
- "I already manually tested it"
- "Keep as reference"
- "TDD is dogmatic, I'm being pragmatic"
**ALL of these mean: Delete code. Start over with TDD.**
--- </quality_standards>
<bug_fix_protocol>
π BUG FIX WORKFLOW
Bug found? Write failing test reproducing it. Follow TDD cycle.
**Example:**
Bug: Empty email accepted
RED:
test('rejects empty email', async () => {
const result = await submitForm({ email: '' });
expect(result.error).toBe('Email required');
});
VERIFY RED:
$ npm test
FAIL: expected 'Email required', got undefined
GREEN:
function submitForm(data: FormData) {
if (!data.email?.trim()) {
return { error: 'Email required' };
}
// ...
}
VERIFY GREEN:
$ npm test
PASS**Never fix bugs without a test.**
--- </bug_fix_protocol>
<integration_and_tooling>
π RALPH WIGGUM INTEGRATION
When Ralph Wiggum is act
Read more
name: tdd-mastery description: Test-Driven Development Iron Law. Write the test first. Watch it fail. Write minimal code to pass. No exceptions.
<domain_overview>
π§ͺ TDD MASTERY: THE IRON LAW
> **Philosophy:** If you didn't watch the test fail, you don't know if it tests the right thing. TDD is not optionalβit's the foundation of trustworthy code. **TEST-FIRST INTEGRITY MANDATE (CRITICAL):** Never write production code before a test exists and has been seen failing. AI-generated code often attempts to write implementation and tests simultaneously or implementation first. You MUST strictly adhere to the Red-Green-Refactor cycle. Any code submitted without a preceding failing test or that generates tests after the implementation must be rejected as "Legacy Code on Arrival".
---
π¨ THE IRON LAW
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
Write code before the test? **Delete it. Start over.**
**No exceptions:**
- Don't keep it as "reference"
- Don't "adapt" it while writing tests
- Don't look at it
- Delete means delete
Implement fresh from tests. Period. </domain_overview> <core_workflow>
π΄ RED-GREEN-REFACTOR CYCLE
Phase 1: RED - Write Failing Test
Write one minimal test showing what should happen.
**Good Example:**
test('retries failed operations 3 times', async () => {
let attempts = 0;
const operation = () => {
attempts++;
if (attempts < 3) throw new Error('fail');
return 'success';
};
const result = await retryOperation(operation);
expect(result).toBe('success');
expect(attempts).toBe(3);
});*Clear name, tests real behavior, one thing*
**Bad Example:**
test('retry works', async () => {
const mock = jest.fn()
.mockRejectedValueOnce(new Error())
.mockResolvedValueOnce('success');
await retryOperation(mock);
expect(mock).toHaveBeenCalledTimes(2);
});*Vague name, tests mock not code*
**Requirements:**
- One behavior per test
- Clear, descriptive name
- Real code (mocks only if unavoidable)
Phase 2: VERIFY RED - Watch It Fail
**MANDATORY. Never skip.**
npm test path/to/test.test.ts # or pytest tests/path/test.py::test_name -v
Confirm:
- Test fails (not errors)
- Failure message is expected
- Fails because feature missing (not typos)
**Test passes?** You're testing existing behavior. Fix test.
**Test errors?** Fix error, re-run until it fails correctly.
Phase 3: GREEN - Minimal Code
Write **simplest code** to pass the test.
**Good:**
async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
for (let i = 0; i < 3; i++) {
try {
return await fn();
} catch (e) {
if (i === 2) throw e;
}
}
throw new Error('unreachable');
}*Just enough to pass*
**Bad:**
async function retryOperation<T>(
fn: () => Promise<T>,
options?: {
maxRetries?: number;
backoff?: 'linear' | 'exponential';
onRetry?: (attempt: number) => void;
}
): Promise<T> {
// YAGNI - You Aren't Gonna Need It
}*Over-engineered*
Don't add features, refactor other code, or "improve" beyond the test.
Phase 4: VERIFY GREEN - Watch It Pass
**MANDATORY.**
npm test path/to/test.test.ts
Confirm:
- Test passes
- Other tests still pass
- Output pristine (no errors, warnings)
**Test fails?** Fix code, not test.
**Other tests fail?** Fix now.
Phase 5: REFACTOR - Clean Up
After green only:
- Remove duplication
- Improve names
- Extract helpers
Keep tests green. Don't add behavior.
Phase 6: COMMIT
git add tests/path/test.ts src/path/file.ts git commit -m "feat: add specific feature with tests"
**Repeat** for next behavior.
--- </core_workflow>
<quality_standards>
π GOOD TEST QUALITIES
| Quality | Good | Bad | |---------|------|-----| | **Minimal** | One thing. "and" in name? Split it. | `test('validates email and domain and whitespace')` | | **Clear** | Name describes behavior | `test('test1')` | | **Shows intent** | Demonstrates desired API | Obscures what code should do | | **Real behavior** | Tests actual code | Tests mock behavior |
---
π« COMMON RATIONALIZATIONS (ALL INVALID)
| Excuse | Reality | |--------|---------| | "Too simple to test" | Simple code breaks. Test takes 30 seconds. | | "I'll test after" | Tests passing immediately prove nothing. | | "Already manually tested" | Ad-hoc β systematic. No record, can't re-run. | | "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is debt. | | "Keep as reference" | You'll adapt it. That's testing after. Delete means delete. | | "Need to explore first" | Fine. Throw away exploration, start with TDD. | | "Test hard = skip test" | Hard to test = hard to use. Simplify design. | | "TDD will slow me down" | TDD faster than debugging. Pragmatic = test-first. | | "Existing code has no tests" | You're improving it. Add tests for existing code. |
---
π¨ RED FLAGS - STOP AND START OVER
If you catch yourself:
- Writing code before test
- Test passes immediately
- Can't explain why test failed
- Tests added "later"
- "Just this once"
- "I already manually tested it"
- "Keep as reference"
- "TDD is dogmatic, I'm being pragmatic"
**ALL of these mean: Delete code. Start over with TDD.**
--- </quality_standards>
<bug_fix_protocol>
π BUG FIX WORKFLOW
Bug found? Write failing test reproducing it. Follow TDD cycle.
**Example:**
Bug: Empty email accepted
RED:
test('rejects empty email', async () => {
const result = await submitForm({ email: '' });
expect(result.error).toBe('Email required');
});
VERIFY RED:
$ npm test
FAIL: expected 'Email required', got undefined
GREEN:
function submitForm(data: FormData) {
if (!data.email?.trim()) {
return { error: 'Email required' };
}
// ...
}
VERIFY GREEN:
$ npm test
PASS**Never fix bugs without a test.**
--- </bug_fix_protocol>
<integration_and_tooling>
π RALPH WIGGUM INTEGRATION
When Ralph Wiggum is act
Elite-tier orchestration framework for Claude Code CLI. Supercharges AI development through specialized agents, modular skills, intelligent hooks, and persistent memory systems. Author: xenitV1 β’ X/Twitter Philosophy: "Why over How.
Repo: xenitv1/claude-code-maestro
Other skills on maestro.
- /backend-design
Elite Tier Backend standards, including Vertical Slice Architecture, Zero Trust Security, and High-Performance API protocols.
Open skill - /brainstorming
Design-first methodology. Explore user intent, requirements and design before implementation. Turn ideas into fully formed specs through collaborative dialogue.
Open skill - /browser-extension
Master specialized skill for building 2025/2026-grade browser extensions. Deep expertise in Manifest v3, Service Worker persistence (Alarms, Offscreen API), Side Panel API, and Cross-Browser compatibility.
Open skill - /clean-code
The Foundation Skill. LLM Firewall + 2025 Security + Cross-Skill Coordination. Use for ALL code output - prevents hallucinations, enforces security, ensures quality.
Open skill - /debug-mastery
Systematic debugging methodology with 4-phase process, root cause tracing, and elite observability standards. No fixes without investigation.
Open skill - /frontend-design
Elite Tier Web UI standards, including pixel-perfect retro aesthetics, immersive layouts, and UX psychology protocols.
Open skill

