Go test
My personal pi harness configuration.
npx -y skills add nyquistwilder/personal-pi --skill go-testAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Go testing workflow for unit, integration, fuzz, benchmark, httptest, slogtest, race-aware, table-driven, and regression tests in greenfield modules. Use for creating, improving, validating, or reviewing Go tests.
SKILL.md
3.6 KB, as published. Nobody here has run it
Go Test
Rule
Test public behavior with deterministic, fast, race-free tests. Prefer the standard
testing package, table-driven cases, subtests, fuzzing for parsers, and benchmarks only
when performance is the contract.
Hard Stops
Stop before writing or running tests when:
- Tests would touch production services, real secrets, live databases, user home files, or mutable shared infrastructure.
- Adding test dependencies such as
go-cmp,testcontainers-go,testify, golden snapshot helpers, or clock libraries has not been approved or established by the project. - The behavior contract is unknowable from code, docs, existing tests, or user request.
- Race-prone concurrency cannot be observed deterministically.
Defaults
- Use
*_test.go,TestXxx,BenchmarkXxx, andFuzzXxx. - Put black-box tests in package
<name>_testwhen exercising public APIs; use same-package tests only for unexported behavior that is stable and valuable to test directly. - Prefer table tests with descriptive case names and
t.Run. - Use
t.Helper,t.Cleanup,t.TempDir, andt.Setenv. - Use
httptestfor HTTP servers/clients and avoid fixed ports. - Use
testing/slogtestfor custom slog handlers. - Use native fuzzing for parsers, decoders, normalizers, and state machines with broad input spaces.
- Use
go test -race ./...for concurrency changes and before release gates when practical.
Assertion Style
Prefer plain if got != want { t.Fatalf(...) } for simple values. Use cmp.Diff from
go-cmp for nested structs, slices, maps, protobuf-like data, or readable diffs. Avoid
testify in greenfield code unless the project has approved it; it often hides simple
control flow and adds a broad dependency.
Boundaries
- Time: inject clocks or use explicit synchronization. Avoid sleeps as proof of correctness.
- Filesystem: use
t.TempDir; assert permissions and paths when they are contract. - Environment: use
t.Setenv; do not depend on developer machine state. - Network: use
httptest.Serveror customhttp.RoundTripper; never call live services by default. - Databases: use transaction rollbacks, temporary databases, or approved containers; never point at developer or production DBs.
- Subprocesses: mock command runners for unit tests; use real subprocesses only for CLI or process-contract tests.
- Logging: test stable fields or handlers, not decorative formatting.
Workflow
- Inspect existing test layout, helpers, fixtures, and wrapper commands.
- For bugs, write or run a focused failing regression test first when practical.
- Cover success, failure, edge cases, cancellation, and error classification.
- Keep fixtures small and inline unless file format/path behavior is the contract.
- Run the narrowest package test first:
go test ./path/to/pkg -run TestName. - Run
go test ./...; add-racefor concurrency or shared-state changes. - Run fuzz seeds or benchmarks only when relevant.
- Run
just checkbefore handing back.
Coverage
Coverage is a signal, not the goal. Use go test -cover ./... when coverage policy exists
or when adding substantial code. Do not add shallow tests or exclusions only to raise a
number. Prefer mutation-resistant assertions over line coverage padding.
Completion
Report tests added or changed, commands run, race/fuzz/benchmark choices, coverage result when measured, and remaining untested risks.