golang-testing
Skill22 starsChanged 15 days agoMITView on GitHub
Write, review, or prune Go tests: unit, integration, HTTP, concurrent, fuzz, benchmark. Use when adding tests (including to raise coverage), judging whether existing tests prove anything, choosing fixtures/fakes/clocks, or diagnosing flaky tests.
51 other projects use a version of this.
Adopted by
Most recently taken up by
- Rojios/everything-claude-codetheir own version, first seen Nov 8, 2026
- ahmadvahidi/skill-atlastheir own version, first seen Nov 8, 2026
- TeddyAlbina/skillstheir own version, first seen Nov 1, 2026
- TsinHzl/claude-code-configtheir own version, first seen Nov 1, 2026
- samber/cc-skills-golangtheir own version, first seen Nov 1, 2026
- poizoncoded/skillstheir own version, first seen Nov 1, 2026
Used with
Projects with it also use golang-how-to and golang-samber-lo.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
alexastrumSkillgolang-how-to
Golang skills orchestrator — always active on any Golang coding, review, debug, or setup task. Reads the task context and loads the most relevant skills from samber/cc-skills-golang, often multiple at once: writing a gRPC service loads golang-grpc + golang-testing + golang-error-handling; debugging a panic loads golang-troubleshooting + golang-safety; auditing security loads golang-security + golang-lint + golang-safety. Also: disambiguates competing clusters when two skills seem to overlap (performance vs benchmark vs troubleshooting, samber/lo vs mo vs ro, DI cluster, safety vs security), and configures CLAUDE.md or AGENTS.md to force-trigger skills in a project (/golang-how-to configure).
Also in 7 projects that use this
guynhsichngeodiecSkillgolang-samber-lo
Functional programming helpers for Golang using samber/lo — 500+ type-safe generic functions for slices, maps, channels, strings, math, tuples, and concurrency (Map, Filter, Reduce, GroupBy, Chunk, Flatten, Find, Uniq, etc.). Core immutable package (lo), concurrent variants (lo/parallel aka lop), in-place mutations (lo/mutable aka lom), lazy iterators (lo/it aka loi for Go 1.23+), and experimental SIMD (lo/exp/simd). Apply when using or adopting samber/lo, when the codebase imports github.com/samber/lo, or when implementing functional-style data transformations in Go. Not for streaming pipelines (→ See golang-samber-ro skill).
Also in 9 projects that use this
Other versions51 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 51
- samber/cc-skills-golang★ 3.8ksame name
- sazardev/goca★ 299same name
- loulanyue/awesome-claude-notes★ 272same name
- unxed/f4★ 261same name
- Fmarzochi/EGC★ 61same name
- jmrplens/gitlab-mcp-server★ 47same name
- jmrplens/libgen-mcp★ 31same name
- castle-x/skills-x★ 18same name
- klawisha012/agentsync★ 18same name
- alexastrum/skl★ 11same name
41 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository56 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .kiro/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- aip-cordis-v4Skill
- aip-pr-deliverySkill
- codegraphSkill
- golang-benchmarkSkill
- golang-cliSkill
- golang-code-styleSkill
- golang-concurrencySkill
- golang-contextSkill
- golang-continuous-integrationSkill
- golang-databaseSkill
- golang-data-structuresSkill
- golang-dependency-injectionSkill
- golang-dependency-managementSkill
- golang-design-patternsSkill
- golang-documentationSkill
- golang-error-handlingSkill
- golang-grpcSkill
- golang-hexagonal-architectureSkill
- golang-lintSkill
- golang-modernizeSkill
- golang-namingSkill
- golang-observabilitySkill
- golang-performanceSkill
- golang-popular-librariesSkill
- golang-project-layoutSkill
- golang-safetySkill
- golang-securitySkill
- golang-simplifySkill
- golang-solid-principle-reviewSkill
- golang-stretchr-testifySkill
- golang-structs-interfacesSkill
- golang-thermonuclear-code-reviewSkill
- golang-troubleshootingSkill
- kiro-debugSkill
- kiro-discoverySkill
- kiro-implSkill
- kiro-review-panelSkill
- kiro-reviewSkill
- kiro-spec-approveSkill
- kiro-spec-archiveSkill
- kiro-spec-batchSkill
- kiro-spec-designSkill
- kiro-spec-initSkill
- kiro-spec-quickSkill
- kiro-spec-requirementsSkill
- kiro-spec-statusSkill
- kiro-spec-tasksSkill
- kiro-steering-customSkill
- kiro-steeringSkill
- kiro-validate-designSkill
- kiro-validate-gapSkill
- kiro-validate-implSkill
- kiro-verify-completionSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 47 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
No source or no mutant means no test.
- Distinctive: line 22
Find claims: Read these, in order, and collect the behaviour each one requires of the code under change:
- Very specific: line 52
Trivial code: Test a getter, String(), or constructor only when its output is itself a contract: a wire value, a config key, a validation …
“Common” is measured: kept by at least 6 in 10 of the 47 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go testing
A test earns its place by defending a claim: one sentence naming behaviour that someone outside the code depends on, and that a plausible bug would break. Coverage is a by-product of tested claims, never a reason to write a test.
Each claim has three parts:
- Claim: what callers, users, or operators observe. "A request with an unknown proxy key gets 401 and never reaches a backend."
- Source: where that behaviour is required, named concretely (file, symbol, issue, steering line).
- Mutant: the concrete bug the test catches. "Delete the
!okcheck inGate.ServeHTTP."
No source or no mutant means no test.
Reviewing existing tests instead of writing new ones: follow review.
Writing tests
- Find claims. Read these, in order, and collect the behaviour each one requires of the code under change:
- the task, issue, or bug report you were given;
.kiro/specs/<feature>/requirements.mdacceptance criteria, when the work belongs to a spec;- the godoc of each exported symbol you are testing;
- "High-Value Semantic Targets" in
.kiro/steering/testing.mdand "Architecture Guardrails" inAGENTS.md; - what the callers of the code do with its return values and errors.
- Write the claim table before any test code. One row per claim: claim, source, mutant. A row whose source is "this line is uncovered" or "the function exists" is struck out.
- Choose where to observe the claim:
- pure logic or decisions: call the function directly, table test with one row per distinct outcome;
- HTTP handler or middleware:
httptest, asserting status, body, and what reached the next handler or backend; - frontend/backend/core protocol behaviour: add a case to the existing suite under
internal/testkit/contract/before building a new harness; - external service or slow dependency: fake only that boundary; use real
pkg/aipapitypes everywhere else.
- Write the test. Assert both what the caller receives (value, error class, status, events) and the side effect that must or must not happen (backend called or not, row persisted or not, retry attempted or not). Name it
Test<Unit>_<Claim>:TestGate_UnknownKeyNeverReachesBackend, notTestServeHTTP2. Hard-code expected values worked out from the source, e.g.want := 6, never recomputed with the code's own formula. - See it red. For each row:
- Under TDD, run the test before the implementation exists and confirm it fails.
- For code that already exists, edit the production code to the mutant, run
go test -run '^TestName$' ./path/to/pkg, confirm FAIL, undo exactly that edit, re-run to PASS, and confirmgit diffon the production file shows no leftover mutant. - A test that stays green under its mutant asserts the wrong thing. Fix the assertion, not the mutant.
- Check every test against these questions. Any "no" means rewrite or delete it:
- Does its name state the claim?
- Is the source a concrete requirement, contract, invariant, or bug?
- Was it observed red under its mutant?
- Would it still pass after a refactor that keeps behaviour the same?
Hand off the claim table with the red result, plus a list of code you left uncovered and why:
Test Claim Source Mutant → result TestGate_UnknownKeyNeverReachesBackendunknown key → 401, next handler not called testing.md: authorization boundariesremoved !okcheck → FAIL
Coverage targets. When a task asks for a coverage percentage, write the claim-backed tests, then report the remaining shortfall and the uncovered code by name. Uncovered code either serves a claim you missed (add the claim) or serves none (report it as dead or speculative). A coverage request never justifies a dummy test.
Trivial code. Test a getter, String(), or constructor only when its output is itself a contract: a wire value, a config key, a validation rule in the constructor. Then the claim is that contract, e.g. "New rejects an empty key map".
Dummy tests
These pass against broken code or break on harmless refactors. Never write them; delete them when found.
| Pattern | Looks like | Do instead |
| Existence check | if New(...) == nil { t.Fatal() } | Delete. Claim tests already construct the value. |
| Getter echo | New("a").Name() == "a" | Delete. |
| Discarded result | _ = l.Allow(ctx, "t"), then assert something else | Assert the returned value. |
| Smoke only | only err == nil, or "does not panic", on a function that produces output | Assert the output. |
| Mock echo | fake returns X; test asserts X came back | Assert what the unit does with X: transforms it, maps the error, decides. |
| Mirrored oracle | want := l.Limit() - l.used["t"] | Hard-code want := 6, derived from the source. |
| Testing Go or a library | JSON tags round-trip, const == literal, errors.Is works | Delete. If the wire shape is the contract, assert the exact bytes a client receives. |
| Change detector | reads private fields, asserts internal call order, exact log or metric text | Assert the public outcome. Assert call order only when order is the contract. |
| Padding rows | ten table rows that all take the same path | One row per distinct outcome or boundary: empty, at limit, limit+1, malformed. |
| Unrun gate | build tag or env var no Makefile target sets | Wire it into a documented target, or delete it. |
| Tested scaffolding | tests for a test helper or fake | Simplify the helper until it is obviously correct. |
Go-specific gotchas
t.Fatal/FailNowonly from the test goroutine; workers send errors back for assertion after synchronization.t.Context()(Go 1.24+) is cancelled just beforet.Cleanupfunctions run; use it for code that must stop with the test.testing/synctest(Go 1.25+) or an injected clock for timer/deadline ordering.time.Sleepis never synchronization; a timeout bounds a test, it does not fix a race.-racedetects races only on exercised paths and cannot prove absence. In this repo never run-racelocally: scheduled remote scans own race coverage and it is not a merge gate; seeAGENTS.mdVerification.- Packages that own goroutines need a test-owned shutdown path for each;
goleak.VerifyNone/VerifyTestMainprovesStopactually releases them (filter unavoidable runtime goroutines). - Fuzz parsers and decoders that take untrusted input; the oracle is a contract property (round-trip, typed error instead of panic, output stays escaped), with a minimal seed corpus.
httptest.NewRecorderskips the transport: usehttptest.NewServerwhen headers, streaming flush, connection close, or client behaviour is the claim.sql.Opendoes not connect; prove readiness withPingContextunder a deadline.- Benchmarks:
b.Loop()where the module's Go version supports it,b.ReportAllocs()when allocations are the claim, compare runs withbenchstat. - Flakes: reproduce with
-count=Nand fixed seeds; fix the synchronization, never weaken the assertion.
Repo test policy (layers, proportionality budget, gating, commands) lives in .kiro/steering/testing.md and overrides this skill.
References: helpers, HTTP tests, integration tests, fakes and mocks.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

