go-performance
Go performance analysis: memory allocation, CPU bottlenecks, concurrency contention, struct alignment, escape analysis, and benchmarking patterns.
Skill by els0r
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/els0r-go-performance
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/go-performance
What's inside
- Skill name
go-performance- Description
- Go performance analysis: memory allocation, CPU bottlenecks, concurrency contention, struct alignment, escape analysis, and benchmarking patterns. Use this skill whenever writing performance-sensitive Go code, reviewing Go code for efficiency, discussing allocations or GC pressure, benchmarking, profiling with pprof, or optimizing hot paths. Also trigger when the user mentions sync.Pool, atomic operations, pre-allocation, or escape analysis — even without saying "performance."
- License
- MIT
- Instructions
- 166 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Go Performance
Performance is cost in cloud, experience on user-facing paths. Never optimize without measurement.
## Workflow
1. Establish a benchmark baseline (see `go-testing` for benchmark patterns).
2. Implement fixes.
3. Compare with `benchstat baseline.txt optimized.txt`.
4. Always ask the user to validate results — if they look too good, they probably are.
Prioritize: hot paths > allocation-heavy code > concurrency contention > stylistic.
---
## Rules
### 1. Expose pprof
Every service must expose pprof. Import `_ "net/http/pprof"` and run `go http.ListenAndServe(":6060", nil)` alongside the app.
| Endpoint | Shows |
|---|---|
| `/debug/pprof/profile` | CPU profile |
| `/debug/pprof/heap` | Live heap allocations |
| `/debug/pprof/allocs` | Cumulative allocation counts |
| `/debug/pprof/goroutine` | Goroutine stacks |
| `/debug/pprof/mutex` | Mutex contention |
| `/debug/pprof/block` | Blocking operations |
```bash
go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30
go tool pprof http://localhost:6060/debug/pprof/heap
```
### 2. `sync.Pool` — Reuse Temporary Buffers
Reuse buffers on high-frequency paths to relieve GC.
```go
var bufPool = sync.Pool{New: func() any { return new(bytes.Buffer) }}
func handleRequest(w http.ResponseWriter, r *http.Request) {
buf := bufPool.Get().(*bytes.Buffer)
defer func() { buf.Reset(); bufPool.Put(buf) }()
buf.ReadFrom(r.Body)
process(buf.Bytes())
}
```
**NEVER pool `strings.Builder` when returning `b.String()`** — `String()` shares the builder's internal buffer (no copy). Resetting the builder corrupts the string the previous caller still holds. Use `bytes.Buffer` and consume `buf.Bytes()` before reset.
Use `bytes.Clone(buf.Bytes())` when you need to retain data after the buffer is returned to the pool.
### 3. Pre-allocate Slices and Maps
Known size → pre-allocate. Avoids runtime reallocation and memory copying.
```go
// ❌
var result []int
for _, v := range input {
result = append(result, v*2)
}
// ✅
result := make([]int, 0, len(input))
```
### 4. `strings.Builder` for Concatenation
Strings are immutable. `+` in a loop creates a new string per iteration.
```go
var b strings.Builder
b.Grow(expectedTotalLength)
for _, word := range words {
b.WriteString(word)
}
```
### 5. `strconv` over `fmt`
`fmt` uses reflection. For basic type conversions, use `strconv`.
```go
s := strconv.Itoa(42) // not fmt.Sprintf("%d", 42)
s := strconv.FormatFloat(f, 'f', 2, 64) // not fmt.Sprintf("%.2f", f)
```
### 6. Struct Field Alignment
Order fields largest → smallest to minimize padding.
```go
// ❌ 24 bytes (padding waste)
type User struct {
IsAdmin bool // 1 + 7 padding
ID int64 // 8
Age int8 // 1 + 7 padding
}
// ✅ 16 bytes
type User struct {
ID int64 // 8
IsAdmin bool // 1
Age int8 // 1 + 6 padding
}
```
Use the `fieldalignment` tool to detect suboptimal ordering.
### 7. Prefer `strings`/`bytes` over `regexp`
`regexp` is safe but slow. Use `strings` functions for simple matching. If regex is unavoidable, compile once at package level with `regexp.MustCompile`.
### 8. Escape Analysis — Keep Allocations on the Stack
Don't return pointers to small, short-lived structs. For slices, use the append pattern — pass a destination slice so the caller manages memory.From els0r/skills, MIT.
More from els0r/skills
- 0.547score
blast-radius
els0r
Produce a risk-ranked audit map of a codebase (especially AI-generated code the user hasn't read), so the human can spend limited reading time where failure…
SkillBFreshness: B★ 1Claude Code +9 - 0.497score
go-testing
els0r
Go testing standards: table-driven tests, testify/require, sentinel errors, mocking, fuzzing, race detection, and test file conventions.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
design-rubric
els0r
Use when critiquing, reviewing, or refining visual designs, wireframes, or UI layouts — especially for small/medium SPAs.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
go-instrumentation
els0r
Observability principles for Go services: structured logging, distributed tracing, metrics, context propagation, and HTTP service bootstrap.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
go-style
els0r
Go coding conventions, error handling, interface design, and idiomatic patterns.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
improve-go-architecture
els0r
Find deepening opportunities in a Go codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
autonomous-orchestration
els0r
Use when the user explicitly hands over multi-PR coordination — asking Claude to follow through on a user story, work bundle, or backlog scope autonomously…
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
coding-style
els0r
Use for all code generation, review, and refactoring regardless of language.
SkillCFreshness: C★ 1Claude Code +9 - 0.486score
Codebase Analyzer
els0r
Analyzes codebase implementation details.
SkillCFreshness: C★ 1Claude Code +9 - 0.486score
Codebase Locator
els0r
Locates files, directories, and components relevant to a feature or task.
SkillCFreshness: C★ 1Claude Code +9 - 0.472score
grill-with-docs
els0r
Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as…
SkillCFreshness: C★ 1Claude Code +9 - 0.468score
diagnose
els0r
Disciplined diagnosis loop for hard bugs and performance regressions.
SkillCFreshness: C★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 20, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/els0r/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from els0r
- 0.547score
blast-radius
els0r
Produce a risk-ranked audit map of a codebase (especially AI-generated code the user hasn't read), so the human can spend limited reading time where failure…
SkillBFreshness: B★ 1Claude Code +9 - 0.497score
autonomous-orchestration
els0r
Use when the user explicitly hands over multi-PR coordination — asking Claude to follow through on a user story, work bundle, or backlog scope autonomously…
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
go-style
els0r
Go coding conventions, error handling, interface design, and idiomatic patterns.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
go-instrumentation
els0r
Observability principles for Go services: structured logging, distributed tracing, metrics, context propagation, and HTTP service bootstrap.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
design-rubric
els0r
Use when critiquing, reviewing, or refining visual designs, wireframes, or UI layouts — especially for small/medium SPAs.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
improve-go-architecture
els0r
Find deepening opportunities in a Go codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/.
SkillCFreshness: C★ 1Claude Code +9
Cite this page
go-performance skill. Agent Mart. https://agentmart.dev/skills/els0r-go-performance (last updated 2026-10-24)