Skip to content
Back to skills

Common Tdd

ASecurity

Guides quality-first TDD for new behavior, bug fixes, and test changes. Selects the smallest test layer, proves a distinct regression risk, and runs bounded RED-GREEN-REFACTOR verification.

  • 584 stars
  • 0 votes
  • 0 copies
  • 9 views
  • Added June 6, 2026
developmentrustgojavatestinggitsecurity

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned November 25, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill common-tdd --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Common Tdd?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Common Tdd
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-common-tdd/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-common-tdd)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: common-tdd
description: "Guides quality-first TDD for new behavior, bug fixes, and test changes. Selects the smallest test layer, proves a distinct regression risk, and runs bounded RED-GREEN-REFACTOR verification."
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 coverage
---

# Quality-First TDD

## **Priority: P0 (CRITICAL)**

A passing test is insufficient; the test must prove an owned behavior and a distinct plausible fault.

## Choose the mode

- **New behavior:** strict RED -> GREEN -> REFACTOR. Do not write production code before the expected RED. If implementation preceded tests, report original RED as `NOT RUN`; never manufacture fake RED by deleting guards or falsifying logs.
- **Legacy or bug fix:** characterize only when needed, then reproduce the intended change as a failing regression (RED). Frozen old-revision proof against a pre-repair snapshot is valid regression evidence when explicitly labeled as `frozen_snapshot_red`. Preserve unrelated existing code; do not delete it merely because it predates the test.
## Before writing a test

Apply A1 (companion-file reuse, twin-extension migration) from `references/anti-slop-rules.md`: add cases to an existing
test file; never create a sidecar with duplicated mocks. Compare against the existing suite; ensure the scenario is not
already covered upstream or in nearby layers. Preserve justified cross-layer tests when layers catch distinct regression
risks.

Create one Test Intent Record per behavior/risk (see `references/quality-contract.md` for schema):
- Fields: `id`, `requirements`, `owner`, `contract` (observable contract — outward side effect), `fault` (distinct plausible fault, risk-sensitive), `layer` (smallest honest layer: `unit`, `integration`, `contract`, `e2e`), `cases` (minimal equivalence classes; use a parameterized test for equivalent inputs), `command` (exact focused single-run command), `oracle` (independent oracle ref, basis, owner, rationale; never copied solely from implementation), `boundaries` (real vs mocked).
- Reject tests that duplicate existing coverage without distinct risk, assert internal mock choreography, or copy expected output from implementation (A7, A12). Evidence receipts bind local consistency under `local-untrusted` trust; they cannot replace human review of oracle independence.

## Bounded loop

1. Run configured lint/type checks, inspect nearby tests, and derive smallest focused command.
2. **RED:** add one intent group and run foreground, sequential, single-run mode.
3. Classify RED as `expected_red`, `frozen_snapshot_red`, `not_run`, `invalid_red`, `unexpected_green`, or `verification_infra_failed`. Setup errors (syntax, import, missing modules, broken fixture) are `invalid_red`, NOT behavioral RED. On `unexpected_green`, inspect existing coverage and remove redundant or weak case before writing production code.
4. **GREEN:** implement only enough to satisfy `expected_red`; rerun same command.
5. **REFACTOR:** improve structure without changing behavior; rerun same command.
6. Escalate only when evidence requires it: related unit target, integration/contract target, then explicit release/full-suite gate.

## Layered Acceptance Protocol

1. **Source-Ready:** Complete owned source delivered at known source/build identity (`git rev-parse HEAD` + dirty identity). Build, lint, and typecheck recorded (`PASS`, `FAIL`, `NOT RUN`, `NOT APPLICABLE` with scope reasons).
2. **Focused Checks:** Unit, component, or contract targets covering owned slices. Derive test count and membership from raw runner output. Reject early zero-exit completions and no-listener runs (zero assertions executed).
3. **Consumer-Smoke:** Actual producer-to-consumer integration verifying outward side effects through real entrypoints (not mock echoes). Required where scope touches service boundaries or consumer contracts.
4. **Independent Review:** Separate task review checking specification compliance, code quality, boundaries, and security.
5. **Human Acceptance:** Explicit sign-off by human partner or authorized operator. Required for milestones/releases; agents cannot provide it.
Later edits invalidate affected proof only; rerun affected gates without weakening checks. Inapplicable layers recorded `NOT APPLICABLE`.

## Execution Safety, Red Flags & Rationalizations

- Honor project timeouts; fallback 120s to bound a focused command. On timeout, terminate only agent-owned process group and verify child cleanup.
- Never watch, blanket-kill, or retry unchanged failure. Record new hypothesis first.
- Risk-sensitive fault evidence: focus on plausible regressions in critical paths; keep only cases detecting a distinct fault or contract rule; use repository-configured coverage thresholds when they exist, or report risk gaps; never add padding tests for coverage percentages or blanket mutation scores.
- Red flags and rationalizations to reject: `add tests after`, `too small`, `passed first run`, `run the full suite again`, `mock every collaborator`, or `implementation is the oracle`. Urgency, manual testing, test count, or coverage target never bypasses intent record, expected RED, bounded command, or fault proof.
## Core Rules & Banned Smells

Apply the universal anti-slop rules A1–A14 in `references/anti-slop-rules.md` (companion reuse, identity fixtures, clause
flipping, tautologies, skip/focus, TS traps, mock echoing, bug-first lock, sleeps, shallow assertions, naming, coverage).
Assert observable outcomes and outward side effects, never mock choreography.

See `references/quality-contract.md` for the intent record schema, RED taxonomy, and escalation ladder.

Files in this skill

  • SKILL.md2.6 KB
  • references/aaa_example.md387 B
  • references/aaa_methodology.md1.2 KB
  • references/anti-patterns.md1.2 KB
  • references/best-practices.md1.9 KB
  • references/tdd_patterns.md1.2 KB
  • references/test_runners.md1014 B
  • references/testing_anti_patterns.md1.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.