go-optimizer
Skill1 starsChanged 8 days agoMITView on GitHub
Audit and optimize Go projects (services on net/http, gin, echo, chi, gRPC; CLIs; libraries; modules and workspaces) for runtime speed, allocations and GC pressure, goroutine and concurrency bugs, database latency, binary size, build time and safety, with real before/after measurement. Always produces a written findings report and a fix plan for approval before touching any code. Use this whenever the user mentions a slow Go program or API, high memory or GC pauses, goroutine leaks, data races, pprof/trace/benchstat, `go build` size or speed, database/sql pooling or N+1, context cancellation, `go vet`/staticcheck/golangci-lint review, or "optimize my Go code" -- even if they don't say "audit" or "optimize".
1 other project uses a version of this.
Adopted by
Most recently taken up by
- damacus/agent-skillstheir own version, first seen Oct 29, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- damacus/agent-skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- architecture-optimizerSkill
- csharp-optimizerSkill
- cpp-optimizerSkill
- c-optimizerSkill
- node-service-optimizerSkill
- ruby-optimizerSkill
- rust-optimizerSkill
- docker-optimizerSkill
- kubernetes-optimizerSkill
- terraform-optimizerSkill
- animate-cssSkill
- animejsSkill
- auto-animateSkill
- gsapSkill
- lenisSkill
- magicuiSkill
- motionSkill
- react-moveSkill
- react-springSkill
- react-three-fiberSkill
- theatrejsSkill
- threejsSkill
- optimizer-routerSkill
- bootstrap-optimizerSkill
- pandacss-optimizerSkill
- sass-scss-optimizerSkill
- stylex-optimizerSkill
- tailwindcss-optimizerSkill
- twind-optimizerSkill
- unocss-optimizerSkill
- vanilla-extract-optimizerSkill
- angular-optimizerSkill
- astro-optimizerSkill
- ui-components-optimizerSkill
- nextjsSkill
- node-optimizerSkill
- nuxt-optimizerSkill
- react-optimizerSkill
- remix-optimizerSkill
- solid-optimizerSkill
- svelte-optimizerSkill
- tanstack-start-optimizerSkill
- vue-optimizerSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Run python <skill-dir>/scripts/audit.py <project-root> -- static scan of go.mod and .go sources (goroutine leaks, missing context, HTTP …
- Very specific: line 17
Read references/tooling.md once: which of pprof, go test -bench, benchstat, go tool trace, hyperfine are available.
- Very specific: line 42
Use plan mode: EnterPlanMode (load with ToolSearch if deferred), write the plan, present with ExitPlanMode.
- Very specific: line 60
Allocations drive Go cost: Check alloc_space/alloc_objects and -gcflags=-m before rewriting.
- Very specific: line 65
Docs move: Check go.dev/doc/ and pkg.go.dev for the toolchain/library version in go.mod, not memory.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
Go Optimizer
Audit a Go codebase, report what is slow or broken and why, agree a plan with the user, then fix it. Order: evidence, approval, edits. Optimizations in Go often change concurrency, error semantics, exported APIs or memory ownership, so nothing is edited before the user approves.
Workflow
1. Scope (quick)
- Find the root:
go.mod(orgo.work). Note Go version (godirective,go version), module path,mainpackages (cmd/), CGO use, target OS/arch. - Run
python <skill-dir>/scripts/audit.py <project-root>-- static scan ofgo.modand.gosources (goroutine leaks, missing context, HTTP client/server timeouts,deferin loops,time.Afterin loops, regexp in functions, string concat in loops,fmt.Sprintffor SQL, ignored errors, unbounded goroutines) with file:line evidence.--jsonfor post-processing. - Classify the workload: CPU-bound, IO/network service, memory/GC-bound, startup/binary-size, or build-time. Advice differs. Ask which hurts if unclear.
- Read
references/tooling.mdonce: which ofpprof,go test -bench,benchstat,go tool trace,hyperfineare available.
2. Audit
The script finds cheap leads; you find the rest by reading the hot path. Read go.mod, main.go/server setup, the 3-5 handlers or functions the user cares about or a profile points at. Load only what applies:
| Area | Reference |
| Build flags, binary size, PGO, GOMAXPROCS/GOMEMLIMIT, containers | references/build-runtime.md |
| Allocations, escape analysis, GC tuning, slices/maps/strings | references/memory-gc.md |
| Goroutines, channels, mutexes, context, errgroup, races | references/concurrency.md |
| HTTP servers/clients, database/sql, pgx, N+1, JSON | references/web-db.md |
| Errors, panics, vet/staticcheck, govulncheck, API stability | references/safety-quality.md |
| pprof, benchmarks, trace, honest measurement | references/tooling.md |
Measure, never guess. Profile the real workload (CPU, heap alloc_space, goroutine, mutex/block) before editing; benchmark with -count >= 6 and compare with benchstat. If the workload can't be run or a tool is missing, say measurement wasn't possible instead of inventing numbers.
Mark each finding Confirmed (profile/code evidence) or Suspected (needs measuring).
3. Report
Fill assets/report-template.md, save as GO_OPTIMIZATION_REPORT.md in the project root, and show the user. 5-line summary, findings table by impact/effort, then per-finding detail (evidence, why it hurts, fix, risk, API impact). Group related findings.
4. Plan -- then stop for approval
Use plan mode: EnterPlanMode (load with ToolSearch if deferred), write the plan, present with ExitPlanMode; if unavailable show it in chat and wait for an explicit "go". Structure:
- Quick wins -- server/client timeouts,
sync.Pool-free fixes likemake([]T, 0, n),strings.Builder, hoistingregexp.MustCompile,GOMEMLIMIT, build flags. Low risk. - Structural -- fix goroutine leaks and context propagation, bounded worker pools, batching queries, removing allocations on measured hot paths, lock redesign. Name each behaviour change.
- Heavy -- PGO, dependency swaps (JSON, router), exported API changes,
unsafe, architecture changes. Separately approved. Each step: files touched, expected effect, how to verify, how to roll back.
5. Fix
Only approved items, small groups. After each: gofmt -l ., go vet ./..., go build ./..., go test ./... (add -race where the project already runs it). A break must trace to one change. Don't mix a Go version / module upgrade with optimization edits. If something turns out riskier than planned (changed error semantics, exported signature, new data race), stop and ask.
6. Verify and wrap up
Re-measure with the same command and inputs: benchstat old.txt new.txt, p50/p99 latency and throughput under the same load, RSS / GC stats (GODEBUG=gctrace=1), binary size, build time. State plainly what could not be measured. End with deferred items and one suggested next step.
Principles
- Algorithm and I/O first. A missing index, an N+1, or an O(n^2) loop beats any allocation tweak.
- Allocations drive Go cost. Check
alloc_space/alloc_objectsand-gcflags=-mbefore rewriting; fix the top few sites. - Don't reach for
sync.Pool,unsafeor custom allocators first. Each adds bugs; require a benchmark. - Every goroutine needs an exit. Leaks and unbounded fan-out are the common production failures; context cancellation must reach every blocking call.
- Timeouts everywhere.
http.Server,http.Client, DB queries, outbound calls: defaults are "never". - Readability stays. Idiomatic, simple Go beats clever; don't contort cold code.
- Docs move. Check
go.dev/doc/andpkg.go.devfor the toolchain/library version ingo.mod, not memory.
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
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.

