/aimi-engineering:go-conventionsfrom aimi-engineering
Applies Go conventions for package layout, error wrapping, interface design, context propagation, concurrency, and table-driven tests.
Ships in aimi-engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Condensed, actionable conventions for structuring, error-handling, and
testing Go code — sourced from Effective Go and the go.dev documentation
(cross-checked against current docs via Context7 before finalizing), with two
supplementary style-guide conventions where they add something go.dev doesn't
spell out. Full-depth material and extended examples live under
references/; this file carries everything needed to write or review
idiomatic Go without reading further.
Attribution: Package layout, error handling, interface, context/ concurrency, and testing guidance below is adapted and modified from Effective Go and the go.dev documentation (The Go Authors, CC-BY 4.0). The comma-ok type-assertion and succinct-wrapping notes are adapted from the Uber Go Style Guide (Apache-2.0); the consumer-side interface framing is adapted from the Google Go Style Guide (CC-BY 3.0). None of these sources are reproduced verbatim — see
NOTICE.mdfor full attribution.
cmd/, internal/, package boundaries, package naming).http, json), never
what it contains (util, common, helpers, misc) — those names
invite unrelated code to accumulate with no cohesion.internal/ holds code the module does not want imported by other modules;
the Go toolchain mechanically enforces this — nothing outside the tree
rooted at internal/'s parent can import it. This is a compiler-enforced
boundary, not a naming convention.cmd/ holds one subdirectory per binary the module produces, each a
package main; go install module/cmd/prog@latest installs it directly.
Use cmd/ once a module produces more than one binary, or once a single
binary's main package needs supporting code that should not itself be
part of the module's importable API.internal/.golang-standards/project-layout is a disputed community template, not
an official or standard Go layout — Russ Cox has publicly pushed back on
it being called a standard. cmd/ + internal/ is the one piece of that
template actually backed by toolchain behavior; do not adopt its other
directories (pkg/, api/, configs/, ...) on the strength of that repo
alone. Prefer go.dev/doc/modules/layout
as the authoritative source for module organization.references/package-layout.md for layout examples at each module size.if err != nil { return ..., err }), never exceptions or ordinary
control flow via panic.fmt.Errorf("doing X: %w", err) — the %w verb
makes the result satisfy Unwrap() error, keeping the chain inspectable.
Since Go 1.20, fmt.Errorf also accepts more than one %w verb in a
single call, producing Unwrap() []error; errors.Join(errs...) combines
independent errors (e.g., from a batch of operations) the same way.errors.Is(err, sentinel) for sentinel-value
comparison and errors.As(err, &target) to extract a concrete error type
— both walk the full Unwrap tree. Never strings.Contains(err.Error(), …)
to detect an error kind; message text is not a stable contract.error returns, not panic. Reserve
panic for programmer errors and truly unrecoverable state, and only at
the top of a call chain a caller cannot reasonably continue past.v, ok := x.(T) — when there is any chance x isn't a T. The
single-value form panics on mismatch, turning a data problem into a crash.references/error-handling.md for wrapping depth, sentinel-vs-typed
error tradeoffs, and errors.Join batch-error examples.var _ SomeInterface = (*ConcreteType)(nil). This
turns accidental interface drift into a compile error instead of a
surprise at the call site.references/interfaces.md for producer-vs-consumer examples and the
compile-time satisfaction-check pattern in more depth.context.Context is the first parameter of any function doing I/O,
RPC, or long-running work, conventionally named ctx, and flows explicitly
through the call chain — it is never stored inside a struct field.context.WithCancel /
context.WithTimeout / context.WithDeadline, and always defer cancel() immediately after creating the derived context so resources
are released once the enclosing function returns, whether or not the
timeout fired.sync.WaitGroup, a closed/buffered channel, or an
errgroup.Group. A goroutine with no way for its caller to learn it
finished, or to stop it, is a leak waiting to happen in a long-running
service.sync.Mutex/sync.RWMutex to
guard simple shared in-memory state (a map, a counter) accessed
concurrently. Neither is a default — pick the one that matches whether
you're transferring ownership or protecting shared state.references/context-and-concurrency.md for goroutine-leak examples
and a worked channels-vs-mutex decision walkthrough.for _, tt := range cases { t.Run(tt.name, func(t *testing.T) { ... }) }. Subtests give per-case pass/fail output and let cases run in
isolation.{name: "...", in: "...", want: "..."}) once a table has more than two or three columns — positional
literals stop being self-describing as columns are added.references/testing.md for a full table-test template and guidance on
when a table is the wrong tool (cases needing genuinely different setup).result, _ := someCall()) instead of
checking and handling or propagating it.error.errors.Is/errors.As.context.Context in a struct field instead of passing it
explicitly as each function's first parameter.context, no WaitGroup, no channel signaling completion.golang-standards/project-layout as the standard Go project
layout rather than a disputed community template.util, common, helpers, or core used as a dumping
ground instead of a cohesive, purpose-named package.Before accepting Go code in review, confirm:
internal/ hides implementation detail; cmd/ holds one main per
binary; no package is named as a generic dumping ground.%w and add real context;
callers branch with errors.Is/errors.As, never message matching.ctx context.Context as its first
parameter; no Context lives in a struct field.t.Run subtests.For extended examples, edge cases, and the two supplementary style-guide notes, read on demand (not auto-loaded):
references/package-layout.md — module layout at each size, package
naming, the golang-standards/project-layout controversy in full.references/error-handling.md — wrapping depth, sentinel vs. typed
errors, errors.Join/multi-%w, comma-ok type assertions.references/interfaces.md — consumer-vs-producer interface examples,
compile-time satisfaction checks.references/context-and-concurrency.md — goroutine-leak patterns,
channels-vs-mutex walkthrough, errgroup usage.references/testing.md — table-test template, subtests, when tables
don't fit.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub aimi-so/aimi-engineering-plugin --plugin aimi-engineering19 skills in this plugin
/agent-browserBrowser automation using Vercel's agent-browser CLI. Use when you need to interact with web pages, fill forms, take screenshots, or scrape data. Alternative to Playwright MCP - uses Bash commands with ref-based element selection. Triggers on "browse website", "fill form", "click button", "take screenshot", "scrape page", "web automation"./agent-native-architectureBuild applications where agents are first-class citizens. Use this skill when designing autonomous agents, creating MCP tools, implementing self-modifying systems, or building apps where features are outcomes achieved by agents operating in a loop./Other plugins' skills for the same job