/fh-commons:token-budget-gatefrom fh-commons
Estimates token cost before multi-step tasks and outputs a 4-tier gate verdict (Green/Yellow/Orange/Red). Records actual vs estimated after completion to calibrate estimates. Prevents surprise token overruns.
Ships in fh-commons. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Multi-step and multi-agent tasks can silently consume large token budgets. This skill estimates cost before execution, outputs a gate verdict, and calibrates estimates against actual usage after completion — preventing surprise overruns without blocking legitimate work.
FH context: FH default execution tier is
standard(~15K tokens). This skill gates against accidentalfull(~30K) ormax(~60K+) consumption on tasks that could be handled lighter.
/token-budget-gateagent-composer, sim-conductor, steel-quench (max-tier skills)| Signal | Verdict | Action |
|---|---|---|
| Estimated < 10K tokens | 🟢 GREEN | Proceed without comment |
| 10K–30K tokens | 🟡 YELLOW | Proceed with notice — suggest lighter approach if one exists |
| 30K–60K tokens | 🟠 ORANGE | Confirm before proceeding — present scope reduction options |
| > 60K tokens | 🔴 RED | Block + require explicit approval — present mandatory reduction |
Custom threshold: user can set TOKEN_BUDGET_MAX=N in conversation or .claude/settings.json.
Extract task dimensions:
| Dimension | Low (×1) | Medium (×2) | High (×4) |
|---|---|---|---|
| File scope | 1–3 files | 4–10 files | 11+ files / whole codebase |
| Agent count | 0 (inline) | 1–2 agents | 3+ agents / parallel |
| Step depth | 1–3 steps | 4–8 steps | 9+ steps |
| Iteration | None | 1 round | 2+ rounds (wave/loop) |
| Output size | Short answer | Medium doc | Full report / deck |
Base estimates per task type:
| Task Type | Base Estimate | Notes |
|---|---|---|
| Single file edit | 2K | Read + edit + verify |
| Code review (1 PR) | 5K | Diff + analysis + comments |
| Skill creation (1 SKILL.md) | 8K | Design + write + CATALOG update |
| Agent dispatch (1 agent) | 10K | Context card + agent overhead |
| Parallel dispatch (3 agents) | 25K | 3× agent + orchestration |
| sim-conductor full run | 30K | All 5 simulation axes |
| steel-quench 4-wave | 50K | All waves + prescriptions |
| Full harvest-loop cycle | 40K | 8-step pipeline + PRs |
Apply dimension multipliers from Step 1 to the base estimate.
Calibration override (read leg): if .claude/token_calibration/log.tsv exists and holds ≥1 row
for this task type, derive the base as median(actual_i / mult_i) over its rows — each row's mult
column records the dimension-multiplier product that was in effect, so dividing recovers a
dimension-neutral base. Never use raw actual as the base: actual already contains that run's
multipliers, and re-applying this run's multipliers on top double-counts scope. The table above is the
uncalibrated default; measured local data outranks it. State which source the estimate used
(base: table (uncalibrated) or base: calibration log, n={rows}).
Final formula:
Estimated = base × file_multiplier × agent_multiplier × iteration_multiplier
Round to nearest 1K.
## Token Budget Gate
Task: {one-line task description}
Estimated cost: ~{N}K tokens
Threshold: {user max or default}
Verdict: 🟡 YELLOW — within budget but consider lighter approach
Breakdown:
Base (skill creation): 8K
× 2 agents: ×2 = 16K
× 1 iteration: ×1 = 16K
Total: ~16K
Lighter alternative:
→ Inline (no agent dispatch): ~8K (-50%)
→ Single agent, not parallel: ~12K (-25%)
Proceed? (y to continue / n to adjust scope)
For 🟢 GREEN: output one line only — "Token estimate: ~{N}K — GREEN, proceeding."
Scope reduction options table (ORANGE/RED):
| Option | Reduction | Trade-off |
|---|---|---|
| Drop parallel → sequential | -30% | Slower, same quality |
| Reduce agent count (3→1) | -50% | Less parallelism |
| Narrow file scope | -40% | Shallower coverage |
| Use lighter skill variant | -60% | Fewer waves/probes |
| Split into 2 sessions | -50%/session | No quality loss |
After task completion, if user says "how much did that cost" or "calibrate":
Actual must come from a mechanical source — the user pasting /cost output, or budget.spent()
in a Workflow context. A model cannot read its own token consumption by introspection; a reconstructed
number written into the log poisons every future estimate that reads it (the read leg in Step 2).
No mechanical source available → render Actual: UNMEASURED and write no row.
## Calibration
Estimated: ~16K tokens
Actual: ~{actual}K tokens (source: /cost paste | budget.spent() | UNMEASURED)
Error: {+/-N}% (omit when UNMEASURED)
Write calibration data (only when Actual is mechanically sourced):
mkdir -p .claude/token_calibration/
# mult = this run's dimension-multiplier product (Step 1) — stored so the read leg can divide it
# back out; a log without it makes every future estimate double-count scope.
printf '%s\t%s\t%s\t%s\t%s\n' "{task_type}" "{estimated_k}" "{actual_k}" "{mult}" "$(date +%F)" \
>> .claude/token_calibration/log.tsv
Recorded rows feed the Step 2 calibration override for the same task type (no model training — local record only).
actual (pasted /cost or
budget.spent()); no mechanical source → Actual: UNMEASURED, no row — mandatory-pass(Post-task calibration is an offer in Step 5, not a completion condition — a completion condition marked "optional" is not a completion condition.)
Upstream (proposed before these skills):
agent-composer (multi-agent orchestration)sim-conductor (5-axis simulation)steel-quench (4-wave adversarial review)harvest-loop (8-step pipeline)Downstream:
arXiv:2606.27009 (Semantic Early-Stopping for Iterative LLM Agent Loops, 2026-06-25, verified
2026-06-27) measures −38% tokens by stopping iterative agent loops on semantic convergence instead
of a fixed iteration cap — external evidence that the largest avoidable spend in loop-shaped work is
over-iteration, the cost class this gate exists to flag. Caveat (provenance-honest): the same paper
found judge-gated stopping counterproductive (judging cost outweighs the saving), so the saving is
real only when the convergence signal is cheap. Pairs with convergence-loop (the stop-rule side of
the same finding).
What SKILL.md sets; muted values are Claude Code's defaults
sonnetThree short reads, in order
token-budget, cost-estimation, gate, token-management, multi-agent
8 skills in this plugin
/convergence-loopA universal gate-reinforcement meta-skill that replaces the "single-pass = done" pattern with a converging loop of up to N rounds. Can be applied to any gate, checkpoint, or verification step. Only declares "truly passed" after FAIL→FIX→re-verify repeats until convergence (all items pass). Escalates to structural redesign if not converged within N rounds. Triggers on: "convergence-loop", "how many rounds do we need", "suspicious of single-pass", "not sure if it really passed", or equivalent phrasing./deliberationMulti-perspective synthesis structure — Innovator (propose) → Devil-Advocate (challenge) → Mediator (synthesize) 3-layer execution. Outputs conditional verdicts without binary win/loss. Activates on "deliberation", "battle this out", "weigh the pros and cons", "review from multiple angles", "which side is right?". Optional deep-insight persona jurors for domain-specific views. Designed for design decisions, skill proposals, and architectural choices./essay-writerDrafts, revises and audits reflective non-fiction essays and essay serials (philosophy, humanities, science-meets-life pieces, platform serials, book chapters) — Korean first, other languages by the same steps. Pins the author's voice decisions before any edit (narrator person including the inclusive "we", register, length band, where each signature image lives), runs a claim gate that separates sourced fact, contested fact and interpretation, maps repeated images and verbatim sentences across episodes, calibrates hedging so conviction survives, and checks mobile rhythm and episode-to-episode bridges. The essay writer is the only one who edits prose; a technical reviewer critiques read-only. Technical docs, tech-blog posts and talk scripts go to ko-tech-writer instead. Triggers: "에세이 다듬어줘", "연재 원고 검토해줘", "브런치 연재 회차 점검해줘", "이 글 단정적인 데 없나 봐줘", "에세이에서 1인칭 빼줘", "회차마다 같은 비유가 반복되나 봐줘", "review my essay serial", "audit this essay for overclaiming"./ko-tech-writerWrites or revises Korean technical prose across three registers — reader-facing documents (tech-blog posts, technical docs), spoken scripts, and derived compressed assets (teasers, summaries) — through a fixed pipeline: register detection, real-sample calibration of the target venue, a translationese-removal pass, honesty-level layering (reader information vs internal audit vocabulary), a number/claim gate, and a rendition + perceptual QA pass. Triggers: "기술문서 써줘", "테크블로그 초안 잡아줘", "이 문서 번역투 고쳐줘", "블로그체로 다듬어줘", "이 글 회사 기술블로그에 올릴 수 있게 다듬어줘", "발표 대본 다듬어줘", "낭독 대본 점검해줘", "이 스크립트 소리 내서 읽을 때 걸리는 데 있나"./mcp-circuit-breakerDetects MCP tool failure patterns and trips a circuit breaker to stop cascading retries. Proposes fallback alternatives and resets when the tool recovers. Triggers on "MCP failing", "tool keeps erroring", "circuit-breaker", repeated tool call failures./persona-castUse to get a screen, page, form, flow or spec looked over the way its users and a review team would: does it look right, is the wording clear, where would someone get confused or stuck. Sends it to separate reviewer personas (designer, UX writer, front/back-end dev, QA, accessibility) and keeps what each one alone caught. Triggers: "이 화면 어때?", "이 페이지 괜찮아 보여?", "화면 문구 어색한 데 없어?", "사용자가 헷갈릴까?", "디자이너·QA 눈으로 봐줘", "does this page look okay?", "is the wording on this screen clear?", "persona-cast".npx claudepluginhub chrono-meta/forge-harness --plugin fh-commonsOther plugins' skills for the same job