Inputs the agent needs
- Path(s) to repo(s)
- Supported Go versions/targets (GOOS/GOARCH), CI provider
- Org policies: min Go version, crypto/TLS/FIPS/security rules, license policy
──────────────────────────────────────────────────────────────────────────────
- Detect toolchain:
go version;go env -json;go env GOTOOLCHAIN(note if set). - Parse module roots: find all
go.mod(monorepo?) and their module paths. - Record CI runners / Dockerfiles / build scripts that install Go. Match toolchain expectations.
Exit if:
-
gonot found OR conflicting versions across CI/dev/container; report locations & versions.
──────────────────────────────────────────────────────────────────────────────
- For each module:
-
godirective is the minimum language version actually required (prefer1.24+ if 1.24 features are used). Flag artificially high values. - If using a preferred toolchain:
toolchaindirective present and sensible; verify CI honors it. Add note ifGOTOOLCHAINwill auto-upgrade. - Zero unexpected
replacedirectives (allow only documented local/dev overrides); fail if any stray replaces remain. - Hygiene:
go mod tidyproduces no diff;go.sumtracked. - Private deps:
GOPRIVATE/GONOPROXYrespected in CI; if private fetch needed, check presence or plan forGOAUTH.
-
- Version selection sanity:
- Explain MVS to output: do not force latest everywhere; ensure
go(main) ≥ every dep’s stated minimum. - Emit a report of direct deps needing upgrade (security/critical fixes) vs “optional” bumps.
- Explain MVS to output: do not force latest everywhere; ensure
Artifacts:
- Attach
go mod graph+go list -m -json alldigests, and a tidy diff summary if any.
──────────────────────────────────────────────────────────────────────────────
- Confirm
go buildembeds VCS version (++dirtyif applicable). If hermetic builds are required, ensure-buildvcs=falseused and documented. - Ensure release builds record version via
runtime/debug.ReadBuildInfo(surface in--versionor logs).
──────────────────────────────────────────────────────────────────────────────
- Generics/type system
- If type aliases with type params make APIs clearer, confirm use of generic type aliases; reject gratuitous complexity.
- Finalizers / cleanup
- Prefer
runtime.AddCleanupoverruntime.SetFinalizerin new code. Check for cycles/leaks and multiple cleanups.
- Prefer
- Weak references
- If weak refs are present, ensure justified and implemented via
weakpackage; document ownership semantics.
- If weak refs are present, ensure justified and implemented via
- Filesystem safety
- For dir-scoped operations on untrusted input, prefer
os.OpenRoot/os.Root(oros.OpenInRoot) to avoid path escape; never initialize the root from user input.
- For dir-scoped operations on untrusted input, prefer
- Allocation-friendly iteration
- Where splitting/iterating large strings/bytes, consider
bytes.Lines/SplitSeq/FieldsSeqandstrings.*Seqhelpers; keep code clear.
- Where splitting/iterating large strings/bytes, consider
- JSON
- Use
omitzerowhere zero-value omission is intended (esp.time.Time); keepomitemptyonly for “empty” semantics.
- Use
- Crypto/TLS
- Prefer AEAD; use
crypto/cipher.NewGCMWithRandomNoncefor sealed outputs that carry a random nonce. - Ensure no SHA-1 verification in
x509chains; RSA < 2048 forbidden, <1024 never allowed. - PQ TLS: confirm default X25519MLKEM768 enabled (unless explicitly disabled). Flag servers/clients that break with larger records; suggest
GODEBUG=tlsmlkem=0only as compatibility fallback. - For constant-time behavior, use
crypto/subtle.WithDataIndependentTimingwhere applicable.
- Prefer AEAD; use
- net/http
- Check
Server.Protocols/Transport.Protocolsconfiguration; justify any unencrypted HTTP/2 (h2c) enablement. - Bound headers via
Transport.MaxResponseHeaderBytes; validate 1xx handling; usehttptracewhere needed.
- Check
- Testing ergonomics
- Benchmarks prefer
testing.B.Loop; verify properB.Context,T/B.Chdir, andt.Cleanup. - Concurrency tests: if complex, consider
testing/synctestwithGOEXPERIMENT=synctest.
- Benchmarks prefer
──────────────────────────────────────────────────────────────────────────────
- Commands in
cmd/<app>; libraries in cohesive packages (internal/<pkg>when appropriate); no import cycles. - Package naming: short, evocative; avoid
util/common/types/.... - Public API:
- Small consumer interfaces; return concrete types.
- Receivers: value vs pointer by mutability/size/containment of mutex; do not mix on same type.
- Context: accept
context.Contextas the first param; never store on structs. - Errors: multi-return idiom;
errors.Is/As/Join; wrap with%w; lower-cased messages, no trailing punctuation. Avoid in-band error sentinels; prefer(T, bool)where appropriate. - Control flow: guard-clause errors; avoid naked returns in non-trivial funcs.
- Documentation:
- Package doc comments present; exported identifiers documented and start with the name; examples compile (
go test ./...runsExample*).
- Package doc comments present; exported identifiers documented and start with the name; examples compile (
──────────────────────────────────────────────────────────────────────────────
-
gofmt -s -l .returns empty;goimportswith proper import grouping (stdlib / external / internal). -
go vet ./...clean, including Go 1.24 analyzers:-
printf: flagfmt.Printf(s)with non-constsand no args (usefmt.Print). -
tests: malformed/misnamed tests/benchmarks/examples fixed. -
buildtag: invalidgo1.Xpoint-release constraints fixed (usego1.23, notgo1.23.1). -
copylock: no copyingsync.Lockerin 3-clause for loops.
-
-
golangci-lint run(curated set): gofmt, goimports, revive/staticcheck (and agreed org linters). Keep noise low; document exceptions.
──────────────────────────────────────────────────────────────────────────────
- Build all:
go build ./...on supported platforms; CI variant with-racewhen feasible. - Tests:
go test -race -count=1 ./...passes; target strong coverage on business logic (e.g., ≥80% or org policy). Producecoverage.out; compute package and total. - Fuzz where valuable (
-fuzz=Fuzzseeds for parsers/decoders); fuzz tests are isolated from unit tests. - Benchmarks: use
testing.B.Loop; avoid per-iteration setup; capture-benchmem. Store historical runs for regressions. - Deterministic concurrent tests: adopt
testing/synctestwhere races/flakes exist.
Artifacts:
- Attach coverage summary & top N low-coverage packages.
- Attach perf delta vs baseline if benches exist.
──────────────────────────────────────────────────────────────────────────────
- CI always runs
-race; zero data races before merge. - Goroutine lifetimes explicit: no leaks on send/recv; document lifetimes when non-trivial; cancel on errors and context timeouts.
- Synchronization correctness:
- No busy-wait flags for cross-goroutine visibility; use channels/
syncprimitives. - No double-checked locking without proper sync.
- Channels/locks: avoid deadlocks; buffer only with rationale; minimize goroutine proliferation.
-
sync/atomiconly when truly required; ensure happens-before edges.
- No busy-wait flags for cross-goroutine visibility; use channels/
- Containers & maps:
- Be aware of 1.24 Swiss-table maps and changed
sync.Mapperf; remove stale micro-opts; never copy structs with embedded mutexes.
- Be aware of 1.24 Swiss-table maps and changed
──────────────────────────────────────────────────────────────────────────────
- Set sane server/client timeouts (Read/Write/Header/Idle/Handshake).
- Always
Close()response bodies; checkdefer resp.Body.Close()patterns. - Respect idempotency/backoff rules on retries; propagate
context.Context. - Validate
Server.Protocols/Transport.Protocols(HTTP/1.1, HTTP/2, optional h2c) per threat model and interoperability.
──────────────────────────────────────────────────────────────────────────────
- Structured logging via
log/slog(levels/handlers configurable); ensure PII/secret scrubbing; redact error values as needed. - Expose version/build info from
debug.BuildInfo; log at startup and in diagnostics. - Profiling & tracing hooks present where needed (
pprofendpoints or on-demandgo tool pprofsupport).
──────────────────────────────────────────────────────────────────────────────
- Allocation hygiene: prefer zero-values usable; avoid needless pointers; preallocate slices/maps when size is known.
- Run representative benches; inspect
allocs/opandB/op. - CPU/mem profiles for hot paths; verify improvements before merging micro-opts.
──────────────────────────────────────────────────────────────────────────────
- govulncheck automated in CI for source and produced binaries; reachable vulns triaged first; attach report.
- Crypto posture:
- No SHA-1 verification; RSA ≥2048; use AEAD (GCM/ChaCha20-Poly1305).
- PQ TLS defaults (X25519MLKEM768) acceptable for your environments; otherwise document explicit
CurvePreferences/GODEBUG workaround. - Use
crypto/randfor secrets; nevermath/rand. - If FIPS 140-3 is required: confirm
GOFIPS140/GODEBUG=fips140=1as per deployment guide; verify approved algorithms only.
- Secrets hygiene: no secrets in repo; env/secret manager used; logs crash reports scrubbed.
- Filesystem safety: prefer
os.Rootwhere user-controlled path components exist; forbid roots from user input.
──────────────────────────────────────────────────────────────────────────────
- Tools tracked via
tooldirectives (not blank-importtools.go):- Add/update with:
go get -tool <module@version>; run withgo tool <name>.
- Add/update with:
- Verify CI caches tool downloads and uses pinned tool versions.
- Module proxies and private sources configured; document
GOAUTHif needed.
──────────────────────────────────────────────────────────────────────────────
- Supported OS/arch list is current; validate deprecations (e.g., Linux ≥3.2; macOS 11 is last in 1.24).
- WebAssembly (if used): validate
go:wasmexport/wasmimporttypes; initial memory expectations; build modes.
──────────────────────────────────────────────────────────────────────────────
- Format/imports:
gofmt -s -l .empty;goimports(or via linter). - Build:
go build ./...(+-raceon CI where feasible). - Vet:
go vet ./.... - Lint:
golangci-lint run. - Test:
go test -race -cover ./.... - Bench (optional):
go test -run=^$ -bench=. -benchmem ./.... - Vuln:
govulncheck ./...(source + binaries). - Module hygiene:
go mod tidy& assert no diff ingo.mod/go.sum. - Tools (1.24+):
go get -tool <tool>;go tool <tool>.
──────────────────────────────────────────────────────────────────────────────
- Busy-waiting on booleans for cross-goroutine visibility.
- Double-checked locking without proper sync.
-
fmt.Printf(nonConstString)with no args. -
context.Contextstored on structs. - Leaking goroutines / missing
Closeonhttp.Response.Body. -
tools.goblank-import pattern (should be tool directives). -
encoding/jsonomitemptyused whenomitzerointended (esp.time.Time). - Crypto: SHA-1 in x509 verify, RSA<2048, OFB/CFB modes, or
math/randfor secrets. - Paths built from user input without
os.Rootconstraints.
──────────────────────────────────────────────────────────────────────────────
- All gates in §14 pass on CI for every module.
- No high/critical reachable vulns remain (attach govulncheck proof).
- Coverage target achieved or justified with risk notes.
- Performance deltas acceptable or better on key benches.
- Security/TLS/FIPS posture explicitly documented.
- All TODOs from this checklist resolved or tracked with owners/dates.