Go Code Review Skill for Claude Code
Review a Go change for ignored errors, goroutine leaks, and context that is not canceled. Use for a Go code review. Do not use for a non-Go repository or to enable an experimental flag by default.
name: "go-code-review" description: "Review a Go change for ignored errors, goroutine leaks, and context that is not canceled. Use for a Go code review. Do not use for a non-Go repository or to enable an experimental flag by default."
Go Code Review Skill for Claude Code
Claude Code skill go-code-review for Go. The command is /go-code-review. Leave the normal permission prompts on.
When to run
Run this review for a Go change: a handler, a worker, a package, or "check the error paths".
When to leave it
Stop for a non-Go repository. Do not bump the go line in go.mod unless the user asked.
Steps
- Read the
goversion ingo.mod.GOEXPERIMENT=simdwithout a written reason is a high finding. An import ofencoding/json/v2on a module older than 1.27 is a high finding. On 1.27,encoding/jsonis already the v2 implementation. Do not flag that import. Flag a switch to theencoding/json/v2package only when the diff does not account for the stricter defaults. - Search the diff for
_ =on a call that returns an error, and forif err != nil { return nil }. A discarded error is a high finding. - Search for
go func. Each goroutine needs a cancel path and something that waits for it. A missingctx.Done()in a loop is a high finding. - Check HTTP and SQL calls for a context and for parameters. String-built SQL is a high finding.
- Run
go testfor the touched package if the user asked. Otherwise writenot run.
Output
Findings with severity, file, line, the ignored error or the leaked goroutine, and a fix. Include the Go version.
## Findings
- high | path:line | what is wrong | what to do instead
## No findings
Say "No findings" and list the files you opened. A search you skipped is not a clean result.
## Example
Input: `handlers/note.go` returns `err` from `os.ReadFile` with no wrap and no context check.
Output: medium | handlers/note.go:20 | the caller cannot see which step failed | return `fmt.Errorf("read note: %w", err)` and honor `ctx.Err()`.
Do not flag the valid pattern named in the standards. Flag the mistake next to it.
Stop
Stop when the user asks you to silence an error with _ so the build is quiet.
Severity
high is a bug a caller can hit or a secret that leaks. medium is a broken contract that needs a specific input. low is a cleanup that does not change behaviour.