一键导入
write-tests
Write tests (unit, property, or smoke) for a target file/function in this repo. Use when the user says "write tests for X" or "add tests".
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Write tests (unit, property, or smoke) for a target file/function in this repo. Use when the user says "write tests for X" or "add tests".
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Audit a file, package, or diff for cryptographic correctness, errs-go compliance, deserialization safety, and audit-scope risk. Use when the user asks to audit, review for security, or check before merging into in-scope code.
Audit code for timing side-channels — variable-time operations on secret values. Use when the user asks to check constant-time, timing, or side-channel safety of a file, function, or diff in this repo.
Run audit twice in parallel — once in this Claude session, once via OpenAI's Codex CLI — then merge the findings into unique-to-each / agreed-by-both buckets followed by both raw reports. Use when the user says "dual-audit <target>" or wants a second-opinion audit of a file, package, or diff.
Run pr-review twice in parallel — once in this Claude session, once via OpenAI's Codex CLI — then merge the findings into unique-to-each / agreed-by-both buckets followed by both raw reports. Use when the user says "dual-review PR
Run spec-compliance twice in parallel — once in this Claude session, once via OpenAI's Codex CLI — then merge the findings into unique-to-each / agreed-by-both buckets followed by both raw reports. Use when the user says "dual-spec-compliance <target>" or wants a second-opinion check of paper/spec/reference-implementation alignment for a package.
Review a GitHub PR by number against the repo's PR template, audit checklist, and conventions. Use when the user says "review PR
| name | write-tests |
| description | Write tests (unit, property, or smoke) for a target file/function in this repo. Use when the user says "write tests for X" or "add tests". |
| effort | xhigh |
You are adding tests in a crypto library. Tests must verify correctness, not just exercise the code path.
Identify the target. Read it. Don't write tests for code you haven't read.
Decide test type(s):
<x>_test.go): exact-value checks, edge cases, error paths, table-driven where natural.<x>_prop_test.go): invariants under random inputs, using pgregory.net/rapid. Use this for any algebraic identity, round-trip (encode/decode, encrypt/decrypt, commit/verify), or cross-implementation equivalence.<x>_smoke_test.go): one fast end-to-end happy path, typically enforcing interface compliance. Optional unless the surface area is large.<x>_bench_test.go): performance benchmarks.Coverage matrix — at minimum, for each function:
Style:
t.Run("subtest", func(t *testing.T) { … }) for organization.errs.Is(err, pkg.ErrInvalidArgument) to assert wrapped errors, not string match.rapid.Check.Correctness:
*k256.Point with == because it would mean pointer equality. Use the relevant internal methods like Equal(T) and alike if present.base/errors.go:ErrAbort), write a test that triggers that abort.t.Skip.CGO heads-up: most tests need BoringSSL. Run with the Makefile's CGO flags (see TESTING.md). When in doubt, run make test from repo root.
Output as GitHub-flavoured markdown. Use headers, bold, and code spans so the terminal renders a clear visual hierarchy. Show the new file content via the editing tools (Write/Edit), not by pasting it inside this report. Don't wrap the whole report in a fenced code block. Template:
## Tests for <target>
**File:** `path/to/x_test.go`
**Types:** unit, property, smoke _(whichever apply)_
### Test plan
- `TestFoo` — exact-value checks for the happy path
- `TestFoo_Errors` — wrapped-error assertions for each `New…` precondition
- `TestFoo_Property` — invariant: <one-liner>
- `TestFoo_Smoke` — interface compliance for `<scheme>`
### Run
`go test <pkg>` → **PASS** (N tests, T) — _or_ — **FAIL**: `<one-line summary>`
If any subtests fail, fix them or report the discrepancy — don't paper over with t.Skip. Quote the failing subtest name and the assertion that fired in the FAIL line.
assert (x == x)).t.Parallel() on tests that share fixtures or read package-level state without checking.