rlpatrao/claude_harness_forge/context-budget

Claude Code and agent skill by rlpatrao/claude_harness_forge

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Analyze and optimize token usage — cost summary, cost per agent, per story, per gate, cache hit rates, and recommendations for context reduction. Use --summary for a quick cost overview.

Install

npx vskill@latest install rlpatrao/claude_harness_forge/context-budget

SKILL.md

The same SKILL.md was published earlier as rlpatrao/claude_harness_forge/context-budget.

Context Budget Skill

Analyze token consumption across the build and recommend optimizations to reduce cost and improve efficiency.

Usage

/context-budget # full analysis + recommendations
/context-budget --summary # quick cost summary only (replaces former /cost)

Run anytime during or after a build.


Prerequisites

  • cost-log.json exists with token usage entries from the build.

Step 1 — Read Cost Log

Read cost-log.json. Parse entries for:

  • Token counts (input, output, cache_read, cache_write) per interaction
  • Agent type (architect, generator, evaluator, reviewer, etc.)
  • Story/task identifier
  • Gate stage (test, lint, coverage, architecture, evaluator, reviewer, ui-standards, security)
  • Timestamp and duration

Step 2 — Calculate Usage by Agent Type

Aggregate tokens per agent:

  • Total input tokens, output tokens, cache tokens
  • Average tokens per invocation
  • Number of invocations
  • Most expensive single invocation

Step 3 — Calculate Usage by Story

Aggregate tokens per story/task:

  • Total cost per story
  • Breakdown by gate stage
  • Number of GAN iterations (generator-evaluator cycles)
  • Identify stories with unusually high token consumption

Step 4 — Calculate Usage by Gate

Aggregate tokens per gate stage:

  • Total cost per gate across all stories
  • Average cost per gate invocation
  • Pass/fail rate per gate (failed gates cost extra due to rework)

Step 5 — Check Prompt Caching Opportunities

Analyze cache performance:

  • Cache hit rate (cache_read / total_input)
  • Identify large uncached prompts that repeat across invocations
  • Estimate savings from improved caching

Step 6 — Recommend Context Reduction Strategies

Based on analysis, recommend:

  • Reducing file loading scope (e.g., "load only owned files instead of full component map")
  • Splitting large stories to reduce per-invocation context
  • Improving cache hit rate via prompt structure changes
  • Reducing GAN iterations via better generator prompts
  • Skipping unnecessary gate stages for trivial changes

Step 7 — Generate Cost Projection

For remaining work:

  • Estimate tokens needed based on remaining stories
  • Project total build cost
  • Compare against budget if configured in manifest

Output Format

Print report to console (not saved to file):

=== Context Budget Report ===
## Current Usage
- Total tokens: X (input: X, output: X, cached: X)
- Cache hit rate: X%
- Total cost estimate: $X.XX
## By Agent
| Agent | Tokens | Invocations | Avg/Call |
|-------------|----------|-------------|----------|
| generator | X | X | X |
| evaluator | X | X | X |
| ... | ... | ... | ... |
## By Story (top 5 most expensive)
| Story | Tokens | GAN Cycles | Gate Fails |
|-------------|----------|-------------|------------|
| ... | ... | ... | ... |
## Recommendations
- [specific, actionable recommendations]
## Projection
- Remaining stories: X
- Estimated remaining tokens: X
- Projected total cost: $X.XX

Quick Summary Mode (--summary)

When invoked with --summary, skip Steps 3-7 and print only a compact cost overview:

Mode: {mode} (budget: ${low}-${high})
Model routing: {strategy} ({local_model_name if applicable})
Agent spawns: {count}
Estimated total: ${amount} ({pct}% of budget ceiling)
Breakdown: Opus {n} spawns (${amount}), Sonnet {n} spawns (${amount}), Local {n} spawns ($0.00)
Top consumers: {agent1} (${amount}), {agent2} (${amount}), {agent3} (${amount})

Also read execution.model_routing from project-manifest.json and display the routing strategy. When strategy is local-only, show:

Model routing: local-only (Qwen3-Coder-480B-A35B-Instruct via vLLM)
Estimated API cost: $0.00 (all local)
Note: Local inference has compute cost (GPU time) not tracked here.
Estimation Method
ModelInput $/1M tokensOutput $/1M tokensAvg inputAvg output
Opus$15$7515K tokens5K tokens
Sonnet$3$1510K tokens3K tokens
Local$0$0N/AN/A

Caveat: These are rough directional estimates, not actual billing. Token counts are approximated. Actual costs depend on prompt caching, system prompt sharing, and output length variation.

Budget Ranges by Mode
ModeLowHigh
Full$100$300
Lean$30$80
Solo$5$15
Turbo$30$50

Gotchas

  • Report only, no file output. This skill prints to console for immediate review. Recommendations are for manifest tuning, not automated changes.
  • Cache hit rate depends on prompt structure. Small changes to system prompts can invalidate the entire cache.
  • GAN iterations are the biggest cost driver. Focus optimization on reducing evaluator failures, not on trimming individual prompts.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/rlpatrao/claude_harness_forge/context-budget/badge)](https://verified-skill.com/skills/rlpatrao/claude_harness_forge/context-budget)

Something wrong with this skill or its page? Tell us.