Claude Code context window budget calculator — know your token cost before you load
Project description
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
scanto identify which files are most expensive - Planning a CLAUDE.md: Use
checkto validate that your Tier 1 files stay under budget - Debugging slow sessions: Find which files are causing context bloat
- Tiered loading audits: Use
tierto confirm your loading strategy is cost-efficient
Built by
Harel Asaf · 2026-05-26
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file context_budget-0.1.0.tar.gz.
File metadata
- Download URL: context_budget-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd70dfa7e0f291ddb37fcf84e6c7a109ed77d7ef3312c252cb201ef18ad05a73
|
|
| MD5 |
05b5d6f11d7b75656320cd741de2f299
|
|
| BLAKE2b-256 |
17f4018ca0df17bc6f87c2c90607fd5418c0257f6eb14584e4639eaf336f5d19
|
Provenance
The following attestation bundles were made for context_budget-0.1.0.tar.gz:
Publisher:
publish.yml on RLASAF12/context-budget
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
context_budget-0.1.0.tar.gz -
Subject digest:
bd70dfa7e0f291ddb37fcf84e6c7a109ed77d7ef3312c252cb201ef18ad05a73 - Sigstore transparency entry: 1723280592
- Sigstore integration time:
-
Permalink:
RLASAF12/context-budget@1916ca3362cf51b54607fc1fafd93348eb7d65cf -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RLASAF12
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1916ca3362cf51b54607fc1fafd93348eb7d65cf -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file context_budget-0.1.0-py3-none-any.whl.
File metadata
- Download URL: context_budget-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa20326e16d82cc941e3fa3cf77232bee6547c8df32b78120bf57cd627fdcdda
|
|
| MD5 |
d13af5416c7fdd99e6a5da800c059c23
|
|
| BLAKE2b-256 |
96ad54cd2ab536f06a9ac08d93ccb1a6dde5c283e16e05481ce50a7558c0f80d
|
Provenance
The following attestation bundles were made for context_budget-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on RLASAF12/context-budget
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
context_budget-0.1.0-py3-none-any.whl -
Subject digest:
aa20326e16d82cc941e3fa3cf77232bee6547c8df32b78120bf57cd627fdcdda - Sigstore transparency entry: 1723280682
- Sigstore integration time:
-
Permalink:
RLASAF12/context-budget@1916ca3362cf51b54607fc1fafd93348eb7d65cf -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RLASAF12
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1916ca3362cf51b54607fc1fafd93348eb7d65cf -
Trigger Event:
workflow_dispatch
-
Statement type: