
hunt-optimization
by blt
Claude skills for experimenting with datadog-agent
SKILL.md
name: hunt-optimization description: Systematic optimization hunter. Finds memory optimizations AND bugs - both are valuable. Run /validate-correctness when bugs are discovered.
Optimization Hunt
Systematically explores the codebase, implements optimizations, validates with benchmarks. Finding bugs is equally valuable as finding optimizations.
Valuable Outcomes
| Outcome | Value | Action |
|---|---|---|
| Optimization works | Memory improved | Submit to /review-optimization |
| Optimization fails | Learned cold path | Record, next target |
| Bug discovered | Found correctness issue | Invoke /validate-correctness |
All three outcomes build institutional knowledge.
Phase 0: Pre-flight
Run /preflight first. Then check what's already been done:
cat ~/.claude/skills/hunt-optimization/hunts.yaml
cat ~/.claude/skills/review-optimization/reviews.yaml
If a target/technique combination exists in either database → SKIP IT.
Phase 1: Select Target
Target Sources
Use profiling data when available:
go tool pprof -top -alloc_objects mem.pprof | head -20
Otherwise, check the queue in hunts.yaml or pick from hot subsystems:
pkg/metrics- per-metric-sample pathpkg/aggregator- aggregation hot loopcomp/dogstatsd- ingestion pathcomp/core/tagger- tag resolution
Phase 2: Analyze Target
Identify Opportunity Type
| Pattern | Technique | Bug Risk |
|---|---|---|
append() in loop | Preallocation | make([]T, n) vs make([]T, 0, n) |
map[K]V{} | Size hint | None |
String + in loop | strings.Builder | None |
new(T) repeated | sync.Pool | Reset state issues |
| Large struct by value | Pointer | Nil pointer risk |
Watch for bugs while analyzing - they're valuable findings.
Phase 3: Implement
git checkout main && git pull
git checkout -b mem-opt/<package>-<technique>
Make ONE change. Commit:
git commit -m "mem-opt: <description>
Hypothesis: <expected improvement>
Technique: <prealloc|pool|builder|etc>
"
Phase 4: Benchmark
# Baseline first, then optimized
git stash
git checkout main
go test -bench=<Name> -benchmem -count=10 ./pkg/... > /tmp/baseline.txt
git checkout -
git stash pop
go test -bench=<Name> -benchmem -count=10 ./pkg/... > /tmp/optimized.txt
benchstat /tmp/baseline.txt /tmp/optimized.txt
Decision Point
| Result | Action |
|---|---|
| B/op improved >=5%, p<0.05 | → /review-optimization |
| No change or regression | → Record FAILURE, next target |
| Tests fail unexpectedly | → Might be a BUG |
| Behavior changed | → Might be a BUG |
Phase 5: Handle Bug Discovery
If during hunting you discover a bug (not an optimization):
Invoke Correctness Validation
/validate-correctness
This skill will:
- Create reproducing test
- Verify fix works
- Add fuzz test if appropriate
- Record in validations.yaml
After Validation
Return here and record as BUG_FOUND (a success!):
- target: pkg/foo/bar.go:Function
date: 2026-01-06
result: BUG_FOUND
bug_id: <from validations.yaml>
lesson: "Found make([]T, n) + append bug"
Then continue hunting - don't stop.
Phase 6: Record & Continue
MANDATORY: Update hunts.yaml
- target: pkg/path/file.go:Function
date: 2026-01-06
branch: mem-opt/name
technique: preallocation
result: SUCCESS|FAILURE|BUG_FOUND
delta_bop: "-18%" | "~" | "N/A"
lesson: "<pattern>"
Immediately Continue
Target completed → Back to Phase 1 → Pick new target → Never stop
Usage
/hunt-optimization
A 10% combined success rate (optimizations + bugs) is excellent. Most targets are cold paths - that's expected.
スコア
総合スコア
リポジトリの品質指標に基づく評価
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
レビュー
レビュー機能は近日公開予定です