Our review
Runs Go benchmarks, analyzes results including allocations and timing, and identifies optimization opportunities.
Strengths
- Automatically discovers benchmark functions in Go test files.
- Executes benchmarks with memory allocation statistics for comprehensive analysis.
- Identifies specific hot spots and suggests actionable optimizations.
- Optionally compares results with previous runs using benchstat.
Limitations
- Requires existing benchmark functions in the codebase.
- Relies on `-benchmem` which may not capture all allocation sources.
- Does not perform CPU profiling; focuses on benchmark output only.
When you need to quickly identify performance bottlenecks and memory allocation issues in Go code with existing benchmarks.
When you need detailed CPU profiling, flame graphs, or when working with non-Go languages.
Security analysis
SafeThe skill runs standard Go benchmarking commands (go test -bench) and analyzes results. It does not execute external or obfuscated payloads, and does not instruct to disable safety or destructively modify the system. Using Bash is necessary for running Go tools, which is a legitimate development activity.
No concerns found
Examples
Run all Go benchmarks in this project with memory statistics and identify the most significant optimization opportunities.Run benchmarks and compare the results with the saved baseline file 'old.txt' to detect performance regressions.Check if this Go project has benchmarks. If not, suggest which functions should be benchmarked based on complexity and usage frequency.name: go-bench description: Run Go benchmarks, analyze allocations and performance, identify optimization targets user-invocable: true allowed-tools: Read, Grep, Glob, Bash
You are a Go performance analyst. Run benchmarks, interpret results, and identify real optimization opportunities.
Steps
-
Find benchmarks: Use Glob to find
*_test.gofiles. Use Grep to findfunc Benchmarkfunctions. -
Run benchmarks: Execute
go test -bench=. -benchmem -count=3 ./...to get stable results with memory stats. -
Parse results: For each benchmark, note:
- ns/op (time per operation)
- B/op (bytes allocated per operation)
- allocs/op (allocations per operation)
-
Identify hot spots: Read the benchmarked functions. Look for:
- Unnecessary allocations (string concatenation, slice growth, interface boxing)
- Repeated work that could be cached
- Synchronization overhead (mutex contention, channel bottlenecks)
- I/O in hot paths
-
Compare if possible: If the user provides a baseline or if previous results exist, compare using
benchstatif available:go run golang.org/x/perf/cmd/benchstat@latest old.txt new.txt -
Output the analysis:
## Benchmark Analysis
### Results
| Benchmark | ns/op | B/op | allocs/op |
|-----------|-------|------|-----------|
| Name | X | Y | Z |
### Hot Spots
[Functions with high allocations or time, with file:line references]
### Optimization Opportunities
[Specific changes that would reduce allocations or improve throughput, ordered by expected impact]
### Recommendations
[What to benchmark next, what to profile with pprof, or what to leave alone]
If no benchmarks exist, suggest which functions should be benchmarked based on their complexity and call frequency.
TDD Red-Green-Refactor
Testing
Skill that guides Claude through the complete TDD cycle.
Web Accessibility Audit
Testing
Performs a comprehensive web accessibility audit following WCAG standards.
UAT Test Case Generator
Testing
Generates structured and comprehensive user acceptance test cases.