Back to list
blt

hunt-optimization

by blt

Claude skills for experimenting with datadog-agent

0🍴 0📅 Jan 14, 2026

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

OutcomeValueAction
Optimization worksMemory improvedSubmit to /review-optimization
Optimization failsLearned cold pathRecord, next target
Bug discoveredFound correctness issueInvoke /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 path
  • pkg/aggregator - aggregation hot loop
  • comp/dogstatsd - ingestion path
  • comp/core/tagger - tag resolution

Phase 2: Analyze Target

Identify Opportunity Type

PatternTechniqueBug Risk
append() in loopPreallocationmake([]T, n) vs make([]T, 0, n)
map[K]V{}Size hintNone
String + in loopstrings.BuilderNone
new(T) repeatedsync.PoolReset state issues
Large struct by valuePointerNil 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

ResultAction
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:

  1. Create reproducing test
  2. Verify fix works
  3. Add fuzz test if appropriate
  4. 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.

Score

Total Score

55/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

0/5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon