Skip to content

Releases

v0.6.0 — stricter rules, fail closed on load errors

Choose a tag to compare

@kidandcat kidandcat released this 04 Oct 21:59

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
    previous go line) ships a standard library affected by GO-2026-4602.
    go install now needs a toolchain that old.

  • gox check --json prints one JSON object (issues, issue_count,
    hidden, load_errors) on stdout. Exit codes are unchanged. The same
    --max-issues cap applies.

  • gox cache clean deletes the on-disk cache, including older version
    directories.

  • exhaustive checks iota enums declared in other packages of the same
    module
    (the usual model.Kind switched in service/). 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.

  • namedargs no longer treats a dotless module (module myapp) as the
    standard library. Stdlib exemption uses go list's Standard field.

  • httptimeout flags http.ListenAndServe, ListenAndServeTLS, Serve,
    and ServeTLS.

  • errcheck treats a result as an error only when it implements error
    (Error() string), including concrete types such as *ValidationError.
    An interface method that is merely named Error is no longer enough.

  • contextcheck treats a function literal that receives its own
    context.Context as a root, so errgroup.Go(func(ctx context.Context) error { context.Background() })
    is reported.

  • A package go list accepts but go/types does not is now a load error
    (exit 2) and its partial result is not cached.

  • gox check / gox baseline resolve the module root from the first
    filesystem pattern, not only from the current directory.

  • Breaking — exit code: gox check now 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 exited 0
    if nothing else was found. It now exits 2 and reports
    gox: N package(s) failed to load or type-check; the report is incomplete; any issues found
    are still printed. gox baseline refuses to write an incomplete snapshot
    in that case. Scripts or CI that relied on exit 0 for 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 from gox/v3 to gox/v4.
    (#5)

Fixed

  • bodyclose matches resp.Body.Close() by types.Object. A shadowed
    resp in an inner block no longer counts as closing the outer response.
  • errorlint understands 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_id before 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 the package clause 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|grok keeps the existing permissions of the settings
    file instead of rewriting it as 0644. It also warns when jq (required
    by the hook) is missing, and the hook says so on stderr instead of doing
    nothing silently. (#8)

Internal

  • Packages from one go list share 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, and exhaustive use that index, so a comment group that
    ends on the flagged line suppresses the finding the same way
    safe-ignore already did.
  • pkg/analyzer, pkg/loader, pkg/cache, and pkg/baseline are
    implementation packages. They are not a stable API.
  • CI: gofmt, go vet, go test -race, staticcheck and govulncheck
    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 check exits 2 and
    gox baseline writes nothing when a package does not load (including a
    replace that points at a missing directory).
  • An end-to-end golden test over testdata/bad exercises the full pipeline,
    and the stale callsSwapOK example was fixed.
    (#9)
  • Docs: gox baseline and the remaining check flags are documented, the
    safe-ignore coverage list is complete, and stale package comments were
    fixed. (#10)

v0.5.1 — module path github.com/kidandcat/gox

Choose a tag to compare

@kidandcat kidandcat released this 04 Oct 21:33

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

Choose a tag to compare

@kidandcat kidandcat released this 02 Jul 07:49

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 check runs 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 list marks 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 .go files 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_FLAGS passes extra flags through (e.g. --all).

Notes

  • gox baseline still captures the full analyzer set, so check --all filters against a complete snapshot.
  • Re-run gox install claude (or grok) after upgrading to refresh the hook script.

v0.4.1 — gox explain

Choose a tag to compare

@kidandcat kidandcat released this 25 May 08:46

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

Choose a tag to compare

@kidandcat kidandcat released this 25 May 08:46

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 through http.DefaultClient, which has zero Timeout)
  • Any call on http.DefaultClient (e.g. http.DefaultClient.Do(req))
  • &http.Client{} / http.Client{} literals with no Timeout field set, or Timeout: 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.Client variable other than http.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

Choose a tag to compare

@kidandcat kidandcat released this 14 May 18:19

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

Choose a tag to compare

@kidandcat kidandcat released this 14 May 06:47

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 claude

v0.1.0

Choose a tag to compare

@kidandcat kidandcat released this 13 May 11:17

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 below

After install, wire it into Claude Code:

gox install claude

What's in here

10 analyzers reimplemented from stdlib only (no golang.org/x/tools, no
third-party linter deps):

  • errcheck — dropped error returns
  • shadow — := shadowing an outer variable (except the ok idiom)
  • forcetypeassert — type assertions without comma-ok
  • namedargs — adjacent same-type args without /* paramName */ at call sites
  • exhaustive — non-exhaustive switch over iota enums and sealed interfaces
  • noglobals — mutable package-level var
  • banany — any / interface{} without justification
  • bodyclose — *http.Response.Body not closed
  • contextcheck — context.Background() inside a function that already has ctx
  • goroutine — go without a visible *errgroup.Group, sync.WaitGroup, or context.CancelFunc

Plus:

  • Per-package incremental cache (~/.cache/gox/v2) keyed by mtime+size.
  • Parallel package processing (worker pool sized to GOMAXPROCS).
  • gox baseline captures existing issues so adoption on legacy
    codebases is zero-day-1-work.
  • Generated files (// Code generated ... DO NOT EDIT.) are skipped.
  • gox install claude registers a PostToolUse hook in
    ~/.claude/settings.json so 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.