agentleFS
RoninForgeRoninForge/roninforge-go/skills/go-validate/SKILL.md

go-validate

Skill0 starsChanged 7 months agoMITView on GitHub

Scan a Go codebase for common LLM-generated anti-patterns: io/ioutil, interface{}, panic(err), time.After in select, defer in loop, log.Println, http.Get without context, %v on errors, init() side effects.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    When auditing AI-generated Go, reviewing a PR, or preparing a codebase for production.

    line 10
  2. Distinctive:

    Run each grep pattern against the project root.

    line 14
  3. Distinctive:

    Run all greps, collect into a report.

    line 105
  4. Very specific:

    Run go vet ./... && staticcheck ./...

    line 109

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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

Validate Go Codebase

When to Use

When auditing AI-generated Go, reviewing a PR, or preparing a codebase for production. Output is a list of locations and suggested fixes.

Instructions

Run each grep pattern against the project root. Each hit is a candidate; not all are wrong. Group results by severity.

Deprecated / legacy

grep -rn "io/ioutil" --include='*.go' .
grep -rn "interface{}" --include='*.go' . | grep -v _gen.go
grep -rnE 'math/rand"' --include='*.go' .  # consider math/rand/v2

Error handling

# Sentinel comparisons. Real Go sentinels start with Err (sql.ErrNoRows,
# http.ErrServerClosed, fetcher.ErrNotFound) or are bare stdlib (io.EOF).
grep -rnE '\berr\s*==\s*([a-z][a-zA-Z0-9_]*\.)?Err[A-Z]' --include='*.go' .
grep -rnE '\berr\s*==\s*io\.(EOF|ErrUnexpectedEOF)' --include='*.go' .
grep -rnE '\berr\s*==\s*context\.(Canceled|DeadlineExceeded)' --include='*.go' .

# %v on err - should be %w
grep -rnE 'fmt\.Errorf\([^)]*%v[^)]*err' --include='*.go' .

# panic on returned error
grep -rn 'panic(err)' --include='*.go' .

# Silently discarded Close
grep -rn '_ = .*\.Close()' --include='*.go' .

Concurrency

# time.After - flag every occurrence then human-check whether it is inside a for/select
grep -rn 'time.After(' --include='*.go' .

# WaitGroup / Mutex by value in a function or method parameter (bug).
# Embedding sync.Mutex / sync.WaitGroup as a struct field is fine - the no-copy
# rule applies to the containing struct, which `go vet` already enforces.
# This grep produces false positives on struct field declarations; visually
# filter for parameter lists `(... sync.X ...)`.
grep -rnE '\bsync\.(WaitGroup|Mutex|RWMutex|Once)\b' --include='*.go' . | grep -v '\*sync\.'

# Goroutines - audit each for an exit path (ctx.Done, channel close, or finite work).
grep -rnE 'go func\(' --include='*.go' .

Context

grep -rn 'context.Context' --include='*.go' . | grep 'struct'  # ctx in struct

HTTP

# http.Get / http.Post - production code should build a request with context
grep -rnE 'http\.Get\(|http\.Post\(' --include='*.go' .

# Body without an immediate Close. Heuristic - false-positives on lines that
# read from resp.Body when the defer is on a different line. Use this as a
# trigger to visually scan each match for `defer resp.Body.Close()` nearby.
grep -rnE '\bresp\b\s*[,:]?=\s*[a-z]+(\.|\b)[A-Za-z]+\(' --include='*.go' . | grep -v 'defer'

Defer

# Heuristic - look for `for` blocks containing `defer`
grep -rnE 'for .*\{' --include='*.go' . -A 10 | grep 'defer'

Logging

grep -rnE 'log\.(Println|Printf|Fatal)' --include='*.go' .

Secrets

grep -rnE '(sk-|api[_-]?key[\"'"'"']?\s*[:=])' --include='*.go' .

init()

grep -rn '^func init()' --include='*.go' .

Workflow

  1. Run all greps, collect into a report.
  2. Open each hit, judge by context. False positives are common in generated code or comments.
  3. Group remaining issues by severity (see go-reviewer agent).
  4. Fix top-priority issues. Use the go-error-wrap skill to do error refactors safely.
  5. Run go vet ./... && staticcheck ./... && go test -race ./... before committing.

Output Format

=== Critical ===
internal/api/user.go:23 - panic(err) on normal error - return wrapped error
internal/queue/worker.go:88 - time.After in for/select - reuse a timer

=== Warnings ===
internal/io.go:12 - io/ioutil import - replace with io.ReadAll
...

=== Suggestions ===
...

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.