AIStorageDepot
← Prompt library

Go Project Rules

Rule · Standards · #standards #go #agents-md

Go project rules

Standing orders for AI agents working in this repository. Drop into AGENTS.md or your tool's rules file.

Tooling

  • gofmt (or goimports) is law — run it before presenting code as done.
  • go vet ./... and the repo's linter must pass. Fix findings, don't silence them.
  • Use the module's Go version from go.mod; no newer language features.

Style

  • Return error, don't panic. Wrap with fmt.Errorf("doing X: %w", err) so chains unwrap.
  • Accept interfaces, return structs. Keep interfaces small and defined where they're USED.
  • Contexts flow first: func Do(ctx context.Context, …). Never store a context in a struct.
  • Zero values should be useful; avoid constructors that only zero fields.
  • No goroutine without a clear owner and shutdown path. Channels are for ownership transfer, mutexes for state.

Tests

  • Table-driven tests with t.Run subtests. testify only if the repo already uses it.
  • Test files live beside the code. New exported behavior ships with tests in the same change.

Boundaries

  • No new dependencies without asking — the standard library probably has it.
  • Don't edit generated files (*_gen.go, *.pb.go); change the generator input instead.

This is one of dozens of free prompts in the AIStorageDepot library. Sign up free to save them, version them, and pull them straight into Claude, Cursor, or VS Code over MCP.