Agent skill
optimization-techniques
Performance optimization strategies. Use ONLY after profiling identifies bottlenecks.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/optimization-techniques
SKILL.md
Optimization Techniques Skill
Performance optimization strategies for Go. ONLY use after profiling!
When to Use
Use ONLY after profiling identifies actual bottlenecks. NEVER optimize prematurely (KISS principle).
Pre-allocate Slices
// Good - pre-allocate when size known
items := make([]Item, 0, expectedSize)
// Bad - repeated allocations
var items []Item
Use strings.Builder
// Good
var b strings.Builder
for _, s := range strings {
b.WriteString(s)
}
result := b.String()
// Bad - repeated allocations
result := ""
for _, s := range strings {
result += s
}
sync.Pool for Reusable Objects
var bufferPool = sync.Pool{
New: func() interface{} {
return new(bytes.Buffer)
},
}
buf := bufferPool.Get().(*bytes.Buffer)
defer bufferPool.Put(buf)
buf.Reset()
// use buf
Minimize Allocations
// Good - reuse buffer
buf := make([]byte, 1024)
for {
n, _ := r.Read(buf)
process(buf[:n])
}
// Bad - allocate each time
for {
buf := make([]byte, 1024)
n, _ := r.Read(buf)
process(buf[:n])
}
Golden Rules
- Profile first - Don't guess
- Measure impact - Benchmark before/after
- KISS principle - Simple first, optimize later
- Maintain readability - Don't sacrifice clarity
- Focus on hot paths - 80/20 rule
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?