context-budget

context-budget is a command for Claude Code from sairam0424/MindForge. It costs 32 tokens per session (761 once invoked), scanned A, original, MIT.

A command that examines how information is allocated in an AI model's context window, the text and instructions it can consider at once.

In plain words
What is it for?
Use it to measure token use, rank context by relevance, and optimize an allocation up to a chosen token limit.
Why use it?
It helps identify wasted, repeated, outdated, or low-value context when the available space is limited.

Command for Claude Code

Written for Claude Code: $ARGUMENTS substitution. Also seen: mentions CLAUDE.md.

Good fit Use it to measure token use, rank context by relevance, and optimize…

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/sairam0424/mindforge/context-budget
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/sairam0424/MindForge

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for context-budget

README.md
[![agentmods](https://agentmods.dev/badge/commands/sairam0424/mindforge/context-budget.svg)](https://agentmods.dev/commands/sairam0424/mindforge/context-budget)
Your own site
<a href="https://agentmods.dev/commands/sairam0424/mindforge/context-budget"><img src="https://agentmods.dev/badge/commands/sairam0424/mindforge/context-budget.svg" alt="Measured on agentmods" height="20"></a>
Per session 32 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 761 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00032 $0.00761
Opus 5 $0.00016 $0.00380
Sonnet 5 $0.00006 $0.00152
Haiku 4.5 $0.00003 $0.00076

Measured 3d ago against content hash 9b6cda47c94e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

context-budget scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/mindforge/context-budget.md · 71 lines

What it actually says

<execution_context> @.mindforge/skills/context-engineering/SKILL.md </execution_context>

  1. Measure token costs per item: For each context item:

    • Calculate raw token count
    • Assess information density (unique facts per 100 tokens)
    • Score temporal relevance (how recently referenced)
    • Score task relevance (direct bearing on current objective)
    • Identify redundancy (same info stated multiple ways)
    • Flag stale items (conversation turns > 10 back with no references)
  2. Prioritize by relevance: Apply the priority matrix:

    • P0 (Critical): Active task instructions, current file contents, error messages
    • P1 (High): Architecture context, type definitions, test fixtures
    • P2 (Medium): Historical decisions, related file contents, examples
    • P3 (Low): General documentation, old conversation turns, verbose outputs
    • Score each item 0-10 on task alignment
  3. Apply budget allocation (60/20/10/10): Distribute max-tokens:

    • 60% — Active working context (current files, task, instructions)
    • 20% — Supporting context (types, tests, architecture docs)
    • 10% — History and decisions (conversation, rationale)
    • 10% — Buffer for tool results and new information
    • Adjust ratios based on task type (debugging needs more history)
  4. Identify compaction candidates: Find items that can be compressed:

    • Long tool outputs that can be summarized (test results → pass/fail counts)
    • Verbose file contents where only specific functions matter
    • Repeated context that can be deduplicated
    • Conversation segments that can be summarized into key decisions
    • Large code blocks where only the interface/signature matters
  5. Prune low-value items: Remove or compress based on scoring:

    • Drop items scoring < 3 on task relevance
    • Summarize items scoring 3-5 into single-line references
    • Compact items scoring 5-7 to essential excerpts
    • Keep items scoring 7+ in full
    • Document what was pruned for recovery if needed
  6. Verify essentials retained: Post-optimization validation:

    • Confirm all P0 items are present in full
    • Verify no broken references (file mentioned but content pruned)
    • Check that task can still be completed with remaining context
    • Ensure error context is preserved for debugging tasks
    • Calculate final utilization percentage and headroom
    • Output budget report with before/after comparison
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 71 lines · 32 tokens per session scan A 9b6cda47c94e

Subscribe to this mod's changes

context-budget is a command published in the GitHub repository sairam0424/MindForge (0 stars, last pushed 3d ago), licensed MIT. It adds 32 tokens to every session and 761 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.