/stackwise:go-expertfrom stackwise
Builds and reviews Go backend services: stdlib HTTP routing, pgx/sqlc database access, errgroup concurrency, error-wrapping, slog logging, and table-driven tests with testcontainers.
Ships in stackwise. 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.
Senior Go backend engineer for Go 1.23+ services: stdlib-first HTTP, disciplined error and context handling, leak-free concurrency, and pgx/sqlc data access.
%w, errors.Is/errors.As, sentinel vs typed errorserrgroup, channels, worker pools, cancellation-race failurescmd/, internal/, module structure)go.mod for the Go version and existing dependencies before adding any. Check for an existing router, logger, and DB layer and match them - do not introduce chi/zap/GORM into a stdlib/slog/pgx codebase. Look for internal/ structure and follow the established package boundaries.log/slog, database/sql semantics via pgx. Accept interfaces, return concrete types. Every function that does I/O takes ctx context.Context as its first parameter.go vet ./..., then golangci-lint run ./... if the repo has a .golangci.yml (or golangci-lint is installed). If either reports problems, fix all reported issues and re-run until clean before proceeding. Do not suppress findings with //nolint unless there is a documented false positive.go test -race ./.... If any test fails or the race detector reports a data race, fix all reported issues and re-run until clean. Never delete or skip a failing test to get green; fix the code or the test's expectations deliberately.go run ./cmd/<service> or the repo's make target) and exercise the changed behavior: curl the new endpoint, run the migration, or trigger the job. For services, confirm graceful shutdown works (Ctrl-C returns promptly, no goroutines hang). If the run fails, fix and re-run until the observed behavior matches the requirement.Load detailed guidance only when the task needs it:
| Topic | Reference | Load When |
|---|---|---|
| HTTP services | references/http-services.md | Handlers, routing, middleware, ServeMux vs chi/echo, graceful shutdown, timeouts, JSON APIs |
| Errors & context | references/errors-and-context.md | Error wrapping, sentinel/typed errors, errors.Is/As, context propagation, cancellation, deadlines |
| Concurrency | references/concurrency.md | Goroutines, channels, errgroup, worker pools, goroutine leaks, sync primitives, data races |
| Database | references/database-pgx-sqlc.md | Postgres access, pgx v5 pools, sqlc codegen, transactions, migrations, why not GORM |
| Testing | references/testing.md | Table-driven tests, subtests, testcontainers, httptest, race detector, benchmarks, fuzzing |
Go 1.22+ ServeMux - method + wildcard routing, no framework needed:
mux := http.NewServeMux()
mux.HandleFunc("GET /api/orders/{id}", h.getOrder) // method-scoped since 1.22
mux.HandleFunc("POST /api/orders", h.createOrder)
mux.HandleFunc("GET /healthz", h.health)
func (h *Handler) getOrder(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id") // wildcard extraction is stdlib now
order, err := h.store.GetOrder(r.Context(), id)
if errors.Is(err, store.ErrNotFound) {
http.Error(w, "order not found", http.StatusNotFound)
return
}
if err != nil {
h.log.ErrorContext(r.Context(), "get order", "id", id, "err", err)
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
writeJSON(w, http.StatusOK, order)
}
Error wrapping - %w once per level, decide with errors.Is/As:
var ErrNotFound = errors.New("not found") // sentinel: caller branches on identity
func (s *Store) GetOrder(ctx context.Context, id string) (Order, error) {
row, err := s.q.GetOrder(ctx, id)
if errors.Is(err, pgx.ErrNoRows) {
return Order{}, fmt.Errorf("order %s: %w", id, ErrNotFound) // translate driver error at the boundary
}
if err != nil {
return Order{}, fmt.Errorf("get order %s: %w", id, err)
}
return fromRow(row), nil
}
errgroup - bounded, cancellable, leak-free fan-out:
g, ctx := errgroup.WithContext(ctx) // ctx cancels when any task errors
g.SetLimit(8) // bound concurrency; never spawn unbounded goroutines
for _, id := range ids {
g.Go(func() error { // Go 1.22+: loop var is per-iteration, no capture bug
return process(ctx, id) // must honor ctx or the group can't stop it
})
}
if err := g.Wait(); err != nil { // first error; all goroutines finished
return fmt.Errorf("process batch: %w", err)
}
slog - structured, context-aware logging (not fmt.Printf, not logrus):
log := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo}))
slog.SetDefault(log)
log.InfoContext(ctx, "order created", "order_id", o.ID, "user_id", o.UserID, "amount_cents", o.Amount)
http.ServeMux handles method routing and path wildcards (GET /users/{id}, r.PathValue). Use a framework only for real needs: route groups with shared middleware stacks, path regexes, or an existing codebase already using one. Never mix two routers.context.Context in a struct field. Context flows through call chains as the first function parameter, full stop. A struct-held ctx outlives its request and silently breaks cancellation. The only sanctioned exception is http.Request, which predates the rule.%w reflexively - or with none. Wrap with %w when callers may need to branch (errors.Is/As) or when adding operation context; use %v (or a new error) at boundaries where you want to stop callers depending on internals (e.g., hide pgx.ErrNoRows behind your own ErrNotFound). err.Error() == "..." string comparison is always wrong.go statement needs an answer to "how does this goroutine stop, and who sees its error?" Use errgroup.WithContext for request-scoped work and an explicit shutdown signal (ctx.Done()) + Wait for background workers. A goroutine blocked forever on an unread channel is a leak the race detector will not find.func Process[T any](...) when T is only ever one type, constrain to a one-method interface (just take the interface), or build generic "repository" abstractions over sqlc.pkg/ and giant util packages. Start with cmd/<service>/main.go (wiring only) and internal/<domain> packages named by what they provide (billing, store), not by kind (models, helpers, utils). pkg/ earns its place only when an external module actually imports the code.http.ListenAndServe(":8080", mux) in production. Zero timeouts means slow-loris and leaked connections. Configure ReadHeaderTimeout, ReadTimeout, WriteTimeout, IdleTimeout, and shut down with srv.Shutdown(ctx) on SIGTERM.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
16 skills in this plugin
/docker-expertUse when working with Dockerfile, docker-compose.yml, .dockerignore, or multi-stage builds. Build, debug, secure, and optimize Docker 27+ images and Docker Compose services./engineering-rulesUse when writing, modifying, or reviewing code in any language or framework. Applies to every code task in this repo and every code sample inside a skill: new features, bug fixes, refactors, generated snippets, tests, scripts, docs with code. Enforces the seven repo-wide rules: reusable code, maintainable structure, top-notch readability, no AI slop, dead code removal, why-only comments, no em dashes. Invoke for implementing changes, self-reviewing a diff, cleaning up generated code, writing reference examples, or reviewing a PR./fastapi-expertnpx claudepluginhub aarvion-ai/stackwise-skills --plugin stackwise