ces107

spec-trace-gate Skill

机器检查规范中的每条需求是否都有任务覆盖,每个任务是否都有真实存在的测试来验证(规范→任务→测试的可追溯性),任何遗漏需求、虚假引用或缺失测试都会导致失败。在编写验收标准、把规范拆解为任务、检查实现是否真正闭合其规范,或想给 CI 加需求覆盖率门禁时使用。

安装方式:把技能目录放入 ~/.claude/skills/(Claude Code)或在 claude.ai 设置中启用;也可复制右侧安装命令一键添加。

查看源码

技能指令原文(SKILL.md)

Spec ↔ task ↔ test traceability gate

Spec-driven workflows (GitHub Spec Kit, AWS Kiro, BMAD) give you Specify → Plan → Tasks → Implement,
but nothing proves the finished code closed over the spec. Drift is caught by a human, if at all.
This skill turns that proof into a pass/fail command.

The contract

Three inputs:

  1. Spec: acceptance criteria, each tagged with a stable id AC-N and written in EARS

(references/ears.md).

  1. Tasks: one block per task:
   ## T-3 — Race-safe idempotency under concurrent duplicates
   Serialise the check-then-insert so N concurrent duplicates yield exactly one result.
   covers: AC-3
   verified_by: test_concurrent_duplicate_key_single_posting
  1. Tests directory of the project (Python, TS/JS, Go, Java/Kotlin, Ruby and C# file

conventions are recognised by default; override with --test-glob).

The gate fails on any of:

| Violation | Meaning |
|---|---|
| UNCOVERED acceptance criterion | An AC-N in the spec that no task covers:. A requirement was dropped. |
| ORPHAN task reference | A task covers: an AC-N that is not in the spec. Phantom work, or a typo. |
| UNVERIFIED task | A verified_by: name that does not appear, as a whole identifier, in any test file. |

Procedure

  1. Find or write the spec. If the user has none, draft one from their request with

assets/spec-template.md and show it to them before going on. Each AC states one observable
behaviour, uses an EARS pattern, and keeps its id forever (never renumber; retire ids instead).

  1. Write the tasks file with assets/tasks-template.md. Small, single-responsibility tasks,

ordered so earlier ones unblock later ones. If a test does not exist yet, name the exact test
that must be written and say so in the task body.

  1. Structure check, right after planning (no tests needed yet):
   python <this-skill-dir>/scripts/trace_gate.py --spec <spec.md> --tasks <tasks.md> \
       --tests-dir <tests/> --structure-only
  1. Full check, after implementation: the same command without --structure-only.
  2. On FAIL, fix the cause, never the report:
  • uncovered AC → add or extend a task; only drop the AC if the user explicitly agrees;
  • orphan reference → correct the id, or add the missing AC to the spec with the user;
  • unverified task → write the named test, or point verified_by: at the real test name.

Never shorten a selector to a generic fragment just to make it match.

  1. Report the verdict line exactly as printed (TRACE: PASS / TRACE: FAIL) together with

the violation lines. Do not paraphrase a gate result.

  1. CI (optional, ask the user first): assets/ci-github-actions.yml runs the full gate on every

push and pull request.

Notes

  • scripts/trace_gate.py needs Python 3.10+ and the standard library only. It reads the three

inputs, prints a report and exits 0 or 1. It writes nothing and makes no network calls.

  • Matching is by whole identifier: test_replay does not match test_replay_across_restart.
  • A spec with no AC-N ids passes trivially. If you see acceptance criteria: 0, the spec is not

in the expected shape; fix that first.

  • For non-standard test layouts pass one or more --test-glob patterns (e.g. --test-glob '*.rs').