Repository navigation
Releases
v0.6.0 — stricter rules, fail closed on load errors
Module path stays github.com/kidandcat/gox (as in v0.5.1). Rules are
stricter than v0.5.x; to adopt v0.6.0 on an existing codebase, run
gox baseline once and commit .gox-baseline.json.
Changed
-
Minimum Go is 1.26.8. Go 1.25 is out of support, and
go 1.25.5(the
previousgoline) ships a standard library affected by GO-2026-4602.
go installnow needs a toolchain that old. -
gox check --jsonprints one JSON object (issues,issue_count,
hidden,load_errors) on stdout. Exit codes are unchanged. The same
--max-issuescap applies. -
gox cache cleandeletes the on-disk cache, including older version
directories. -
exhaustivechecks iota enums declared in other packages of the same
module (the usualmodel.Kindswitched inservice/). Enums from the
standard library and from third-party modules are still ignored. Constants
that share a value (const Default = Off) count as one variant. -
namedargsno longer treats a dotless module (module myapp) as the
standard library. Stdlib exemption usesgo list'sStandardfield. -
httptimeoutflagshttp.ListenAndServe,ListenAndServeTLS,Serve,
andServeTLS. -
errchecktreats a result as an error only when it implementserror
(Error() string), including concrete types such as*ValidationError.
An interface method that is merely namedErroris no longer enough. -
contextchecktreats a function literal that receives its own
context.Contextas a root, soerrgroup.Go(func(ctx context.Context) error { context.Background() })
is reported. -
A package
go listaccepts butgo/typesdoes not is now a load error
(exit 2) and its partial result is not cached. -
gox check/gox baselineresolve the module root from the first
filesystem pattern, not only from the current directory. -
Breaking — exit code:
gox checknow fails closed when a package
cannot be loaded (syntax error, type error, missing dependency). Such
packages used to be printed to stderr and skipped, and the run exited0
if nothing else was found. It now exits2and reports
gox: N package(s) failed to load or type-check; the report is incomplete; any issues found
are still printed.gox baselinerefuses to write an incomplete snapshot
in that case. Scripts or CI that relied on exit0for non-compiling code
will now fail. (#4) -
The cache key now also covers the export data of every dependency and a
fingerprint of the gox binary. Results are no longer stale after a
dependency's API changes or after gox is upgraded or rebuilt. The cache
directory moved fromgox/v3togox/v4.
(#5)
Fixed
bodyclosematchesresp.Body.Close()bytypes.Object. A shadowed
respin an inner block no longer counts as closing the outer response.errorlintunderstands explicit argument indexes (%[1]v) and*width
or precision, which consumes an operand. String-literal escapes are
unquoted before the format is read.- The Stop hook sanitizes
session_idbefore using it as a cache filename. - Generated files are detected with
ast.IsGenerated(the exact Go
convention): markers after headers longer than 20 lines are recognized,
and markers placed after thepackageclause no longer hide hand-written
code. (#6) forcetypeassert:var x, ok = v.(T)is accepted as comma-ok.
(#2)bodyclose: leaks inside closures are reported once instead of twice, and
a response returned to the caller (return resp, err) is no longer
flagged. (#3)gox install claude|grokkeeps the existing permissions of the settings
file instead of rewriting it as0644. It also warns whenjq(required
by the hook) is missing, and the hook says so on stderr instead of doing
nothing silently. (#8)
Internal
- Packages from one
go listshare a single export-data importer, so the
standard library is decoded once and type identity stays intact. Internal
test variants no longer re-walk production files, and baseline
fingerprints read each source file once. - Opt-out comments are indexed once per file.
goroutine,banany,
noglobals, andexhaustiveuse that index, so a comment group that
ends on the flagged line suppresses the finding the same way
safe-ignorealready did. pkg/analyzer,pkg/loader,pkg/cache, andpkg/baselineare
implementation packages. They are not a stable API.- CI:
gofmt,go vet,go test -race,staticcheckandgovulncheck
run on the minimum toolchain plus current stable. Also removed dead code
(entryHasGoxCommand) and fixed gofmt drift.
(#7) - CLI tests cover the fail-closed path:
gox checkexits2and
gox baselinewrites nothing when a package does not load (including a
replacethat points at a missing directory). - An end-to-end golden test over
testdata/badexercises the full pipeline,
and the stalecallsSwapOKexample was fixed.
(#9) - Docs:
gox baselineand the remainingcheckflags are documented, the
safe-ignorecoverage list is complete, and stale package comments were
fixed. (#10)
v0.5.1 — module path github.com/kidandcat/gox
The module is now github.com/kidandcat/gox (the repository moved from mentasystems/gox). No rule or behavior changes from v0.5.0.
go install github.com/kidandcat/gox/cmd/gox@latest
v0.5.0 and earlier keep the old path github.com/mentasystems/gox.
v0.5.0 — bug/style tiers
gox check now defaults to the bug tier
A month of real agent transcripts (100 Stop-hook blocks, 2799 reported issue lines for only 665 unique findings) showed that style rules, enforced inside an agent loop, overwhelmingly produce suppression annotations instead of fixes — noise that drowns the rules that catch real bugs.
Changed
gox checkruns only the bug tier by default:bodyclose,contextcheck,errcheck,errorlint,exhaustive,forcetypeassert,httptimeout.- The style tier (
banany,goroutine,namedargs,noglobals,shadow) is opt-in:gox check --all(env:GOX_ALL=1). gox listmarks opt-in rules.
Added
--skip=a,b,...(env:GOX_SKIP) to exclude analyzers per run; unknown names are an error.- Claude/Grok Stop hook v2:
- only checks packages whose
.gofiles were modified during the turn (mtime vs the transcript's last user message) — a file left dirty in git no longer re-blocks unrelated turns; - never re-blocks a session with a byte-identical report (also prevents stop-loops);
GOX_HOOK_FLAGSpasses extra flags through (e.g.--all).
- only checks packages whose
Notes
gox baselinestill captures the full analyzer set, socheck --allfilters against a complete snapshot.- Re-run
gox install claude(orgrok) after upgrading to refresh the hook script.
v0.4.1 — gox explain
What's new
New subcommand: `gox explain ` — prints each rule's reference page from inside the binary.
Each analyzer now ships its reference as a co-located `.md` file, embedded via `//go:embed`. The CLI exposes it two ways:
```sh
gox explain bodyclose # markdown to stdout
gox explain bodyclose --json # { "rule": "...", "doc": "...", "explanation": "..." }
gox explain --json bodyclose # flag position is free, important for agent invocations
```
Every reference page covers:
- one-line summary
- what the rule catches (concrete LLM-bug class)
- bad / good example pair
- opt-out annotation syntax
- known limitations
Why embedded. Docs are version-pinned to the binary you have installed. An agent that runs `gox explain ` gets the contract for the exact version, not whatever a docs site happens to show today. The `--json` envelope makes it cheap for agent loops to consume.
Internals. New `Analyzer.Explanation string` field on `pkg/analyzer.Analyzer`. Each analyzer's `init()` does:
```go
//go:embed bodyclose.md
var explanation string
func init() {
analyzer.Register(&analyzer.Analyzer{
Name: "bodyclose",
Doc: "...",
Explanation: explanation,
Run: run,
})
}
```
12 `var explanation string` package-level vars annotated `// global-ok: populated at compile time by //go:embed, never mutated` — dogfooded against `noglobals`.
Coverage
All 12 rules now ship a reference page: banany, bodyclose, contextcheck, errcheck, errorlint, exhaustive, forcetypeassert, goroutine, httptimeout, namedargs, noglobals, shadow.
v0.4.0 — httptimeout rule
What's new
New rule: httptimeout — gates HTTP calls and clients that have no timeout.
Flags:
http.Get,http.Post,http.Head,http.PostForm(all go throughhttp.DefaultClient, which has zeroTimeout)- Any call on
http.DefaultClient(e.g.http.DefaultClient.Do(req)) &http.Client{}/http.Client{}literals with noTimeoutfield set, orTimeout: 0
Does not flag:
&http.Client{Timeout: 30*time.Second}— explicit non-zero&http.Client{Timeout: cfg.Timeout}— non-constant expressions are trusted (the rule's job is to force a deliberate choice, not to verify it)client.Do(req)on a*http.Clientvariable other thanhttp.DefaultClient— the literal construction is the gate, not every use
Opt-out: `// timeout-ok: ` on the call line or on the opening brace of a multi-line client literal.
Drift fixes in README
- `errorlint` was previously added without a matching entry in the Rules table; both `errorlint` and `httptimeout` are now listed
- Coverage count bumped from 11 to 12
v0.3.0
Bounded gox check output
gox check now prints at most 100 issues by default, followed by a one-line summary of how many were hidden:
... 437 more issue(s) hidden (showing 100 of 537; raise with --max-issues=N or GOX_MAX_ISSUES, 0 = all)
A package with hundreds of findings could previously flood a context-limited consumer — notably the Claude Code Stop hook, which pipes gox check straight back into the model and could exhaust the conversation context.
Issues are sorted by file:line, so the truncation is deterministic. Configure with --max-issues=N (0 = unlimited) or the GOX_MAX_ISSUES env var.
v0.2.0
Claude Code integration: PostToolUse → Stop hook
gox install claude now registers the hook on the Stop event instead of PostToolUse.
The old PostToolUse hook ran gox check on every Edit/Write of a .go file — slow and noisy on large packages. The Stop hook fires once per turn: it inspects the .go files changed in the current git repo (unstaged, staged, untracked) and runs gox check once per affected package.
gox install claude automatically migrates an existing PostToolUse entry from older installs to the new Stop event, preserving every other key in settings.json. Re-run it to upgrade:
go install github.com/mentasystems/gox/cmd/gox@latest
gox install claudev0.1.0
First tagged release of gox.
Install
# from source
go install github.com/mentasystems/gox/cmd/gox@v0.1.0
# or download the binary for your platform belowAfter install, wire it into Claude Code:
gox install claudeWhat's in here
10 analyzers reimplemented from stdlib only (no golang.org/x/tools, no
third-party linter deps):
errcheck— dropped error returnsshadow—:=shadowing an outer variable (except theokidiom)forcetypeassert— type assertions without comma-oknamedargs— adjacent same-type args without/* paramName */at call sitesexhaustive— non-exhaustive switch over iota enums and sealed interfacesnoglobals— mutable package-levelvarbanany—any/interface{}without justificationbodyclose—*http.Response.Bodynot closedcontextcheck—context.Background()inside a function that already hasctxgoroutine—gowithout a visible*errgroup.Group,sync.WaitGroup, orcontext.CancelFunc
Plus:
- Per-package incremental cache (
~/.cache/gox/v2) keyed by mtime+size. - Parallel package processing (worker pool sized to GOMAXPROCS).
gox baselinecaptures existing issues so adoption on legacy
codebases is zero-day-1-work.- Generated files (
// Code generated ... DO NOT EDIT.) are skipped. gox install clauderegisters a PostToolUse hook in
~/.claude/settings.jsonso Claude Code runs gox after every Go file
edit and must fix or annotate before continuing.
On the Agentero monorepo (442 packages): ~6.3s cold, ~2.5s warm cache.
BSD-3-Clause.