go-review

A Go code review command that examines changed Go files for coding conventions, error handling, security, and concurrency problems.

In plain words
What is it for?
Use it after changing Go code, before submitting a change, while reviewing a pull request, or when learning common Go patterns.
Why use it?
It helps uncover issues that can be difficult to spot by reading code alone, such as data races, leaked goroutines, deadlocks, and ignored errors.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/codelably/harmony-claude-code/go-review
Clone the repo
git clone --depth 1 https://github.com/codelably/harmony-claude-code
Per session 32 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,154 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00032 $0.01154
Opus 5 $0.00016 $0.00577
Sonnet 5 $0.00006 $0.00231
Haiku 4.5 $0.00003 $0.00115

Measured 2d ago against content hash 74f70b85edf3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

go-review scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/go-review.md · 149 lines

How it starts

The opening of the file, as written. The whole thing — 149 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Go 代码审查 (Go Code Review)

此命令调用 go-reviewer 智能体 (Agent) 进行针对 Go 语言特性的全面代码审查。

此命令的作用

  1. 识别 Go 代码变更:通过 git diff 查找已修改的 .go 文件
  2. 运行静态分析:执行 go vetstaticcheckgolangci-lint
  3. 安全扫描:检查 SQL 注入、命令注入、竞态条件等安全隐患
  4. 并发审查:分析 Goroutine 安全、通道 (Channel) 使用、互斥锁 (Mutex) 模式
  5. 地道 Go 检查:验证代码是否遵循 Go 惯例和最佳实践
  6. 生成报告:按严重程度对问题进行分类

适用场景

在以下情况下使用 /go-review

  • 编写或修改 Go 代码后
  • 提交 Go 代码变更前
  • 审查包含 Go 代码的拉取请求 (Pull Request)
  • 熟悉新的 Go 代码库
  • 学习地道的 Go 模式

审查类别

致命 (CRITICAL) - 必须修复

  • SQL/命令注入漏洞
  • 未经同步的并发访问(竞态条件)
  • Goroutine 泄露
  • 硬编码的凭据
  • 不安全的指针 (Unsafe Pointer) 使用
  • 关键路径中被忽略的错误

高危 (HIGH) - 建议修复

  • 缺失包含上下文 (Context) 的错误包装
  • 使用 Panic 代替错误返回
  • 上下文 (Context) 未透传
  • 导致死锁的无缓冲通道
  • 接口未实现错误
  • 缺失互斥锁保护

中等 (MEDIUM) - 酌情考虑

  • 非地道的代码模式
  • 导出的标识符缺失 Godoc 注释
  • 低效的字符串拼接
  • 切片 (Slice) 未预分配容量
  • 未使用表驱动测试 (Table-driven tests)

运行的自动化检查

# 静态分析
go vet ./...

# 高级检查(如果已安装)
staticcheck ./...
golangci-lint run

# 竞态检测
go build -race ./...

# 安全漏洞
govulncheck ./...

使用示例

用户: /go-review

智能体 (Agent):
# Go 代码审查报告 (Go Code Review Report)

## 已审查的文件
- internal/handler/user.go (已修改)
- internal/service/auth.go (已修改)

## 静态分析结果
✓ go vet: 无问题
✓ staticcheck: 无问题

## 发现的问题

[致命] 竞态条件 (Race Condition)
文件: internal/service/auth.go:45
问题: 未经同步访问共享 Map
```go
var cache = map[string]*Session{}  // 并发访问!

func GetSession(id string) *Session {
    return cache[id]  // 竞态条件
}

修复: 使用 sync.RWMutex 或 sync.Map

var (
    cache   = map[string]*Session{}
    cacheMu sync.RWMutex
)

func GetSession(id string) *Session {
    cacheMu.RLock()
    defer cacheMu.RUnlock()
    return cache[id]
}

[高危] 缺失错误上下文 文件: internal/handler/user.go:28 问题: 返回错误时未包含上下文信息

return err  // 缺失上下文

修复: 包装上下文信息

return fmt.Errorf("get user %s: %w", userID, err)

总结

  • 致命 (CRITICAL): 1
  • 高危 (HIGH): 1
  • 中等 (MEDIUM): 0

建议: ❌ 在修复“致命”问题前禁止合并


## 批准标准

| 状态 | 条件 |
|--------|-----------|
| ✅ 批准 (Approve) | 无致命 (CRITICAL) 或高危 (HIGH) 问题 |
| ⚠️ 警告 (Warning) | 仅存在中等 (MEDIUM) 问题(谨慎合并) |
| ❌ 阻断 (Block) | 发现致命 (CRITICAL) 或高危 (HIGH) 问题 |

Read the full file on GitHub · 149 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 149 lines · 32 tokens per session scan A 74f70b85edf3

Subscribe to this mod's changes

go-review is a command published in the GitHub repository codelably/harmony-claude-code (42 stars, last pushed 6mo ago), licensed MIT. It adds 32 tokens to every session and 1,154 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.