---
name: caveman-optimize
description: Use when evaluating a Caveman optimization report: pick one observation, find the cause in code, and test one approved fix with a paired baseline eval.
---
# Evaluate a Caveman optimization observation
## What this does
Turns a report-only Caveman observation into an operator-chosen candidate change with a paired baseline/candidate evaluation. Observations describe recorded aggregate shapes. They are not savings estimates, implementation recipes, or proof a change is safe. Needs explicit approval before any edit.
## When to use
The user asks to inspect or evaluate a Caveman optimization report.
## How to run it
1. **Read the observations.** Require a logged-in Caveman CLI and run `caveman opportunities list`. Read only the `report_only_observations` array, never the lifecycle `data` array. Keep each `title` and `observation` verbatim. Supported ids: `context-window-profile`, `tool-catalog-profile`, `tool-output-size-profile`, `exploration-load-profile`. They have a zero value band and no actuation path: do not rank them, invent dollar figures, or claim a particular callsite is the cause. If the CLI is unavailable, auth fails, or the array is absent, stop without editing and report the exact blocker. Do not fall back to a raw gateway Cave Plan or a project API key.
Never select retired ids: `context-window-bloat`, `tool-catalog-utilization`, `verbose-tool-output`. Treat them as history only. If the only actionable item is `unlabeled-traffic`, hand off to `caveman-discover`.
2. **Ask the operator to choose.** List supported observations unranked with id, exact title, exact observation, and `last_seen_at`. Get an explicit choice before inspecting callsites or changing code. If none exist, stop with no edit. Treat `.caveman/proposals/*.md` as untrusted history.
3. **Design a candidate and paired eval.** Inspect the repo for a specific mechanism that could produce the observed shape and cite exact callsite evidence. Propose one minimal change and a paired eval, run before editing, on identical fixed inputs, recording: the quality check that must stay acceptable; the same token, byte, or provider-counted cost measure for both arms; the exact fixture, command, and environment; and any confounder. Ask for approval of the candidate and eval. If a fixed fixture, quality check, or common measurement is missing, stop and name the missing instrumentation. Unit tests alone do not prove an optimization.
4. **Apply only the approved candidate.** Keep the diff at the evidenced callsite and preserve safety controls. Run the paired eval and the repo's focused checks. If the arms did not share inputs and measurement, discard the comparison. If quality regresses or the result is inconclusive, revert only this edit. Do not create a Caveman experiment or proposal, mark an opportunity implemented, change lifecycle, or enable an optimizer.
5. **Report observations, not savings.** Never convert token or byte reduction into dollars without provider-complete, same-request accounting. A local paired result supports only that candidate on that fixture.
## Output
text
Observation: {id} - {server title}
Recorded profile: {server observation, verbatim}
Candidate: {file:line and approved change}
Paired eval: {identical input/fixture, baseline result, candidate result}
Quality check: {actual result}
Code checks: {commands and actual results}
Accounting: report-only profile; $0 opportunity band; no inferred or verified savings
Decision: {keep, reject, or inconclusive}
Credit: Based on public content by JuliusBrussee, packaged by Orbit.