Skip to content

RoninForge/roninforge-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

roninforge-go

Validate Plugin License: MIT GitHub release

Cursor plugin for modern Go (1.22, 1.23, 1.24). Teaches the AI to write idiomatic Go that uses log/slog, errors.Is/As with %w wrapping, context-first APIs, the 1.22+ http.ServeMux method routing, and 1.23 range-over-func iterators. Catches io/ioutil, interface{}, panic(err), time.After leaks in select loops, and the other regressions LLMs trained on pre-1.18 code still ship.

The Problem

LLMs trained on Go code from the 1.16-2023 era default to outdated patterns. They:

  • Import io/ioutil (deprecated since 1.16)
  • Write interface{} instead of any
  • Compare errors with == instead of errors.Is, lose chains with %v
  • panic(err) on normal I/O failures
  • Use time.After inside for/select loops (timer leak)
  • Pass sync.WaitGroup by value (silently does nothing)
  • Stick defer f.Close() inside a for loop (resources accumulate until function return)
  • Reach for gorilla/mux and chi when stdlib http.ServeMux (1.22+) has method routing
  • Use log.Println / log.Fatal instead of log/slog
  • Call http.Get / http.Post without a context
  • Run a goroutine with no exit condition
  • Add the unnecessary v := v shadow inside goroutines (fixed at language level in 1.22)
  • Stuff context.Context into a struct field
  • Use func init() to open DB connections and register globals
  • Generate fresh *time.Timer allocations from every time.After call

Install

Clone into your Cursor plugins directory:

git clone https://github.com/RoninForge/roninforge-go.git ~/.cursor/plugins/local/roninforge-go

Or copy into your project:

git clone https://github.com/RoninForge/roninforge-go.git
cp -r roninforge-go/rules/* your-project/.cursor/rules/
cp -r roninforge-go/skills/* your-project/.cursor/skills/
cp -r roninforge-go/agents/* your-project/.cursor/agents/

What's Included

Rules (5 files)

Rule Scope What it does
go-core Always active Loop-var rules, async iterators, any, context-first, error wrapping, slog, http.ServeMux 1.22+, graceful shutdown, sql.DB pool
go-anti-patterns Always active 20 LLM mistakes: io/ioutil, interface{}, panic(err), time.After leaks, defer-in-loop, WG-by-value, log.Println, http.Get without context, body-not-closed, %v on err, init() side effects
go-errors **/*.go Wrap-and-check, sentinels, typed error structs, errors.Join, when to panic, common stdlib sentinels
go-concurrency **/*.go Goroutine lifecycle, context propagation, errgroup over hand-rolled WG, channels, sync.Once, race detector, atomic counters
go-testing Agent-requested Table tests, t.Cleanup, testing.TB, httptest, fuzz, benchmarks, testing/synctest (1.24 experimental, stable 1.25+)

Skills (4 commands)

Skill Command What it does
New service /go-new-service Scaffold HTTP service with graceful shutdown, slog setup, 1.22+ mux, ReadHeaderTimeout
Error wrap /go-error-wrap Convert %v to %w, == to errors.Is, type assertions to errors.As, define sentinels
Validate /go-validate Scan a codebase for the 20 anti-patterns, report by severity
Modernize /go-modernize Migrate older code: ioutil to io/os, log to slog, interface{} to any, hand-rolled router to ServeMux 1.22+

Agent (1 subagent)

Agent What it does
go-reviewer Reviews Go code by severity: critical (crashes, leaks), warnings (regressions vs modern Go), suggestions (style)

What Makes This Different

Existing Go cursor rules cover style-only items (gofmt, naming) or are pinned to Go 1.18 patterns. None of them:

  • Cover the 1.22 / 1.23 / 1.24 language deltas (range-over-func iterators, math/rand/v2, crypto/rand.Text, b.Loop() in benchmarks, the tool directive)
  • Catch time.After leaks in select, the single most common production bug LLMs ship
  • Force context-first signatures with grep-able patterns
  • Teach log/slog migration from log.Println (still the dominant generated output)
  • Bundle a reviewer agent that grades by severity

The plugin treats the LLM as a junior writing in 2026, not as a senior writing in 2018.

Fixtures

tests/fixtures/anti-pattern-sample/ is a deliberate worst-case service (compiles on Go 1.20 to demonstrate ioutil). tests/fixtures/correct-sample/ is the modernised version - compiles, vets clean, and go test -race ./... passes.

License

MIT - see LICENSE

Links

About

Cursor plugin for modern Go (1.22, 1.23, 1.24). Teaches log/slog, errors.Is/As + %w, context-first APIs, http.ServeMux method routing, range-over-func iterators. Catches io/ioutil, interface{}, panic(err), time.After leaks, and 16 more LLM regressions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages