mhmtszr/go-guidelines

97 stars · Last commit 2026-03-23

Make your AI code agent write production-grade Go instead of tutorial-grade Go. A plugin for Cursor & Claude Code with version-aware guidelines (Go 1.0–1.26) covering modern syntax, performance tuning, error handling, concurrency patterns, testing, and graceful shutdown.

README preview

# Go Guidelines for Code Agents

A plugin that teaches AI code agents how to write **production-grade Go** — covering modern syntax, generics, performance, concurrency safety, error handling, testing, and best practices.

Drop it into Cursor or Claude Code and every Go file the agent touches gets better.

## Motivation

All coding agents tend to generate outdated and suboptimal Go. Key reasons:

1. **Training data lag.** Models don't know about features added after their training cutoff. They can't use `wg.Go()` (1.25), `new(val)` (1.26), or `errors.AsType[T]` (1.26) if they've never seen them.

2. **Frequency bias.** Even for features the model knows, it picks older patterns. There's more `for i := 0; i < n; i++` in the training data than `for i := range n`, so that's what comes out.

3. **No performance awareness.** Agents don't align struct fields, don't set `GOMAXPROCS` for containers, and spawn unbounded goroutines instead of using pools.

4. **Broken operational patterns.** Generated shutdown code closes the database before draining the HTTP server. Resources get leaked. Signals get ignored.

5. **No post-change verification.** Agents never run `golangci-lint` or tests with the race detector after making changes.

View full repository on GitHub →