/common-tdd
Implements a strict Red-Green-Refactor loop to ensure zero production code is written without a prior failing test. Use when: creating new features, fixing bugs, or expanding test coverage.
$ npx -y skills add hoangnguyen0403/agent-skills-standard --skill common-tdd --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
/common-tdd
Context preview
The summary Claude sees to decide when to auto-load this skill.
Implements a strict Red-Green-Refactor loop to ensure zero production code is written without a prior failing test. Use when: creating new features, fixing bugs, or expanding test coverage.
SKILL.md
common-tdd.SKILL.mdname: common-tdd
description: "Implements a strict Red-Green-Refactor loop to ensure zero production code is written without a prior failing test. Use when: creating new features, fixing bugs, or expanding test coverage."
metadata:
triggers:
files:
- "**/*.test.ts"
- "**/*.spec.ts"
- "**/*_test.go"
- "**/*Test.java"
- "**/*_test.dart"
- "**/*_spec.rb"
keywords:
- tdd
- unit test
- write test
- red green refactor
- failing test
- test coverageTest-Driven Development (TDD) Standard
**Priority: P0 (CRITICAL)**
> **Iron Law: NO PRODUCTION CODE WITHOUT FAILING TEST FIRST.** > Code written before test MUST deleted. Start over.
**Step 1: RGR Loop (Red-Green-Refactor)**
> [!TIP] > **Orchestration**: If sub-agents are available, delegate each AC implementation to `specialist-tdd-implementer`.
1. **RED**: Write minimal failing test. **Verify failure** (Expected error, not typo). 2. **GREEN**: Write simplest code to pass. **Verify pass**. 3. **REFACTOR**: Clean up code while staying green.
**Red Flags**
- **Stop if code exists before test**: Delete it. Restart from RED.
- **Stop if test passes first run**: You tested old behavior.
- **Stop if "tests after" appears**: That is not TDD.
**AAA Structure (Mandatory)**
Every test must follow Arrange-Act-Assert:
- **Arrange**: Set up inputs, stubs, mocks, and expected values.
- **Act**: Call single unit under test.
- **Assert**: Verify output and side effects. One logical assertion per test.
**(See [AAA Example](references/aaa_example.md) for code structure)**.
**Step 3: Verification & Thresholds**
- **Minimum Coverage**: 80% (Stat/Func/Line), 75% (Branch).
- **Mocks**:
- Always mock: HTTP, Time/Date, Filesystem.
- Never mock: Fast internal services (<200ms), pure domain logic.
- See [Test Runner Reference](references/test_runners.md) for environment-specific commands.
**Step 4: Principles & Mocks**
- **Watch it Fail**: Prove test works before writing code.
- **Minimalism**: Don't add features/options beyond current test (YAGNI).
- **Isolation**: Mock external APIs (HTTP) and Time.
- **Realism**: Prefer real DBs (test containers) and fast internal services (<200ms).
**Rationalization Prevention**
- **"Too small to test"**: Small code still regresses. Write the test.
- **"Manual testing is enough"**: Manual checks do not prove the RED step.
- **"Keep code as reference"**: Pre-test code biases the implementation. Delete it.
- **"Tests after are equivalent"**: Passing immediately proves little.
**Verification Checklist**
- [ ] Every new function/method failing test first?
- [ ] Failure message expected?
- [ ] Minimal code implemented passed?
- [ ] AAA structure followed?
- [ ] Coverage thresholds met?
**Expert References**
- [AAA Example](references/aaa_example.md)
- [AAA Methodology](references/aaa_methodology.md)
- [Test Runners](references/test_runners.md)
- [TDD Patterns](references/tdd_patterns.md)
- [Testing Anti-Patterns](references/testing_anti_patterns.md)
Anti-Patterns
- **No test-after**: Writing tests post-implementation defeats TDD. Delete and restart.
- **No assertion-free tests**: test without assert not test.
- **No testing implementation**: Test behavior and contracts, not internal calls.
- A passing test alone is not enough: the failing test must demonstrate missing behavior before implementation.
Read more
name: common-tdd
description: "Implements a strict Red-Green-Refactor loop to ensure zero production code is written without a prior failing test. Use when: creating new features, fixing bugs, or expanding test coverage."
metadata:
triggers:
files:
- "**/*.test.ts"
- "**/*.spec.ts"
- "**/*_test.go"
- "**/*Test.java"
- "**/*_test.dart"
- "**/*_spec.rb"
keywords:
- tdd
- unit test
- write test
- red green refactor
- failing test
- test coverageTest-Driven Development (TDD) Standard
**Priority: P0 (CRITICAL)**
> **Iron Law: NO PRODUCTION CODE WITHOUT FAILING TEST FIRST.** > Code written before test MUST deleted. Start over.
**Step 1: RGR Loop (Red-Green-Refactor)**
> [!TIP] > **Orchestration**: If sub-agents are available, delegate each AC implementation to `specialist-tdd-implementer`.
1. **RED**: Write minimal failing test. **Verify failure** (Expected error, not typo). 2. **GREEN**: Write simplest code to pass. **Verify pass**. 3. **REFACTOR**: Clean up code while staying green.
**Red Flags**
- **Stop if code exists before test**: Delete it. Restart from RED.
- **Stop if test passes first run**: You tested old behavior.
- **Stop if "tests after" appears**: That is not TDD.
**AAA Structure (Mandatory)**
Every test must follow Arrange-Act-Assert:
- **Arrange**: Set up inputs, stubs, mocks, and expected values.
- **Act**: Call single unit under test.
- **Assert**: Verify output and side effects. One logical assertion per test.
**(See [AAA Example](references/aaa_example.md) for code structure)**.
**Step 3: Verification & Thresholds**
- **Minimum Coverage**: 80% (Stat/Func/Line), 75% (Branch).
- **Mocks**:
- Always mock: HTTP, Time/Date, Filesystem.
- Never mock: Fast internal services (<200ms), pure domain logic.
- See [Test Runner Reference](references/test_runners.md) for environment-specific commands.
**Step 4: Principles & Mocks**
- **Watch it Fail**: Prove test works before writing code.
- **Minimalism**: Don't add features/options beyond current test (YAGNI).
- **Isolation**: Mock external APIs (HTTP) and Time.
- **Realism**: Prefer real DBs (test containers) and fast internal services (<200ms).
**Rationalization Prevention**
- **"Too small to test"**: Small code still regresses. Write the test.
- **"Manual testing is enough"**: Manual checks do not prove the RED step.
- **"Keep code as reference"**: Pre-test code biases the implementation. Delete it.
- **"Tests after are equivalent"**: Passing immediately proves little.
**Verification Checklist**
- [ ] Every new function/method failing test first?
- [ ] Failure message expected?
- [ ] Minimal code implemented passed?
- [ ] AAA structure followed?
- [ ] Coverage thresholds met?
**Expert References**
- [AAA Example](references/aaa_example.md)
- [AAA Methodology](references/aaa_methodology.md)
- [Test Runners](references/test_runners.md)
- [TDD Patterns](references/tdd_patterns.md)
- [Testing Anti-Patterns](references/testing_anti_patterns.md)
Anti-Patterns
- **No test-after**: Writing tests post-implementation defeats TDD. Delete and restart.
- **No assertion-free tests**: test without assert not test.
- **No testing implementation**: Test behavior and contracts, not internal calls.
- A passing test alone is not enough: the failing test must demonstrate missing behavior before implementation.
The portable SDLC standards layer for AI coding agents. Sync once, then work in your own runtime.
Repo: hoangnguyen0403/agent-skills-standard
Other skills on agent-skills-standard.
- /android-agp-upgrade
Upgrade an Android project to Android Gradle Plugin (AGP) 9. Use when migrating to AGP 9, updating Gradle build files, migrating to built-in Kotlin, or adopting the new AGP DSL.
Open skill - /android-architecture
Apply Clean Architecture layering, modularization, and Unidirectional Data Flow in Android projects. Use when setting up project structure, placing code in layers, configuring feature/core modules, or implementing UDF patterns; defer Compose state and ViewModel/StateFlow
Open skill - /android-background-work
Implement WorkManager and background processing correctly on Android. Use when creating Worker classes, scheduling tasks, choosing between WorkManager and Foreground Services, or setting up Hilt in workers; defer FCM and notification delivery to android-notifications.
Open skill - /android-compose-migration
Migrate an Android XML View to Jetpack Compose following a structured 10-step workflow. Use when converting XML layouts to Compose, setting up Compose in an existing View-based project, or incrementally adopting Compose.
Open skill - /android-compose
Build high-performance declarative UI with Jetpack Compose. Use when writing Composable functions, optimizing recomposition, hoisting state, or working with LazyColumn and side effects; defer deep-link and navigation routing to android-navigation.
Open skill - /android-concurrency
Write correct coroutine scopes, lifecycle collection, and dispatcher injection in Android production code. Use for suspend functions, coroutine scopes, and dispatcher mechanics; defer ViewModel StateFlow/LiveData architecture, Fragment lifecycle recipes,
Open skill

