This skill should be used when performing test-driven development, "write a failing test first", "RED-GREEN- REFACTOR", or implementing new functionality with tests. Covers the full TDD cycle with pragmatic exceptions for generated code and configuration files. Do not use for planning testing strategy (see testing-strategy).
From forgenpx claudepluginhub flox/forge-plugin --plugin forgeThis skill uses the workspace's default tool permissions.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Details PluginEval's skill quality evaluation: 3 layers (static, LLM judge), 10 dimensions, rubrics, formulas, anti-patterns, badges. Use to interpret scores, improve triggering, calibrate thresholds.
Test-Driven Development discipline adapted for Forge workflows. Follows the RED-GREEN-REFACTOR cycle where appropriate, with pragmatic exceptions for generated code and configuration files.
Before writing implementation code, write a test that fails.
Why:
Actions:
Example (Python):
def test_validate_manifest_version():
manifest = Manifest(version="2.0")
assert validate_manifest(manifest) is True
# Run: pytest
# Expected: FAIL - validate_manifest doesn't exist yet
Write minimal code to make the test pass.
Why:
Actions:
Example (Python):
def validate_manifest(manifest):
if manifest.version == "2.0":
return True
raise ValueError("Invalid version")
# Run: pytest
# Expected: PASS
Clean up code while keeping tests passing.
Why:
Actions:
Example (Python):
SUPPORTED_VERSION = "2.0"
def validate_manifest(manifest):
if manifest.version != SUPPORTED_VERSION:
raise ValueError(
f"Unsupported version: {manifest.version}"
)
return True
# Run: pytest
# Expected: PASS (same behavior, clearer code)
Use full RED-GREEN-REFACTOR for:
Examples:
TDD can help but isn't mandatory:
Do NOT use TDD for:
Generated code Code generators are tested separately. Testing generated output is redundant. Approach: test the generator, not its output.
Configuration files JSON, YAML, TOML configs. Approach: validate with schema or linter.
Documentation Markdown files. Approach: review for accuracy.
Simple refactors Renaming variables, moving functions. Existing tests provide coverage. Approach: run existing test suite.
implementation-worker AgentWhen implementing a ticket:
Example commit message:
feat(manifest): Add version validation
TDD approach:
- RED: Wrote test expecting version 2.0 validation
- GREEN: Implemented validate_manifest function
- REFACTOR: Extracted SUPPORTED_VERSION constant
Tests: pytest passes
code-reviewer AgentWhen reviewing PRs:
Check for TDD evidence:
Red flags:
Acceptable:
feat(feature-name): Brief description
TDD: RED-GREEN-REFACTOR followed
- Test: {what test was written}
- Implementation: {what was implemented}
- Validation: {test output showing pass}
OR for exceptions:
feat(feature-name): Brief description
TDD exception: {reason}
- Generated code: Tested generator separately
## Testing Approach
- [x] TDD: Wrote failing tests first
- [x] Tests pass: output shows all pass
- [x] Refactored: Improved clarity while maintaining coverage
OR
- [ ] TDD: N/A (generated code)
- [x] Validated: Generator output matches expected schema
❌ Bad:
1. Write implementation
2. Manually test once
3. Open PR as "done"
4. Reviewer asks: "Where are the tests?"
5. Scramble to add tests
✅ Good:
1. Write failing test
2. Implement until test passes
3. Open PR with tests included
❌ Bad:
def test_feature():
# Feature not implemented yet
assert True # Always passes, tests nothing
✅ Good:
def test_feature():
result = my_function()
assert result == expected_value
# Run first — should FAIL (function doesn't exist)
TDD is a discipline, not a religion.
Use TDD when it helps:
Skip or adapt TDD when it doesn't:
The key principle:
"If you haven't watched the test fail, you don't know if it works."
When you skip the RED phase, at least manually verify the feature works and note that in your PR. Don't claim "done" without evidence.
| Phase | Action | Evidence |
|---|---|---|
| RED | Write failing test | Test output shows failure |
| GREEN | Implement feature | Test output shows pass |
| REFACTOR | Clean up code | Tests still pass |
Exceptions: Generated code, configs, docs, simple refactors
Key principle: Watch the test fail before claiming it works.