-
-
Notifications
You must be signed in to change notification settings - Fork 0
Cost preflight
Home / Operations / Cost preflight
Pre-send guard that estimates the dollar cost of a review and prompts/aborts when it exceeds the configured threshold. Catches "oops, I pasted a 50k-line generated file" before tokens are actually spent.
Right after the cache lookup, before the provider call. The cache hit path skips it entirely (no provider call, no cost).
estimated_input_tokens = prompt.EstimatedTokens() # chars/4 heuristic
estimated_output_tokens = clamp(estimated_input / 4, 200, 1500)
estimated_cost = provider.Pricing(model).Cost({
InputTokens: estimated_input_tokens,
OutputTokens: estimated_output_tokens,
})
- Input tokens: chars-divided-by-4 — the well-known approximation.
- Output tokens: capped at 1500 (typical structured-finding review is 200–1500), floored at 200. Underestimating output matters: Opus output costs 5× the input, so a low estimate could hide the actual bill.
-
Cost: applies the provider's pricing table (see each
Provider page) including cached-input discounts
where supported. Rates can be overridden per model via
providers.<name>.pricing.<model>in config — see Configuration files (OQ-09).
The output-token heuristic intentionally errs high; if the user cares about precision, lower the cost threshold rather than reach for the heuristic.
| Config | Default | Meaning |
|---|---|---|
cost.warn_threshold_usd |
0.50 |
Estimated dollar cost above which the preflight fires. |
0 or negative disables the check entirely. Bump it for scheduled
jobs (a CI runner doing 100 reviews/day cares less about a single
$1 review).
| Estimated cost | Context | Outcome |
|---|---|---|
<= threshold |
any | Silent. Review proceeds. |
> threshold |
TTY, no --no-cost-check, no --yes
|
Prompt; default no → abort. |
> threshold |
TTY, --yes
|
Prompt still shows. --yes does NOT bypass since v0.9.1 (UC-06). |
> threshold |
Non-TTY, no --no-cost-check
|
Abort with Aborted (non-interactive); pass --no-cost-check or raise cost.warn_threshold_usd to override.
|
| any | --no-cost-check |
Skip the preflight entirely. |
When the preflight fires (TTY):
⚠ Estimated cost: $0.8421 (threshold: $0.5000)
Proceed with the review?
Yes ▸ No (←/→ to choose · Enter to confirm)
The confirmation is an arrow-key Yes/No toggle (huh), pre-selected
on No. Picking No (or pressing Enter on the default) aborts
with aborted: cost preflight. Non-TTY/piped input is unchanged: it
falls back to the typed y/N line, and a non-TTY run aborts outright
(see the matrix above).
Ollama, claude-cli, and gemini-cli return Pricing{} (all
zero). The cost preflight short-circuits silently — estimated
cost is always 0, never above the threshold, so the prompt never
fires. The verbose footer shows — instead of a dollar figure
in these cases.
commitbrief --staged --no-cost-check# Set a higher ceiling.
commitbrief config set cost.warn_threshold_usd 5.0
# Disable entirely.
commitbrief config set cost.warn_threshold_usd 0Important
Since v0.9.1 (UC-06), --yes no longer bypasses the cost
preflight. Users routinely wire --yes into CI to skip the
.commitbrief/ guard prompt, and we did not want that to also
silently approve unbounded spend. Use --no-cost-check
explicitly if you want bypass-on-CI semantics.
- Review command — pipeline position.
-
Configuration files —
cost.warn_threshold_usd. - Cache — cache hits skip the preflight entirely.
Home · Installation · Quick start · Troubleshooting · GitHub repo · Issues
CommitBrief — local, LLM-powered code review for git diffs. This wiki documents only what ships in the binary.
Getting started
Commands · reviewing
Commands · summarizing
Commands · committing
Commands · setup
Commands · integration
Commands · inspect
Commands · maintenance
Configuration
Providers
Output
Operations
Reference