Skip to main content

context-budget

Know your token cost before you load.

A CLI tool for Claude Code users. Counts the token cost of files in your workspace so you can make informed decisions about what to load in a session — before you hit the context wall.

The Problem

Claude Code has a ~200K token context window. Your system prompt + tools already consume ~80K. Every file you load eats into the remaining ~120K. Load too much = early compaction = shorter, less useful sessions.

But you don't know the cost until it's too late.

The Solution

# See what's eating your context budget
python3 context_budget.py scan ./my-workspace

# Check the exact cost of files you're about to load
python3 context_budget.py check CLAUDE.md M-memory/SESSION-BRIEF.md A-agents/jams-agent.md

# Validate your tiered loading strategy (reads CLAUDE.md tier definitions)
python3 context_budget.py tier ./my-workspace

Install

pip install tiktoken
# That's it — single file, no other dependencies

Example Output

--- Token Scan Results for './M-memory' ---
Budget: 50,000 tokens | Claude Max Context: 200,000 tokens
───────────────────────────────────────────────────────────
  15,134 tokens  (30.3% budget) (7.6% window)  learning-log-archive.md
   9,080 tokens  (18.2% budget) (4.5% window)  vision-backlog.md
   2,793 tokens   (5.6% budget) (1.4% window)  decisions.md
   1,656 tokens   (3.3% budget) (0.8% window)  SESSION-BRIEF.md
───────────────────────────────────────────────────────────
Total: 40,271 tokens (80.5% of budget) — ⚠️ NEAR LIMIT

Insight: Loading learning-log-archive.md alone costs 7.6% of the full window. SESSION-BRIEF (0.8%) gives you 90% of the value at 10% of the cost. That's why tiered loading works.

Commands

Command What it does
scan PATH Recursively lists all files sorted by token count
check FILE1 FILE2... Sums up token costs for specific files
tier PATH Reads CLAUDE.md, maps files to their loading tier

Options

Flag Default Description
--budget N 50000 Token budget to compare against
--format json text Output as JSON for scripting

Use Cases

  • Before a session: Run scan to identify which files are most expensive
  • Planning a CLAUDE.md: Use check to validate that your Tier 1 files stay under budget
  • Debugging slow sessions: Find which files are causing context bloat
  • Tiered loading audits: Use tier to confirm your loading strategy is cost-efficient

Built by

Harel Asaf · 2026-05-26

Metadata

Release files for context-budget 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for context-budget 0.1.0
File Size Uploaded Provenance Actions
context_budget-0.1.0.tar.gz 7.0 kB With provenance Details for context_budget-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for context-budget 0.1.0
File Interpreter ABI Platform Actions
context_budget-0.1.0-py3-none-any.whl Python 3 none any Details for context_budget-0.1.0-py3-none-any.whl

Total release size: 14.4 kB

Release files / context_budget-0.1.0.tar.gz

Download URL context_budget-0.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bd70dfa7e0f291ddb37fcf84e6c7a109ed77d7ef3312c252cb201ef18ad05a73
BLAKE2b-256 checksum
How to use checksums
17f4018ca0df17bc6f87c2c90607fd5418c0257f6eb14584e4639eaf336f5d19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.

Transparency log

Release files / context_budget-0.1.0-py3-none-any.whl

Download URL context_budget-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa20326e16d82cc941e3fa3cf77232bee6547c8df32b78120bf57cd627fdcdda
BLAKE2b-256 checksum
How to use checksums
96ad54cd2ab536f06a9ac08d93ccb1a6dde5c283e16e05481ce50a7558c0f80d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.

Transparency log

Security for context-budget 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for context_budget-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page