plugins/flow/skills/tdd-patterns/SKILL.md
Guide test-driven development through the mandatory Red-Green-Refactor cycle (failing test before code), enforce test quality (one behavior per test, real code over mocks, no implementation-detail testing), and enforce test runner discipline (run mode, no watch mode). Use when implementing features or fixing bugs (with `testing.tddMode='enforce'` blocking implementation without a failing test). This skill MUST be consulted because test-first is the primary quality enforcement point; tests that pass on first write are suspect (likely testing the wrong thing).
npx skillsauth add synaptiai/synapti-marketplace tdd-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Domain skill for test-driven development: Red-Green-Refactor cycle, test quality, and runner discipline.
IF YOU DIDN'T WATCH THE TEST FAIL, YOU DON'T KNOW IF IT TESTS THE RIGHT THING.
A test that has never failed might pass for the wrong reason. The RED phase exists to prove the test is valid.
For each feature or fix, track the TDD cycle with tasks:
TaskCreate("RED: Write failing test for {behavior}", "Minimal test describing desired behavior. MUST fail on first run.")
TaskCreate("GREEN: Implement {behavior}", "Simplest code to make the test pass. No cleverness.")
TaskCreate("REFACTOR: Clean up {behavior}", "Improve quality. All tests must still pass after each step.")
TaskUpdate(RED task, status: "in_progress")
TaskUpdate(RED task, status: "completed")
TaskUpdate(GREEN task, status: "in_progress")
TaskUpdate(GREEN task, status: "completed")
TaskUpdate(REFACTOR task, status: "in_progress")
TaskUpdate(REFACTOR task, status: "completed") Use TaskList to confirm the full cycle completed before moving to the next behavior.
The cycle is non-negotiable. RED → GREEN → REFACTOR. Always in this order.
Always use run mode, never watch mode:
| Framework | Correct | Wrong |
|-----------|---------|-------|
| Vitest | vitest run | vitest (watch) |
| Jest | CI=true jest or jest --watchAll=false | jest (watch) |
| Pytest | pytest | — |
| RSpec | rspec | guard (watch) |
Watch mode leaves orphan processes. Verify cleanup:
pgrep -f "vitest|jest|pytest" && echo "ORPHAN PROCESS — kill it"
# GOOD: Each test verifies one thing
test "returns empty array when no items match"
test "returns matching items sorted by relevance"
# BAD: Multiple behaviors in one test
test "search works correctly" # What does "correctly" mean?
Test names should read as specifications:
| Scenario | TDD? | Notes | |----------|------|-------| | New feature | Always | Define behavior before implementing | | Bug fix | Always | Write reproducing test first | | Refactor | Existing tests | Ensure tests pass before AND after | | Prototype/spike | Optional | But write tests before merging | | Config changes | No | Unless behavior changes |
Check settings.json → testing.tddMode:
| Mode | Default? | Behavior |
|------|----------|----------|
| enforce | Yes | Block implementation without a failing test. No exceptions. The RED phase must produce a failing test before any production code is written. |
| suggest | No (opt-in) | Recommend TDD. Allow override with explicit user decision. |
| off | No (opt-in) | No TDD guidance. Tests still run in verification. |
enforce is the default because skipping the RED phase is the #1 source of tests that pass for the wrong reason. Teams that need the old suggest behavior can opt out:
{
"testing": {
"tddMode": "suggest",
"tddModeOptOut": true
}
}
Set testing.tddModeOptOut to true in settings.json to switch tddMode back to suggest. When tddModeOptOut is false (the default), tddMode must remain enforce. This two-field design ensures the opt-out is an explicit, auditable decision rather than a silent default change.
Aim for meaningful coverage, not vanity metrics:
| Excuse | Response | |--------|----------| | "Skip TDD just this once" | Delete the code. Start over. The cycle is the discipline. | | "This is too simple to test" | Simple code, simple test. Write it in 30 seconds. | | "I'll write tests after" | You won't. And if you do, they'll test what you wrote, not what you should have written. | | "Tests slow me down" | Tests slow you down NOW. Bugs slow you down FOREVER. | | "The test passes on first try" | That's a red flag. It should have failed first. Check: is it testing the right thing? |
| Trigger | Action | |---------|--------| | Test passes immediately on first write | Test is suspect. Verify it fails when you break the code intentionally. | | >3 tests needed for one function | Function may be doing too much. Consider splitting. | | Mocking >2 dependencies | Design smell. Refactor to reduce coupling. | | Test is harder to write than the code | Step back. Either the interface is wrong or the test is testing implementation. |
tools
Validate a FlowWorkflow YAML at `plugins/flow/workflows/<id>.workflow.yaml` against `schemas/v1/workflow.schema.json` AND cross-reference the referenced skills/agents exist + every Tier 3 action is confirm-gated + no native /goal or /loop dependency is declared. Use when /flow:workflow validate is invoked, when CI runs the workflow schema gates, or when a new workflow is being authored. This skill MUST be consulted because schema validation alone catches shape errors; cross-reference validation catches the silent-correctness failures (typo'd skill name, Tier 3 escape, /goal dependency) that would otherwise ship to users.
tools
Verify UI-facing changes by running a screenshot-analyze-verify loop across configured viewports, with a browser-tool priority cascade (Playwright MCP → Chrome DevTools MCP → CLI fallback → external skill fallback) and bounded iteration. Use after build/runtime verification passes and the diff includes `.tsx`/`.jsx`/`.vue`/`.html`/`.css`/`.scss`/`.svelte` files OR the acceptance criteria mention UI/page/render/display/visual. This skill MUST be consulted because UI changes that pass build and unit tests can still ship blank pages, render-blocking console errors, or broken responsive layouts that no other verification phase catches.
data-ai
Coordinate agent teams for adversarial review (paired skeptic/verifier per facet, challenge round with disposition vocabulary, consolidated findings with confidence) or parallel implementation (task sizing 5-6 per teammate, non-overlapping files). Enforces independent analysis before shared conclusions. Reference only (`disable-model-invocation: true`); loaded only when `agentTeams: true` in settings.
development
Conduct two-stage code review: Stage 1 verifies spec compliance (criterion-to-code mapping), Stage 2 evaluates security, correctness, performance, and maintainability across 6 parallel facets with P1/P2/P3 synthesis and deduplication by file:line. Use when reviewing code changes or pull requests. This skill MUST be consulted because reviewing quality on broken logic is wasted effort, and unmet acceptance criteria must block merge.