pattern-engineer-go
Skill0 starsChanged 5 months agoMITView on GitHub
Modern idiomatic Go: pinned `go.mod`/`toolchain`; gofmt-clean; `go vet` + `golangci-lint run` + `go test -race ./...`; every error checked + wrapped via `%w`; `errors.Is`/`As`; no panic across API boundaries; `ctx` first param, never stored; small consumer-side interfaces, accept-interfaces/return-structs; every goroutine has an exit path (`errgroup`/`WaitGroup`); sender-closes-channel; zero-value structs; `defer` cleanup; MixedCaps; table-driven `t.Run` tests. Activate on `.go`, `go.mod`.
In this repository74 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- create-bug-issueSkill
- create-enhancement-issueSkill
- create-feature-issuesSkill
- dream-summary-memorySkill
- memory-conventionSkill
- operation-gitSkill
- pattern-architect-api-endpointSkill
- pattern-architect-data-modelSkill
- pattern-architect-deep-moduleSkill
- pattern-e2e-coding-standardSkill
- pattern-engineer-apiSkill
- pattern-engineer-backend-standardSkill
- pattern-engineer-coding-standardSkill
- pattern-engineer-containerSkill
- pattern-engineer-databaseSkill
- pattern-engineer-fastapiSkill
- pattern-engineer-frontend-standardSkill
- pattern-engineer-javaSkill
- pattern-engineer-kotlinSkill
- pattern-engineer-nodeSkill
- pattern-engineer-non-functionalSkill
- pattern-engineer-observabilitySkill
- pattern-engineer-pythonSkill
- pattern-engineer-rustSkill
- pattern-engineer-securitySkill
- pattern-engineer-ssrSkill
- pattern-engineer-swiftSkill
- pattern-engineer-typescriptSkill
- pattern-engineer-viteSkill
- pattern-exploratory-testingSkill
- pattern-reviewer-apiSkill
- pattern-reviewer-backend-standardSkill
- pattern-reviewer-coding-standardSkill
- pattern-reviewer-containerSkill
- pattern-reviewer-contractSkill
- pattern-reviewer-databaseSkill
- pattern-reviewer-fastapiSkill
- pattern-reviewer-frontend-standardSkill
- pattern-reviewer-goSkill
- pattern-reviewer-javaSkill
- pattern-reviewer-kotlinSkill
- pattern-reviewer-nodeSkill
- pattern-reviewer-non-functionalSkill
- pattern-reviewer-observabilitySkill
- pattern-reviewer-pythonSkill
- pattern-reviewer-rustSkill
- pattern-reviewer-securitySkill
- pattern-reviewer-ssrSkill
- pattern-reviewer-swiftSkill
- pattern-reviewer-test-coverageSkill
- pattern-reviewer-typescriptSkill
- pattern-reviewer-viteSkill
- pattern-test-coverageSkill
- principle-engineer-tddSkill
- scaffold-projectSkill
- workflow-architect-interviewSkill
- workflow-designer-sample-pagesSkill
- workflow-design-interviewSkill
- workflow-e2e-authorSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 2 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-go.md in the consuming project (resolve …
- Very specific: line 21
Keep code gofmt/goimports-clean.
- Very specific: line 23
Always go test -race ./...
- Very specific: line 24
Run go mod tidy and commit both go.mod and go.sum.
- Very specific: line 28
Check every returned error.
- Very specific: line 45
Keep them small — 1–3 methods (io.Reader-sized).
- Distinctive: line 47
No preemptive exported "for mocking" interfaces.
- Distinctive: line 51
Every goroutine has a defined exit path — no fire-and-forget.
- Very specific: line 52
Use errgroup.Group or sync.WaitGroup to track lifetime and surface errors.
- Very specific: line 77
No cargo-culted pkg/ — add it only when you deliberately export a library surface.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
pattern-engineer-go
When to activate
Activate when writing or editing any .go file, scaffolding a Go service or CLI, modifying go.mod / go.sum, tuning .golangci.yml, or running gofmt / goimports / go vet / golangci-lint / go test. Skip for non-Go code.
Project memory overlay
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-go.md in the consuming project (resolve MAIN_ROOT="$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")"). If present, load it as an additive overlay to the rules below; if absent, skip silently. See memory-convention for the full contract (additivity, severity floor, conflict surfacing).
Patterns
Toolchain & modules
go.modpins the language version (go 1.x) and an explicittoolchain go1.x.ydirective.- Keep code gofmt/goimports-clean; CI fails on a non-empty
gofmt -l .. - Lint gate is
go vet ./...+golangci-lint run; nothing merges red. - Always
go test -race ./...— the race detector is non-negotiable, not opt-in. - Run
go mod tidyand commit bothgo.modandgo.sum; never hand-editgo.sum.
Errors
- Check every returned error; never
_-discard one without an inline comment justifying it. - Wrap with context at each hop:
fmt.Errorf("loading user %d: %w", id, err)—%w, not%v, to keep the chain unwrappable. - Compare with
errors.Is/ extract witherrors.As— nevererr.Error()string matching. - Declare sentinels as package-level
var ErrNotFound = errors.New("not found"). - No
panicacross a package/API boundary — return an error.paniconly for unreachable programmer-error invariants. recoveronly at a goroutine's top frame in a long-running server; never as flow control.
Context
ctx context.Contextis the first parameter of anything doing I/O (DB, HTTP, RPC, file).- Propagate the caller's
ctx; never store one in a struct field. - Honor cancellation inside loops (
select { case <-ctx.Done(): ... }); checkctx.Err()before long work. - Wrap outbound calls in
context.WithTimeout/WithDeadlineanddefer cancel().
Interfaces
- Define interfaces at the consumer, not alongside the implementation.
- Keep them small — 1–3 methods (
io.Reader-sized). - Accept interfaces, return concrete structs.
- No preemptive exported "for mocking" interfaces; introduce one when a second caller or a real seam appears.
Goroutines & concurrency
- Every goroutine has a defined exit path — no fire-and-forget.
- Use
errgroup.Grouporsync.WaitGroupto track lifetime and surface errors; never spawn an untracked goroutine in a request handler. - A channel is closed by its sender only, never a receiver.
- Mutex (
sync.Mutex/RWMutex) guards shared mutable state; channels pass ownership/handoff.
Idiom
- Make the zero value useful — a freshly declared struct should be usable without a constructor where feasible.
deferthe cleanup immediately after acquiring the resource (f, err := os.Open(...); ...; defer f.Close()).- MixedCaps naming; no
Getprefix on getters; no package-name stutter (user.User, notuser.UserStruct). any/interface{}only where generics or a concrete type genuinely can't fit; reach for type parameters first.- Slice-aliasing trap:
appendmay mutate a shared backing array — copy or full-slice (s[a:b:b]) before handing a sub-slice to another owner. time.Durationfor durations — never a bareintof seconds/millis.
Tests
- Table-driven with
t.Run(tc.name, ...)subtests; one struct slice of cases. - Mark helpers with
t.Helper()so failures point at the caller. t.Parallel()where cases are independent and don't share mutable state.net/http/httptestfor handler tests — real*http.Request/ResponseRecorder, not hand-rolled fakes.- Coverage substance (what to test, the happy/edge/failure matrix) is owned by
pattern-test-coverage— follow it rather than restating here.
Layout
cmd/<app>/main.gois thin — flag/env parsing, wiring, then call into a package.- Application packages live under
internal/so they can't be imported externally. - No cargo-culted
pkg/— add it only when you deliberately export a library surface.
Adjacent skills
- Input validation, auth, error-envelope shaping, and HTTP wiring are language-agnostic — owned by
pattern-engineer-backend-standard/pattern-engineer-api. - Crypto, SSRF, injection, and secret handling are owned by
pattern-engineer-security; follow its catalogue rather than restating it here.
Tooling
gofmt -l . # List unformatted files (empty = clean)
goimports -l . # List files with bad/missing imports
go vet ./... # Built-in static analysis
golangci-lint run # Aggregated linters (lint gate)
go test -race ./... # Tests with the race detector
go mod tidy # Reconcile go.mod / go.sumAuto-fix before re-running checks:
gofmt -w . # Format in place
goimports -w . # Fix + group imports in place
golangci-lint run --fix # Apply auto-fixable lint findingsBaseline .golangci.yml
The scaffold ships this enabled set; treat it as the floor:
linters:
enable:
- errcheck # unchecked errors
- govet # go vet
- staticcheck # the SA/ST/QF analyzer suite
- ineffassign # ineffectual assignments
- unused # dead code
- errorlint # %w wrapping + errors.Is/As misuse
- bodyclose # unclosed http.Response.Body
- contextcheck # context propagation
- gosec # security analyzer (defers to pattern-engineer-security)go test -race ./... runs alongside the linters in the pre-push gate; a non-empty gofmt -l . also blocks the push.
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.

