tdd
The craft of the test-first loop for one slice: a test that fails for the right reason, the smallest code, a refactor, the checks of the area, then the proof. Use when you build or fix code in a slice or in /quick. The test list comes from testing-strategy.
- License 许可
- MIT
- 所属仓库
- lamtran8401/nook
- 最近更新
- 2026-10-27
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- tdd
- description
- The craft of the test-first loop for one slice: a test that fails for the right reason, the smallest code, a refactor, the checks of the area, then the proof. Use when you build or fix code in a slice or in /quick. The test list comes from testing-strategy.
- user-invocable
- false
03 SKILL.md 正文
Goal: code that a test proves, written in the smallest steps that work. A test that you saw fail for the right reason proves the code. A test that passed at once proves nothing.
Before you start
- Read the brief that
nook task take <id> <T>printed: the ACs, thedone whenline, the folder. - Read the tests next to the code you change. Copy their style: the same helpers, the same names, the same test doubles.
- Run the tests of the area once. Know what is green before you change anything.
- Take the test list of the slice from the Proof of the plan. With none, answer the five questions of the craft testing-strategy for each AC, two lines each:
${CLAUDE_PLUGIN_ROOT}/skills/testing-strategy/SKILL.md.
The loop
- Write one test for one behavior. Name it with the behavior:
returns the shipments that match the status. Arrange, act once, assert the visible result. - Run it. It must fail, for the reason of the AC. A missing import is not the right reason: add the stub and run again until the assertion fails. A test that passes at once: the test is wrong or the code exists. Stop and check.
- Write the smallest code that makes it pass. No code for the next test.
- Run the test, then the tests of the file.
- Refactor with the tests green, inside the scope of the slice: clear names, small functions, the helpers of the area, no dead code.
- Repeat for the next behavior, with one negative case for each AC: an input or a state that must be refused or left unchanged.
- Run the checks of the area (
checksinnook.yml). Fix each failure; the craft find-cause when the cause is not clear after one read. - Run
nook task done <id> <T> --tests <the new test files> --files <every changed file>. It runs your new tests on the base of the branch, without your change, then marks the slice done.proven: they fail there, and the slice is done.weak: they pass there, so they cannot fail.none: a load or import error; read the note. For a feature or a fix,weakandnonekeep the slice running: fix the test and runtask doneagain.
A good test
- One behavior, and the name says it. The expected value is written by hand.
- The fewest doubles. Mock the edge (network, database, clock), never the code under test.
- No sleep, no order between tests. It fails when the behavior is removed.
Gotchas
- A test that cannot fail is the most expensive line in the diff: it reads as proof and proves nothing. The proof says
weak, and the ruledefectsnames it. - Do not change a test to make code pass, and do not skip or weaken one. A test that is wrong now is a question:
nook task wait <id> <T> --reason. - A snapshot written with
--updatebefore the code existed proves nothing. - Edit only in the folder of the slice. A check that needs the running app is a manual check for the owner: say so in your summary.
- Keep the list of changed files while you work.
nook task done --filesneeds it.
04 同仓库更多 Skills
yolo
Run an item alone from its state to the owner's accept: the lead runs the phases, records each guess, passes the plan gate with proceed, and stops at a stop rule. Use when the owner types /yolo with an id, a prompt, or nothing.
write-walkthrough
Write walkthrough.md, the explanation of finished work: what works now in plain words, the changed files, where to start reading, the key code, the met criteria, how to try it, the risks. It is the source of the Walkthrough tab of the web app. Use after /qa, or for a question about the code.
wiki-tidy
Find what is wrong in the wiki: broken links, pages with no index line, lines too near the code, stale epic pages, topics with no source, two pages on one topic, adjectives with no example. Fix the mechanical part after one yes; list the rest. Use when the owner says tidy the wiki, or after many pages changed.
wiki-merge
Merge related wiki pages into one complete page: the pages of the features of one process or epic become one page with the flow from end to end. The old pages move to the archive after the owner's yes, and their links point at the new page. Use when the owner says merge these pages, or when wiki-tidy finds pages on one topic.
wiki-ask
Answer a question from the wiki: the index first, then only the pages whose line matches, an answer in a few lines with a link to each page. Use when the owner asks what the wiki says, or asks why or how about a known topic. Not to add a page: wiki-add.
wiki-add
Keep the lesson of a source in the wiki: a page in the shelf business/ or tech/ with its main points, a real example for each, the gotchas and the link of the source; written after the owner's yes. Use when the owner says add this to the wiki, keep this, or gives a PRD, a ticket, notes or an article to keep.