author-go-test
ALWAYS invoke this skill when writing or fixing tests for Go. NEVER write or fix Go tests without this skill.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1
- Forks
- 1
01 前言 Front Matter
- name
- author-go-test
- description
- ALWAYS invoke this skill when writing or fixing tests for Go. NEVER write or fix Go tests without this skill.
- allowed-tools
- Read, Glob, Grep, Write, Edit, {{! tool('use_skill') !}}, Bash(go test:*), Bash(go vet:*), Bash(go build:*), Bash(gofmt:*), Bash(staticcheck:*), Bash(golangci-lint:*)
03 SKILL.md 正文
{!% require_skill 'go:go-code-standards' %!}
{!% require_skill 'go:go-test-standards' %!}
{!% require_skill 'product-tree:test' %!}
<objective>
Go test files that supply evidence, at the level and assertion type /test selects, for a product-tree node's assertions.
</objective>
<prerequisites>
The /test router, /go-code-standards, and /go-test-standards are pre-loaded above.
Before writing or revising tests, also check:
spx/local/go.mdat the repository root, if presentspx/local/go-tests.mdat the repository root, if present
</prerequisites>
<mode_detection> Determine the mode before editing:
| Mode | Signal | Action |
|---|---|---|
| Write | An assertion has no linked Go test, or /verify routed a new assertion to test |
Follow <workflow> |
| Fix | An /audit-go-test or /audit-tests verdict rejected existing Go evidence |
Follow <fix_workflow>, then rerun <workflow> steps 5 through 9 on the repaired file |
| Split | A rejected file carries more than one assertion type or execution level | Separate it into one file per cell, then continue as Fix |
</mode_detection>
<fix_workflow> Map each rejecting finding's property to the remediation it implies before editing:
| Finding property or rule | Remediation |
|---|---|
coupling |
call the governed function, type, package, or harness-built binary; remove the reassigned function variable or generated mock |
falsifiability |
replace the severed seam with a hand-written implementation of the same interface; assert on observations |
alignment |
exercise every clause of the assertion; match the evidence method to the assertion type |
coverage |
drive execution into the assertion-relevant path; remove t.Skip on a mandatory dependency |
oracle-independence |
derive the expectation from the spec, an exported constant of another package, an external schema, or a fixture |
declarations |
move the chosen data, expectation, or runner setting to its owner: source contract, generator, harness, or fixture |
predicate-ownership |
move the comparison and the testing.T failure call back into the Test* function or its subtest |
extraction_target |
move the harness, generator, or fixture resolver into internal/testinfra/ |
filename_policy |
rename to <subject>.<evidence>.<level>[.<runner>]_test.go; add the //go:build constraint an l2 or l3 file needs |
</fix_workflow>
<workflow>
- Load the governing spec context before editing any co-located
spx/.../tests/file. - Map each assertion to the assertion type and level chosen by
/test. - Apply the
/testsource-contract-first gate: read the assertion, the existing or planned test, and the Go code under test; state the production contract the evidence exercises. - If the source does not expose the typed constant set, constructor, interface boundary, parser entry point, registry, schema, or observable behavior the assertion needs, fix the source contract before writing test predicates.
- Use the
<router_mapping>and examples in/go-test-standardsto choose the Go implementation shape. - Keep every predicate and
testing.Tfailure call in the linkedTest*function or itst.Runsubtest. Permit:=,var,const, closure, and property-generated parameters that only receive actual results, source contracts, generated values, harness observations, callback inputs, resource handles, or fixture paths; reject bindings that choose data, expectations, configuration, setup policy, generator domains, fixture contents, or verdict rules. At.Helper()mark never moves a predicate into infrastructure. - Keep test infrastructure — harnesses, generators, and inert fixtures — in the canonical
internal/testinfra/location prescribed by/go-test-standards. A repo-local overlay may route to a governing product spec or decision that explicitly amends this contract; the overlay does not redefine the location itself. - Put
//go:build l2or//go:build l3on the first line of every Level 2 or Level 3 file, sogo test ./...runs Level 1 alone. - Run the repository's Go validation commands before reporting the tests complete, or the fallback sequence
gofmt -l .,go vet ./..., the repository's linter, andgo test -race ./....allowed-toolspreapproves only the listed raw-tool fallbacks; a repository-canonical wrapper outside those patterns uses the runtime's normal per-call approval path, and a fallback is never selected merely to avoid that approval.
</workflow>
<router_mapping>
After running through /test, use the canonical mapping in /go-test-standards:
| Router Decision | Go implementation summary |
|---|---|
| Stage 2 -> Level 1 | pure functions, t.TempDir(), hand-written interface implementations, in-cycle binaries |
| Stage 2 -> Level 2 | local services, containers, installed binaries |
| Stage 2 -> Level 3 | remote APIs, deployed workflows, browser automation, shared environments |
| Stage 3A | direct pure-function tests |
| Stage 3B | extracted pure function plus outer boundary evidence |
| Stage 5 exceptions | controlled implementations that preserve the real seam |
| compile-time contract | toolchain-oracle evidence |
| universal invariant | property-based evidence through the rapid harness |
</router_mapping>
<reference_guides>
All Go test examples are owned by /go-test-standards:
/go-test-standards<level_1_patterns>/go-test-standards<property_and_compile_time_patterns>/go-test-standards<level_2_patterns>/go-test-standards<level_3_patterns>/go-test-standardsreferences/level-1.md/go-test-standardsreferences/level-2.md/go-test-standardsreferences/level-3.md
</reference_guides>
<success_criteria> Go test work is complete when:
/testchose the assertion type and target level first- the source-contract-first gate was applied before test predicates were written or repaired
/go-code-standardsand/go-test-standardswere loaded before test code was written- the test shape follows the canonical Go test standard and repo-local overlays
- executed
Test*functions and subtests own every predicate andtesting.Tfailure call - test-file bindings introduce no case data, expectation, configuration, setup policy, generator domain, fixture content, or verdict rule
- controlled implementations preserve coupling to the real seam
- property claims use property-based testing through the harness
- compile-time claims use toolchain-oracle evidence
- Level 2 and Level 3 files carry their build constraint
- the repository's Go validation commands pass, or the fallback sequence in step 9 passes, with any unavailable tool named explicitly
</success_criteria>
04 同仓库更多 Skills
plugin
暂无简介
sanitize-powerpoint
ALWAYS invoke this skill when sanitizing, cleaning up, auditing, or aligning a PowerPoint (.pptx) deck — slide-master and layout structure, layout type attributes, stray fonts, non-theme colors, or layout naming. NEVER hand-edit pptx XML without this skill.
draw-excalidraw
ALWAYS invoke this skill when creating Excalidraw diagrams, visualizing workflows, architectures, or concepts. NEVER generate Excalidraw JSON without this skill.
typescript-test-standards
TypeScript test standards enforced across all skills. Loaded by other skills, not invoked directly.
typescript-code-standards
TypeScript code standards enforced across all skills. Loaded by other skills, not invoked directly.
typescript-architecture-standards
TypeScript ADR conventions enforced across architect and auditor skills. Loaded by other skills, not invoked directly.