Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .claude/agents/go-expert.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,42 @@ var i = 42
var coords = Point{X: 0, Y: 0}
```

**Use var groups for multiple related declarations**:
```go
// Good - grouped zero-value declarations (very common pattern)
var (
name string
email string
address string
)

// Good - grouped package-level initialized vars (errors, constants)
var (
ErrNotFound = errors.New("not found")
ErrInvalid = errors.New("invalid")
maxRetries = 3
)

// Good - grouped function-level zero values
func process() {
var (
count int
result string
err error
)
// ...
}

// Bad - separate var declarations for multiple related vars
var name string
var email string
var address string

// Bad - separate package-level initializations
var ErrNotFound = errors.New("not found")
var ErrInvalid = errors.New("invalid")
```

**Shadowing vs Stomping** - Use `=` to reassign in new scope:
```go
// Bad - shadowing bug
Expand Down Expand Up @@ -223,6 +259,34 @@ type Request struct {}
func Encode(w io.Writer, req *Request) {}
```

**Wrap doc comments at 80 characters**:
```go
// Good - wrapped at 80 chars
// ProcessBatch processes a batch of items concurrently using the provided
// worker pool. It returns the number of successfully processed items and any
// error encountered during processing.
func ProcessBatch(items []Item, pool *WorkerPool) (int, error) {}

// Bad - long single line
// ProcessBatch processes a batch of items concurrently using the provided worker pool and returns the number of successfully processed items and any error encountered during processing.
func ProcessBatch(items []Item, pool *WorkerPool) (int, error) {}
```

**Use [] notation to reference other types and functions**:
```go
// Good - using [] for cross-references
// NewClient creates a new [Client] with the given configuration.
// Use [Client.Connect] to establish a connection before calling other methods.
// See [Config] for available options.
func NewClient(cfg Config) *Client {}

// Bad - no cross-references
// NewClient creates a new Client with the given configuration.
// Use Client.Connect to establish a connection before calling other methods.
// See Config for available options.
func NewClient(cfg Config) *Client {}
```

## Misc Patterns

**Empty slices** - Prefer `var t []string` over `t := []string{}`:
Expand Down