rlpatrao/claude_harness_forge/context-budget
Claude Code and agent skill by rlpatrao/claude_harness_forge
- community
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-budgetSKILL.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
Run anytime during or after a build.
Prerequisites
cost-log.jsonexists 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):
Quick Summary Mode (--summary)
When invoked with --summary, skip Steps 3-7 and print only a compact cost overview:
Also read execution.model_routing from project-manifest.json and display the routing strategy. When strategy is local-only, show:
Estimation Method
| Model | Input $/1M tokens | Output $/1M tokens | Avg input | Avg output | |
|---|---|---|---|---|---|
| Opus | $15 | $75 | 15K tokens | 5K tokens | |
| Sonnet | $3 | $15 | 10K tokens | 3K tokens | |
| Local | $0 | $0 | N/A | N/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
| Mode | Low | High | |
|---|---|---|---|
| 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
- SKILL.md in the repositoryCheckingskills/context-budget/SKILL.md
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
[](https://verified-skill.com/skills/rlpatrao/claude_harness_forge/context-budget)