testing-policy-creator
Writes, or brings up to date, a repo's own testing-policy skill at .claude/skills/testing-policy/SKILL.md: which code gets which kind of test, with which doubles, asserting what, and why. Surveys the codebase for its layers and boundaries, proposes a draft map, grills the user on it row by row, then lists the tests and boundaries that break the policy. Use when the user says "create a testing policy", "write our testing-policy skill", "decide what we test in this repo", "which tests should we keep", "our tests are a mess, set some rules", "purge tests that don't conform", or asks to update an existing testing policy. Not for writing a test (use the language's testing skill and tdd) or reviewing a diff.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- testing-policy-creator
- description
- Writes, or brings up to date, a repo's own testing-policy skill at .claude/skills/testing-policy/SKILL.md: which code gets which kind of test, with which doubles, asserting what, and why. Surveys the codebase for its layers and boundaries, proposes a draft map, grills the user on it row by row, then lists the tests and boundaries that break the policy. Use when the user says "create a testing policy", "write our testing-policy skill", "decide what we test in this repo", "which tests should we keep", "our tests are a mess, set some rules", "purge tests that don't conform", or asks to update an existing testing policy. Not for writing a test (use the language's testing skill and tdd) or reviewing a diff.
02 资源文件 3
- 参考文档references/example-go-policy.md5.2 KB
- 参考文档references/policy-template.md3.2 KB
- 参考文档references/principles.md7.2 KB
03 SKILL.md 正文
Testing policy creator
Produces one file in the target repo: .claude/skills/testing-policy/SKILL.md. That skill
decides what is tested and why. How a test is written (assertions, tables, helpers) belongs
to the language's testing skill (go-testing for Go); the policy names it and never restates it.
A good policy does two jobs at once. It stops regressions, and it makes the codebase legible: a reader who knows the map knows what each layer is for, because each row says what behaviour the layer promises and which test proves it. Code that fits no row is a design finding, not a gap in the map.
Read references/principles.md before drafting. It holds the rules for choosing what earns a test, picking its size and doubles, and reading untestability as coupling. references/policy-template.md is the output shape, and references/example-go-policy.md is a finished policy from a Go service to calibrate against.
1. Check for an existing policy
If .claude/skills/testing-policy/SKILL.md exists, this is an update. Treat it as the draft:
explore as below, then grill only on what changed (new layers, rows the code no longer matches,
rules the tests ignore). Never overwrite it wholesale.
2. Survey the codebase
Dispatch Explore sub-agents in parallel, one per question, and keep only their conclusions:
- Stack. Languages, test runner, test file convention (
foo_test.go,foo.test.ts,test_foo.py), fixture and snapshot locations, and which testing skill applies. - Layers. The architectural layers or modules and the exported surface each offers callers (services, stores, handlers, adapters, consumers, UI components). Name each by what it does.
- Boundaries. Every out-of-process dependency, split into managed (only this app touches it, e.g. its own database) and unmanaged (others observe it: third-party APIs, queues, email, LLMs). This decides doubles.
- Existing tests. For each test file: the source file it pairs with, the layer it exercises, its size, its doubles, and what it asserts. Flag files pairing with no source file, fixtures no test reads, tests of unexported code, and assertions on calls between the repo's own packages.
- Boundary gaps. Code that cannot be tested through an exported surface without reaching into internals, standing up the whole app, or mocking the repo's own packages. Note the seam each would need.
3. Draft the map
From the survey and the principles, draft one row per layer: code, test file, size, doubles, what it asserts, and a short "guards" note naming the regression or promise the row protects. Add the never-tested list and the boundary gaps. Start from the core rule in the template.
Where an existing test already shows a row's shape well, lift a trimmed version of it as that row's example. Examples illustrate a rule; they are chosen because they are good, not because they exist.
4. Grill
Call the Skill tool with "grilling" and give it this agenda, one branch per item:
- The core rule, and whether this repo's file convention overrides it.
- Each map row: does the layer exist as described, is this the right size and doubles, does the assertion target behaviour a caller observes.
- The never-tested list.
- Doubles: fidelity order, where fakes live, whether a fake needs a contract suite.
- When interaction assertions are allowed.
- Each boundary gap: keep it in the policy as a named gap, or drop it.
5. Write the policy
Write .claude/skills/testing-policy/SKILL.md from the template. It states rules that hold
whenever it is read, so it never describes the repo as it was on the day it was written: no
inventory of current tests, no "X is the pilot", no "bring code onto the policy when touched",
no counts or dates. Its description uses the standards-skill shape (TRIGGER — load BEFORE writing, editing or reviewing a test … SKIP …) so it loads on plain "add a test" requests.
Write the reasoning behind each row (the evidence from the survey, the principle applied, the grilling answer) to a rationale file outside the repo, in the session scratchpad or the system temp directory. It is a review aid only; tell the user it is safe to delete once they have read it.
6. Report and hand off
- Add one line to the repo's
AGENTS.md(create it if missing) pointing at the policy:Before writing or reviewing a test, load the testing-policy skill. - Print the tests that break the policy, grouped by the rule they break, then the boundary gaps with the seam each needs. Recommend delete, rewrite or move for each test; change nothing.
- Ask once whether to file both lists as one purge issue. On yes, call the Skill tool with "file-issue".
- Give the path to the rationale file.
04 同仓库更多 Skills
vault-recall
Answer the user's conceptual or technical question using their Obsidian vault as well as general knowledge. Use when the user asks a question (not a task) whose topic appears in the vault MOC digest from session start. Not for task instructions, not mid-task, and not for writing to the vault (that is to-vault).
ingest
Ingest one external source (an article, course lesson, doc, PDF or URL) into the user's Obsidian vault: save the original to raw/, then build wiki/ pages per the vault's § Ingest. Use when the user types /ingest, or says "ingest this", "add this source to my wiki", "put this article/lesson in the vault as a wiki page". Works from any repo. Routing rule: someone else's words go to wiki/ (this skill); the user's own learnings and decisions go to notes/ (/to-vault).
to-tickets
Breaks a source into independently-grabbable GitHub tickets. For a code feature the source is the plan (`docs/plans/<feature>.md`, from /to-plan) and every new or changed symbol lands in exactly one ticket, its signatures copied into the ticket body; a non-code feature is cut from the PRD's slices. Cuts tickets for one feature per run. If a code feature has no approved plan, offers /to-plan instead of cutting from prose. In a repo that runs command-centre, also emits `[[task]]` blocks into its config; in a plain treepad repo, emits a Batch Manifest instead so the tickets materialise as stacked worktrees.
to-seams
Records an agreed-but-unlanded cross-repo interface as a seam: the file a consumer's agent gets pasted into its prompt as ground truth, plus the `[[seam]]` block command-centre reads for the retirement pointer. Use when two repos need to build against an interface neither has landed yet — "record a seam for X", "we agreed on this schema, seam it", "add a seam so Y can build against Z's new field". Halts for approval before writing either file.
to-roadmap
Prioritises settled features into a Now / Next / Later kanban board, rendered as a self-contained ./ideas/roadmap.html. Each card is a feature, not a ticket — one card later becomes several tickets via /to-prd -> /to-plan -> /to-tickets. Boards the features in ./docs/approach.md, or the "## Accepted ideas" in ./ideas/CONTEXT.md when there is no approach doc. The approach doc is settled truth: this assigns tiers and reasons about ordering, it never re-litigates what was decided.
to-prd
Turns one feature idea into a PRD built on journeys: a one-line problem, journeys (each ending in an observable state) and delivery slices that say what is usable after each. Interviews, explores the codebase, and saves to docs/prds/<feature>.md. Covers exactly one feature: given a multi-feature source, ask which one. Reads any approach doc or ideate report as priors so it doesn't re-ask what's settled, but needs none. Starts the per-feature spine (/to-prd -> /to-plan -> /to-tickets).