AGENT SKILL

tdd-cycle

Drive one vertical slice of behaviour red-green-refactor, seam agreed before the first test. Use when the user asks to add a feature, fix a bug, write code test-first, says "TDD this", "red green refactor", or "write a failing test first". Inside a live dossier:build covenant, invoke dossier:build instead — it composes this skill's run-slice command as its RED/GREEN proof.

License 许可
ISC
最近更新
2026-11-13
Stars
★ 3
Forks
0

01 前言 Front Matter

name
tdd-cycle
description
Drive one vertical slice of behaviour red-green-refactor, seam agreed before the first test. Use when the user asks to add a feature, fix a bug, write code test-first, says "TDD this", "red green refactor", or "write a failing test first". Inside a live dossier:build covenant, invoke dossier:build instead — it composes this skill's run-slice command as its RED/GREEN proof.

02 资源文件 4

03 SKILL.md 正文

tdd-cycle — one slice, red before green

Test-first for ad-hoc work that no ledger is driving. Agree the seam, watch the test fail, make it pass, keep the suite green. Refactoring is a separate pass.

When to use

  • Adding a feature or fixing a bug where the test should define "done".
  • Any behaviour-bearing edit outside a dossier:build covenant. Under a covenant, dossier:build drives WHEN and WHAT and composes this skill's run-slice as its RED/GREEN proof (dossier ADAPTERS §whetstone); the §T row already fixes the seam, so the interview is skipped. One ledger drives one edit.

The seam (agree it first)

Before the first assertion, name the seam: the public boundary you test through — a function signature, an HTTP route, a CLI. Get the user's agreement on it. Assert behaviour through that boundary, so the test survives a refactor and fails when the behaviour is wrong. A wrong seam buys tests that pass over broken behaviour, or break on every rename. Highest-value moment in the loop; spend it.

The loop (one slice at a time)

  1. RED — write one failing test. Then prove it fails for the right reason:

    run-slice red --expect '<text the failure must print>' <test-command>
    

    run-slice red exits non-zero when the test passed — a test that never failed characterises nothing. With --expect, it also exits non-zero when the output does not match the pattern (an extended regex), so a failure from a typo or a missing import does not count as RED. Check the test against reference/anti-patterns.md and reference/examples.md before running it; mock only where reference/mocking.md allows.

  2. GREEN — minimum code to pass:

    run-slice green <test-command>
    

    Just enough for this one test.

  3. Full-suite gate:

    run-slice full <suite-command>
    

    The slice leaves everything else green.

  4. Next slice — one seam, one test, one implementation per cycle. Repeat from RED.

A test that fails, then passes on a rerun with no change, is a flake signal. Measure it before any fix:

FLAKE_TEST_NAME=<test-id> flake-runner 10 "$(mktemp -d)/results.json" <test-command>

It prints FLAKY <fails>/<runs> <rate> <test-id> when the rate is between 0 and 1. A flaky test gets the framework's skip marker and a tracking issue, not a code fix in this slice.

Refactor is a separate pass

Once GREEN and the suite passes, the slice is done. Cleanup and design improvement go to a review/simplify step, so a failure during red-green means exactly one thing.

Verification

Each slice: run-slice red exited 0 (the test genuinely failed first), then run-slice green and run-slice full exited 0. Three exit codes gate the slice.

Dossier breadcrumb

In a repo with a live dossier ledger, record the verdict as one §S line through the dossier plugin's append tooling (the host session reminds when applicable; the first live row is the current dossier). No dossier → skip: this skill ships no hooks and no dossier dependency.

04 同仓库更多 Skills

raisedadead
raisedadead/claude-code-plugins

suite-review

Run the monthly evidence review of this repo's plugin skills. Count each skill's opportunities and uses with the census, read what happened where a skill was not used, put each skill in one bucket, act, and write the actions as predictions with a check date. Use when the operator says "suite review" or "monthly review", or when the suite-review line on LATER.md is due.

★ 3
raisedadead
raisedadead/claude-code-plugins

tiger-style

Check the column budget of the lines a change adds, and read that change against the TIGER_STYLE shape rules a script cannot judge. Use when the user asks about line length or column limits, to check code shape, what the column check flagged, or why a commit was blocked on a column budget.

★ 3
raisedadead
raisedadead/claude-code-plugins

prototype

Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.

★ 3
raisedadead
raisedadead/claude-code-plugins

doubt-pass

Adversarial doubt cycle on a plan or design before any code exists — distinct from post-hoc code review. Use when the user asks to doubt this, stress-test a design before building it, poke holes in a plan, find the flaw in an approach, or before committing to a non-trivial architecture or design decision.

★ 3
raisedadead
raisedadead/claude-code-plugins

diagnose

Diagnose a hard bug or a performance regression with a feedback loop first, then ranked hypotheses, instrumentation and a regression test. Use when the user says diagnose or debug this, or reports something broken, throwing, failing or slow.

★ 3
raisedadead
raisedadead/claude-code-plugins

verify

Empirical fact-check for freshness-sensitive claims — versions, EOLs, package latest, GitHub Action SHAs, k8s apiVersions, AI model deprecations, image tags, or anything the model's training cutoff may have staled. Primary sources only. Auto-fires as a PreToolUse hook on Edit/Write, but only in a repo with a `.scratchpad/dossier/` directory; `/dossier:verify` on demand works anywhere. Invoke when user says "verify", "fact-check", "is this current", "/dossier:verify", "double check", or when reviewing freshness claims.

★ 3