一键导入
go-code-review
Go code review checklist based on official Go style guides. When reviewing Go code for style, idioms, and best practices
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Go code review checklist based on official Go style guides. When reviewing Go code for style, idioms, and best practices
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | go-code-review |
| description | Go code review checklist based on official Go style guides. When reviewing Go code for style, idioms, and best practices |
| metadata | {"languages":"go"} |
Comprehensive code review checklist based on official Go style guides.
For deeper information, fetch these URLs:
gofmt or goimportsRun: gofmt -w . or goimports -w .
util, common, misc, api, types, interfaceschubby.File not chubby.ChubbyFilec, i, rc for Clientme, this, selfURL or url, never UrlServeHTTP not ServeHttpxmlHTTPRequest or XMLHTTPRequestappID not appIdOwner() not GetOwner()SetOwner() is fine-er suffix (Reader, Writer)// Request represents a request to run a command.
type Request struct { ... }
// Encode writes the JSON encoding of req to w.
func Encode(w io.Writer, req *Request) { ... }
package clause (no blank line)// Package math provides basic constants and mathematical functions.
package math
_, err := Foo() then ignored)fmt.Errorf("something bad") not "Something bad."// GOOD
if err != nil {
return err
}
// normal code
// BAD
if err != nil {
// error
} else {
// normal
}
func F(ctx context.Context, ...)context.Background() only with good reasongo test -race// GOOD - consumer defines interface
package consumer
type Thinger interface { Thing() bool }
// BAD - producer defines interface
package producer
type Thinger interface { Thing() bool }
func NewThinger() Thinger { ... }
var t []string (nil slice)t := []string{} only when needed (JSON encoding)*string and *io.Reader usually wrongcrypto/rand for keys, not math/randcrypto/rand.Text() for random textimport (
"fmt"
"os"
"github.com/foo/bar"
)
import _ "pkg" only in main package or testsif got != tt.want {
t.Errorf("Foo(%q) = %d; want %d", tt.in, got, tt.want)
}
TestFunctionName format// Avoid
func (n *Node) Parent1() (node *Node) {}
// Better
func (n *Node) Parent1() *Node {}
// OK when clarifying
func (f *Foo) Location() (lat, long float64, err error)
// GOOD
func Lookup(key string) (value string, ok bool)
// BAD
func Lookup(key string) string // returns "" on not found
// GOOD - switch with direct evaluation
switch status := getStatus(); status {
case StatusPending:
return "pending"
case StatusActive:
return "active"
case StatusDone:
return "done"
default:
return "unknown"
}
// BAD - long if-else chain
if status := getStatus(); status == StatusPending {
return "pending"
} else if status == StatusActive {
return "active"
} else if status == StatusDone {
return "done"
} else {
return "unknown"
}
// Type switch
var i interface{} = "hello"
switch v := i.(type) {
case string:
fmt.Println("string:", v)
case int:
fmt.Println("int:", v)
default:
fmt.Println("unknown type")
}
// GOOD - comma-separated cases
switch kind {
case "admin", "owner", "superadmin":
grantFullAccess()
}
slices.Sort instead of sort.Sliceslices.Sort instead of sort.Ints/sort.Float64s/sort.Stringsslices.Contains instead of manual search loopsslices.Equal instead of manual slice comparisonslices.Delete instead of append pattern for slice deletionmaps.Clone instead of manual map copy loopsmaps.Equal instead of manual map comparisonmaps.Keys/maps.Values (Go 1.23+) for iteration// GOOD - modern idioms
slices.Sort(items)
if slices.Contains(items, target) { ... }
clone := maps.Clone(original)
// BAD - unnecessary manual implementation
sort.Slice(items, func(i, j int) bool { return items[i] < items[j] })
sort.Ints(items)
for _, item := range items {
if item == target { found = true; break }
}
clone := make(map[K]V, len(original))
for k, v := range original { clone[k] = v }
cmp.Ordered constraint used for comparable typesany constraint only when truly type-agnostictime.Now() callstime.Now() in business logic// GOOD - testable time handling
type Clock interface { Now() time.Time }
type Service struct { clock Clock }
// BAD - untestable
func (s *Service) IsExpired() bool {
return time.Now().After(s.expiresAt)
}
iter.Seq or iter.Seq2sync.WaitGroup.Go for fire-and-forget goroutineswg.Go(fn) is equivalent to go func() { wg.Wait(); fn() }() but simplergo func() { defer wg.Done(); fn() }() for simpler error handling// GOOD - Go 1.24+ WaitGroup.Go pattern
var wg sync.WaitGroup
for _, task := range tasks {
wg.Go(func() {
process(task) // err handled inside
})
}
wg.Wait()
// ACCEPTABLE - traditional pattern still works
var wg sync.WaitGroup
for _, task := range tasks {
wg.Add(1)
go func(t Task) {
defer wg.Done()
process(t)
}(task)
}
wg.Wait()
{ ... } wrapping code without if/for/switch// BAD - bare block adds unnecessary indentation
msg := buildFlowMessage()
{
multiModelSection := processMultiModel()
// ... 30+ lines
}
// GOOD - flatten the code
msg := buildFlowMessage()
multiModelSection := processMultiModel()
// ... (unindented)
goimports -w .)response.txt after file-based transport removal)return, panic, break in loops (unless in defer)// BAD - unreachable code after return
func foo() {
return
fmt.Println("this never runs") // dead code
}
// GOOD - remove unreachable code
func foo() {
return
}
For fast reviews, check these critical items:
Load and follow subagent-return-protocol skill, then return its Review Envelope exactly.
Guide for creating custom opencode agents with proper configuration, permissions, path-based delegation, work splitting, and strict status envelopes. Use when creating or updating agents for coordination, implementation, review, deployment, verification, documentation, or specialized workflows.
TDD for process documentation - test with subagents before writing, iterate until bulletproof. When you discover a technique, pattern, or tool worth documenting for reuse. When editing existing skills. When asked to modify skill documentation. When you've written a skill and need to verify it works before deploying. When skills fail to help agents, when documentation is unclear, when new patterns emerge that need standardization.
Create and setup a new OpenAI Agents SDK application with interactive guidance for language choice, agent type selection (Basic, Voice, Realtime), project setup, and automatic verification.
Create and setup a new Claude Agent SDK application with interactive guidance for language choice, project setup, and automatic verification.
Problem-Solving Dispatch; Dispatch to the right problem-solving technique based on how you're stuck; Stuck on a problem. Conventional approaches not working. Need to pick the right problem-solving technique. Not sure which skill applies.
Interactive wizard to compose valid GOAL.md files for SGAI with step-by-step guidance through 7 phases. Use when creating GOAL.md, configuring agents and model, safety-analysis guidance, or starting an SGAI project. Safety Analysis must use coordinator/reviewer stpa-overview skill guidance.