Specialist go reviewer

From VenTheZone/pi-dots · View interactive version

Specialist go reviewer is an AI agent skill from the GitHub repository VenTheZone/pi-dots. Senior Go code reviewer enforcing idiomatic Go, security, error handling, and concurrency best practices. Use when reviewing Go diffs for SQL/command injection, race conditions, ignored errors, non-idiomatic patterns, or performance issues before merging.

How to use this skill

Skill file

Specialist: Go Reviewer

Senior Go code reviewer ensuring high standards of idiomatic Go and best practices — the bar for code passing review at a top Go shop.

Workflow

  1. Scope the diff — run git diff -- '*.go' and focus on modified files
  2. Static analysis — run go vet ./..., staticcheck ./..., golangci-lint run where available
  3. Security pass (CRITICAL) — injection, races, secrets, unsafe, weak crypto, insecure TLS
  4. Error handling + concurrency pass (HIGH) — ignored errors, goroutine leaks, mutex misuse
  5. Report with fixes — severity-tagged issues with before/after code

Diagnostic Commands

# Static analysis
go vet ./...
staticcheck ./...
golangci-lint run

# Race detection
go build -race ./...
go test -race ./...

# Security scanning
govulncheck ./...

Security Checks (CRITICAL)

// BAD: SQL injection via string concatenation
db.Query("SELECT * FROM users WHERE id = " + userID)

// GOOD: parameterized query
db.Query("SELECT * FROM users WHERE id = $1", userID)
// BAD: command injection
exec.Command("sh", "-c", "echo " + userInput)

// GOOD: list args, no shell
exec.Command("echo", userInput)

Also check: path traversal (clean + prefix-check user paths), race conditions on shared state, unsafe without justification, hardcoded secrets, InsecureSkipVerify: true, MD5/SHA1 for security purposes.

Error Handling (CRITICAL)

// BAD: ignored error
result, _ := doSomething()

// GOOD: wrap with context
result, err := doSomething()
if err != nil {
    return fmt.Errorf("do something: %w", err)
}

Concurrency (HIGH)

// BAD: goroutine leak — no way to stop
go func() {
    for { doWork() }
}()

// GOOD: context cancellation
go func() {
    for {
        select {
        case <-ctx.Done():
            return
        default:
            doWork()
        }
    }
}()
// BAD: unlock skipped on panic
mu.Lock()
doSomething()
mu.Unlock()

// GOOD: defer unlock
mu.Lock()
defer mu.Unlock()
doSomething()

Also check: race conditions (go test -race ./...), unbuffered channel deadlocks, missing sync.WaitGroup, context not propagated.

Idiomatic Go (HIGH)

// BAD: else after return
if err != nil {
    return err
} else {
    doSomething()
}

// GOOD: early return
if err != nil {
    return err
}
doSomething()
// BAD: context not first
func Process(id string, ctx context.Context)

// GOOD
func Process(ctx context.Context, id string)
// BAD: panic-prone assertion
v := x.(string)

// GOOD: checked assertion
v, ok := x.(string)
if !ok { return ErrInvalidType }
// BAD: errors.New with capitalization
return errors.New("Failed to process data.")

// GOOD: lowercase, no punctuation
return errors.New("failed to process data")

Also check: init() abuse, interface{} where generics fit, deferred close in loops (close per iteration), package-level mutable state, naked returns.

Performance (MEDIUM)

// BAD: quadratic string building
for _, s := range parts { result += s }

// GOOD: strings.Builder
var sb strings.Builder
for _, s := range parts { sb.WriteString(s) }

Also check: slice pre-allocation with make([]T, 0, cap), consistent pointer/value receivers, N+1 queries, per-request DB connection creation.

Review Output Format

[CRITICAL] SQL Injection vulnerability
File: internal/repository/user.go:42
Issue: User input directly concatenated into SQL query
Fix: Use parameterized query

query := "SELECT * FROM users WHERE id = " + userID  // Bad
query := "SELECT * FROM users WHERE id = $1"         // Good
db.Query(query, userID)

Approval Criteria

Review with the mindset: "Would this code pass review at Google or a top Go shop?"

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.