Automated summary
This skill guides writing correct Go benchmarks, measuring with -benchmem and pprof, optimizing hot paths, then proving the gain with a before/after benchstat comparison.
Strengths
- Provides a correct Go 1.24+ benchmark template (b.Loop, ReportAllocs, package-level sink to prevent dead-code elimination)
- Requires statistical proof of improvement via benchstat and rejects changes that regress allocations or other benchmarks
- Lists typical optimizations ordered cheapest first (allocations, reflection, loop hoisting, algorithmic change)
- Explicitly scopes when not to optimize cold code
Limitations
- Assumes mise tasks (bench, bench:baseline, bench:compare) already exist in the repository
- Targets Go 1.24+ for b.Loop; older versions need the classic b.N loop
- Covers only unit-level Go benchmarks, not end-to-end or multi-service performance testing
Use when writing a Go benchmark or when asked to measure and optimize the performance of a function on a hot path.
Avoid for cold code where clarity matters more than a tiny gain, or outside a Go project.
Security analysis
CautionThe skill is purely instructional Go performance guidance. Commands shown are standard, legitimate developer tooling (go test, pprof, benchstat) with no destructive, exfiltrating, or obfuscated actions and no secret handling. It is rated caution only because it directs execution of build/test/benchmark tooling and repo-defined mise tasks without declaring allowed-tools, so the actual command surface depends on the host repository.
- •Includes shell commands (go test -bench, go tool pprof, mise run bench/bench:baseline/bench:compare) that an agent may execute, but no allowed-tools are declared to scope this
- •Assumes repo-specific mise tasks (bench, bench:baseline, bench:compare) whose behavior is not shown and depends on the host repo
Examples
Write a correct benchmark for distance() in internal/search and report allocs per op.Our candidate search feels slow — profile it, optimize the hot path, and prove the gain with benchstat before/after.Check the allocations in the distance function's benchmark and reduce them without changing behavior.name: go-benchmark description: Use when writing Go benchmarks or when asked to measure/optimize/improve the performance of a function — establishes correct benchmarks, measures with -benchmem and pprof, optimizes hot paths, and proves the gain (and no regression) with benchstat.
Go Benchmarking & Performance
Goal: only optimize what's measured. Write a correct benchmark, measure, optimize, and
prove the improvement with benchstat before/after.
When to benchmark (the right targets)
Benchmark a function when: it's on a hot path (called in tight loops — e.g. the candidate-search and image-distance core of the port), it allocates heavily, or someone claims it's "slow". Do NOT micro-optimize cold code — clarity wins there (see go-style-guide).
Writing a correct benchmark (Go 1.24+)
func BenchmarkDistance(b *testing.B) {
img := loadFixture() // setup OUTSIDE the loop
b.ReportAllocs() // always report allocs
b.ResetTimer() // if setup was non-trivial
for b.Loop() { // Go 1.24+: not `for i := 0; i < b.N; i++`
sink = distance(img) // assign to a package-level sink…
}
}
var sink int // …to stop the compiler eliminating the call
b.Loop()(Go 1.24+) — keeps setup/cleanup out of the timed region automatically.b.ReportAllocs()— allocs/op is usually the real lever.- Prevent dead-code elimination: store results in a package-level
sink. - Table-driven sub-benchmarks with
b.Run(name, …)for input sizes. b.RunParallelfor contention;b.SetBytes(n)for throughput (MB/s).
Measure
mise run bench # go test -bench -benchmem ./...
go test -bench=Distance -benchmem -cpuprofile cpu.prof -memprofile mem.prof ./internal/...
go tool pprof -top cpu.prof # find the hot frames / allocations
Optimize (typical levers, cheapest first)
- Reduce allocations: preallocate slices/maps with known size, reuse buffers
(
sync.Pool,bytes.Buffer), avoid[]byte↔stringcopies (strings.Builder). - Avoid reflection / interface boxing on hot paths; use generics or concrete types.
- Hoist work out of loops; precompute; use
slices/mapshelpers. - Algorithmic improvement (better complexity) beats micro-tuning — escalate to
algo-architectif the win is algorithmic.
Prove the gain (mandatory)
mise run bench:baseline # save baseline BEFORE changing code
# …optimize…
mise run bench:compare # benchstat baseline vs new → shows %delta + significance
Keep a change only if benchstat shows a statistically significant improvement (and no
regression in allocs or other benchmarks). Commit the benchmark alongside the optimization.
Notes
- Benchmark artifacts (
bench*.txt,*.prof) are gitignored and cleaned byrepo-janitor. - Don't sacrifice clarity for a tiny gain — measure first, and only optimize where it matters.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/go-benchmarking-performance-mrwak9qz' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/go-benchmarking-performance-mrwak9qz/download' --output '.skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md.part' && mv '.skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md.part' '.skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md' && test -s '.skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/go-benchmark' && cp -R '.skill-downloads/go-benchmarking-performance-mrwak9qz' '.claude/skills/go-benchmark'Cursor
test -f '.skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md' && test -s '.skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/go-benchmark' && cp -R '.skill-downloads/go-benchmarking-performance-mrwak9qz' '.cursor/skills/go-benchmark'Codex
test -f '.skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md' && test -s '.skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/go-benchmark' && cp -R '.skill-downloads/go-benchmarking-performance-mrwak9qz' '.agents/skills/go-benchmark'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/go-benchmarking-performance-mrwak9qz'openskills read 'go-benchmarking-performance-mrwak9qz'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/go-benchmarking-performance-mrwak9qz/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.