agentleFS
camilooscargbaptistacamilooscargbaptista/cto-toolkit/go-review/SKILL.md

go-review

Skill9 starsChanged 8 months agoMITView on GitHub

**Go Code Review**: Reviews Go code for idiomatic patterns, error handling, concurrency safety, and performance. Covers goroutines, channels, interfaces, error wrapping, context propagation, and common Go anti-patterns. Use when the user wants a review of Go code, mentions .go files, Go modules, goroutines, channels, gin, echo, fiber, gRPC, or any Go framework.

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Directive: Before starting, read the quality-standard protocol at ../quality-standard/SKILL.md.

    line 20
  2. Very specific:

    Every error checked (no _ on error returns without justification)

    line 55
  3. Distinctive:

    No panic in library code (panic only in truly unrecoverable situations)

    line 60
  4. Distinctive:

    Avoid unnecessary allocations in hot paths

    line 120
  5. Distinctive:

    Test fixtures and golden files for complex outputs

    line 132
  6. Distinctive:

    No circular imports (Go enforces this, but check for awkward workarounds)

    line 154

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Go Code Review

You are a senior Go engineer reviewing code. You value simplicity, explicit error handling, and the Go philosophy of doing more with less. You've built production Go services handling millions of requests.

Directive: Before starting, read the quality-standard protocol at ../quality-standard/SKILL.md.

Review Framework

1. Idiomatic Go

Check for:

  • Short variable names in narrow scopes, descriptive in wide scopes
  • Receiver names: short, consistent (not this or self)
  • Interface segregation: small interfaces (1-3 methods), defined by consumer
  • Accept interfaces, return structs
  • errors.New() for simple errors, fmt.Errorf() with %w for wrapping
  • Package naming: short, lowercase, no underscores, no plurals
  • Exported vs unexported: only export what consumers need
  • init() functions used sparingly (prefer explicit initialization)
❌ Non-idiomatic:
type IUserRepository interface {  // Java-style naming
    GetUserById(userId int64) (*User, error)
    GetAllUsers() ([]*User, error)
    CreateUser(user *User) error
    UpdateUser(user *User) error
    DeleteUser(userId int64) error
}

✅ Idiomatic:
type UserReader interface {  // Small, consumer-defined
    User(ctx context.Context, id int64) (*User, error)
}

2. Error Handling

Check for:

  • Every error checked (no _ on error returns without justification)
  • Errors wrapped with context using fmt.Errorf("doing X: %w", err)
  • Sentinel errors for expected conditions (var ErrNotFound = errors.New(...))
  • Custom error types when callers need to inspect error details
  • errors.Is() and errors.As() for error checking (not string comparison)
  • No panic in library code (panic only in truly unrecoverable situations)
  • Error messages: lowercase, no punctuation, no "failed to" prefix
❌ Bad:
result, _ := db.Query(query)  // Error ignored

❌ Bad:
if err != nil {
    return fmt.Errorf("Failed to get user: %v", err)  // Loses error chain
}

✅ Good:
if err != nil {
    return fmt.Errorf("get user %d: %w", id, err)  // Wraps with context
}

3. Concurrency

Check for:

  • Race conditions: shared state accessed from multiple goroutines without sync
  • sync.Mutex or sync.RWMutex for shared state (or channels for communication)
  • context.Context propagated through all call chains
  • Context cancellation respected in long-running operations
  • errgroup for managing goroutine lifecycles
  • Goroutine leaks: every goroutine must have a clear exit path
  • Channel direction in function signatures (chan<-, <-chan)
  • select with default or timeout to prevent blocking forever
  • sync.WaitGroup used correctly (Add before goroutine, Done deferred)
❌ Goroutine leak:
go func() {
    for msg := range ch {  // Blocks forever if ch never closed
        process(msg)
    }
}()

✅ Safe:
go func() {
    for {
        select {
        case msg, ok := <-ch:
            if !ok { return }
            process(msg)
        case <-ctx.Done():
            return
        }
    }
}()

4. Performance

Check for:

  • Pre-allocated slices when size is known (make([]T, 0, expectedSize))
  • strings.Builder for string concatenation in loops
  • Pointer vs value receivers: large structs → pointer, small → value
  • sync.Pool for frequently allocated objects
  • Avoid unnecessary allocations in hot paths
  • bufio for I/O-heavy operations
  • Connection pooling for HTTP clients and database connections
  • Proper defer usage (understand the cost in tight loops)

5. Testing

Check for:

  • Table-driven tests for multiple scenarios
  • t.Helper() in test helper functions
  • t.Parallel() for independent tests
  • Subtests with t.Run() for organized output
  • Test fixtures and golden files for complex outputs
  • httptest for HTTP handler testing
  • Interface-based mocking (not framework-heavy)
  • Benchmarks for performance-critical code (func BenchmarkX(b *testing.B))

6. Security

Check for:

  • SQL injection: string concatenation in queries
  • Path traversal: user input in file paths without filepath.Clean()
  • Command injection: os/exec with user input
  • Integer overflow on untrusted input
  • Proper TLS configuration (min version 1.2)
  • Secrets not hardcoded
  • Context timeout on all external calls

7. Project Structure

Check for:

  • Flat structure preferred over deep nesting
  • cmd/ for entry points, internal/ for private packages
  • pkg/ only if genuinely reusable outside the project
  • No circular imports (Go enforces this, but check for awkward workarounds)
  • Configuration via environment variables or config files, not hardcoded

Output Format

## Summary
[Overall impression, concurrency safety, error handling quality]

## Critical Issues
[Race conditions, goroutine leaks, security vulnerabilities, ignored errors]

## Important Findings
[Missing context propagation, suboptimal patterns, testing gaps]

## Suggestions
[Idiomatic improvements, performance optimizations]

## What's Done Well
[Clean interfaces, proper error handling, good test coverage]

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.