Your AI agent is smart enough to code all day. Now it actually can. Stop letting bloated file reads, noisy test dumps, and broken prompt caches drain your limits by lunch. TokenSafe runs locally, filtering context down to what the model actually touches while keeping secrets out of git. Works with Cursor, Claude Code, Codex, Windsurf, Google Antigravity, Kimi Code, and ChatGPT.
Install • Quickstart • What's New in v4.0 • Why TokenSafe • Benchmarks • Pricing • FAQ • Reference • Website & Docs
TokenSafe 4.0 is a major architecture release designed for Zero Mid-Day Lockouts, 3-Second Turn Latency, Exact Code Context (Zero Loss), and Developer Flow:
Connect TokenSafe to the AI coding agents on your workstation in one command:
# Option 1: Zero-Install via npx (recommended) npx tokensafe # Option 2: Python / PyPI pip install tokensafe && tokensafe # Option 3: Direct shell script (macOS / Linux) curl -fsSL https://tokensafe.dev/install.sh | bash The installer detects which agents live on your machine, registers the TokenSafe MCP server, injects project rules, and wires lifecycle hooks where the agent supports them.
Claude Desktop / Cursor MCP config:
{ "mcpServers": { "tokensafe": { "command": "npx", "args": ["-y", "tokensafe", "mcp"] } } } Cloud features (team metrics, managed distillation, shared team cache, billing) run on the remote endpoint https://api.tokensafe.dev/mcp with Authorization: Bearer . Four public tools work without a key, so ChatGPT connects with authentication set to None.
Full per-agent configuration, hook details, and the Codex/ChatGPT setup live in docs/AGENT_SETUP.md.
# View live savings dashboard in your terminal tokensafe stats ⚡ TOKENSAFE CONTEXT OPTIMIZER DASHBOARD Total Tokens Saved: 4,524,156 tokens Efficiency Gain: [████████████████████████░░] 92.5% Context Traffic: 4,889,255 raw → 370,574 optimized (2,132 events) • Command Sanitizer (CLI) : 727,300 tokens saved (263 events) • Architecture Graph : 758,256 tokens saved (13 events) • Multi-turn History Fold : 2,897,897 tokens saved (471 events) • Prompt Compactor (local+cache) : 43,502 tokens saved (1,255 events) # Audit your environment: MCP tool overhead, skills tax, risky settings tokensafe doctor # Recursive security & hygiene audit of a repository tokensafe guard audit # Preview prompt compaction on custom input tokensafe test "fix the validate_token method in src/auth.py to check jwt expiration" # Map architectural hotspots before multi-file changes tokensafe graph # Disable a heavy MCP server without editing JSON tokensafe mcp disable # Compile and preview the Friday team ROI digest tokensafe digest # Activate a Team or Solo license key tokensafe activate TS2.eyJlbWFpbCI6... The full command reference (24 commands) is in Reference.
Giving coding agents raw access to entire repositories creates three daily costs:
A $29 seat pays for itself by saving one hour of senior code review or preventing one leaked key. Typical payback: 1 to 3 days of team usage.
One contrast: an agent asked to change one helper in a 1,420-line file receives 94 lines of target logic and type contracts instead of the whole module. The same principle applies to terminal output, diffs, and session history.
When an operation is blocked, the agent sees an explicit, constructive message:
🛡️ TokenSafe Guard: Blocked a hardcoded secret fallback in config.py. Leave the default empty or read from os.environ at runtime. 10 Core Engine Capabilities Why TokenSafe agents ship working code on the first pass without burning quotas or leaking keys:
Deeper mechanics (language matrix, AST syntax trees, cache tiers, governor) live in docs/ARCHITECTURE.md.
Reference run across 10 production engineering scenarios (169,761 baseline tokens down to 8,173 tokens, -95.2% net context reduction, -99.4% peak single-scenario reduction, +30.6% turn latency speedup with 100% accuracy retention):
Prompt compaction, graph topology (SWE-06), dep_mode="signature" slicing (SWE-07), repeat-read pointer dedup (SWE-09), and parametric slot cache hits (SWE-10) are measured live (1,368 optimized tokens) while baselines (169,761), turn counts, and output estimates (6,805 tokens) are modeled constants. See METRICS.md and BENCHMARK_REPORT.md.
TokenSafe combines two multiplicative savings layers rather than relying on AST compression alone:
Honest bounds: When ~85–95% fewer context tokens combine with a 90%+ KV-cache hit rate billed at 0.10x, cached input spend approaches 1–2% of uncached cost (up to ~99% savings) on graph-first, repeat-read, and cache-warm workflows. Total session invoices typically fall 80–97% because newly generated output tokens and first-turn cache writes are never discounted by KV-caching.
How to read these numbers: this benchmark is a simulated harness. Compression ratios and 20-turn KV-prefix byte matches are computed live from real files, while baselines and turn speedups are modeled. Production events in TokenSafe are explicitly labeled measured or estimated (see METRICS.md).
No modeling: fifteen popular repositories across 10 languages (Python, TypeScript, JavaScript, Go, Rust, Java, Ruby, PHP, C#, Swift, C) cloned at HEAD, scenarios pre-registered before measurement (src/bench_scenarios.json), every token counted on real bytes, and deterministic zero-loss gates that disqualify any scenario they fail. Curated rows (all rows in docs/BENCHMARK_REAL.md):
Aggregate: ~25.7M measured tokens saved per traced pass over all 15 repositories in 10 languages (142 gated-OK rows; input at $3/M, output axis at $15/M, KV-cache hits billed at $0.30/M). Clean pytest suites honestly score ~0-3% — savings are never invented. 17 gate-FAILs and 21 skips are published with reasons on the live page (e.g. fastapi's test-output: strict warning filters escalate a pytest-asyncio deprecation into a pytest INTERNALERROR; whole-repo API surfaces bigger than hub crawls for fastapi/httpie; httpie's core.py refuses skeletonization — one function is most of the file). Full table + raw JSON: docs/BENCHMARK_REAL.md · live page: https://tokensafe.dev/bench · methodology post: https://tokensafe.dev/blog/real-repo-benchmark-5-repos. Reproduce:
tokensafe bench --real # all 15 pre-registered repos tokensafe bench --real --repo=pallets/flask # one repo tokensafe bench --real --here # your current repository Head-to-Head Competitor Benchmark (Measured on Real Repositories) We cloned 8 popular open-source repositories across Python, Go, C, and Java, and tested JayPokale/Chisle, alexgreensh/token-optimizer, and TokenSafe (v4.1.2) on the exact same hub files and target functions. Every token was counted with a calibrated BPE tokenizer on real bytes.
Deterministic zero-loss gates disqualify any output where the code fails to compile/parse, or where the targeted function is missing. Savings without code correctness are just destructive truncation.
When running benchmarks on large repositories, developers often ask: Why does token-optimizer show 317 tokens on Flask while TokenSafe shows 3,784 tokens?
The answer lies in what each tool actually passes to the model:
TokenSafe labels every savings event as one of:
Totals always display the split (X metered · Y est.). When a live metric is missing, the UI shows — rather than a placeholder number. USD figures are derived approximations (tokens × $1.5 / 1M), not provider invoices. Full contract: METRICS.md.
TokenSafe follows an open-core model: verify local context savings and guardrails on your own repo first, then roll out team caching, org policies, and per-seat ROI.
Working solo? Individual Solo plans start at $9 / mo ($89 / yr).
7-Day Free Trial · Offline Ed25519 Seat Keys (TS2.*) · Zero Source Code Transmitted · Cancel anytime
Start a 7-Day Team Trial Run Free Locally
Does my source code leave my machine? No. Slicing, guarding, compaction, and metrics run locally. The cloud receives only counters (token totals and event types), never file contents or prompts. Set TOKENSAFE_TELEMETRY_DISABLED=1 to disable all telemetry sync; local features keep working.
How does offline license verification work? License keys are TS2.* tokens signed with Ed25519. Your client verifies the signature offline against an embedded public key and caches the result for up to an hour. Enforcement never requires a network round trip.
What do measured and estimated mean? measured means the model literally received fewer bytes than the tool produced. estimated means savings are counted against a reasonable modeled baseline. The dashboard always shows the split and never invents numbers for missing data.
What exactly does the $29/seat plan include? Unlimited compaction and managed cloud distillation (zero API keys for developers), the shared L3 monorepo cache, org-wide guard policies, the Friday per-seat ROI digest, and centralized seat provisioning and revocation. Billed annually it is $290/seat/year (~$24/seat/mo).
Can we self-host? The Enterprise & VPC plan covers a private VPC Docker proxy with BYOK provider keys, zero-telemetry / air-gapped mode, and SAML/OIDC SSO, deployed together with the TokenSafe engineering team: corp@tokensafe.dev.
What happens if a hook fails? All hook adapters fail open: an internal error never stalls your agent. Failures are logged locally so they can be reported and fixed, not silently swallowed.
Endpoint: https://api.tokensafe.dev/mcp, auth Authorization: Bearer .
tokensafe stats / markdown / html Savings analytics (terminal / .md report / dashboard) tokensafe search [--path ] Fast SQLite FTS5 BM25 code search ( Restore folded tool/command/file result by its 8-char hash tokensafe optimize-image Downscale image >1024px via Pillow or macOS sips tokensafe prune-superseded Prune obsolete intermediate tool reads from transcript tokensafe mistakes [list|record|clear] Anti-stuck dead-ends ledger & prompt guard tokensafe web Fetch web page/docs and print clean compact Markdown tokensafe wrap Run command with compact output folding & ANSI stripping tokensafe doctor [--cleanup] Audit MCP tool overhead, ghost tokens & conflicts tokensafe benchmark Zero-context-loss benchmark suite (simulated harness) tokensafe bench --real Measured benchmark on real repos (zero-loss gates) tokensafe graph / map / skeleton Architecture graph / API surface / AST skeleton of a file tokensafe test " " Preview prompt compaction on custom input tokensafe guard " " Pre-flight safety check for a shell command tokensafe guard audit [path] Recursive source audit for secrets & vulnerabilities tokensafe digest [--send] Compile (and optionally dispatch) the weekly team digest tokensafe mcp list|disable|enable Manage configured MCP servers tokensafe proxy [port] Local transparent AI proxy (127.0.0.1:8765/v1) tokensafe proxy on/off/status Daemon + agent wiring with one-command rollback tokensafe install / setup [--all] Configure detected agent environments tokensafe update / check-update Self-update / check for a newer version tokensafe activate Activate a Team or Solo license key tokensafe login / logout Authorize or unlink this device via browser tokensafe license Show active tier and trial state tokensafe providers List distillation providers and active mode tokensafe sync Sync local telemetry with the cloud dashboard tokensafe prune [--days N] Compact metrics database (roll old events) tokensafe vacuum Reclaim SQLite disk space tokensafe tests [pytest] Run the unit test suite (compact failure report) tokensafe reset Reset all local token metrics tokensafe --version Print version and exit Proxy mode & agent coverage (v3.0.0) One command wires everything it safely can:
tokensafe proxy on # installs a keep-alive daemon (launchd/systemd), wires Claude Code, prints manual steps for the rest tokensafe proxy status # health, wiring state, last traffic tokensafe proxy off # rollback: unwires agents (previous base URL restored) and removes the daemon The daemon keeps the proxy alive on 127.0.0.1:8765, on rewires agents only after a verified /health answer (a dead proxy never bricks an agent), and every wiring is backed up for off. tokensafe install and tokensafe update ask interactively whether to enable the proxy (skipped in non-TTY/scripted runs); prefer manual? Run tokensafe proxy in a terminal and point your agent's base URL at http://127.0.0.1:8765 yourself:
More documentation: docs/AGENT_SETUP.md · docs/ARCHITECTURE.md · docs/API.md · METRICS.md · BENCHMARK_REPORT.md
The client runs on Python 3.10+ with cryptography>=42.0 as its sole runtime dependency for Ed25519 license checks; all AST slicing, SQLite metrics, MCP tooling, and guardrails run on the standard library (details).
# Run the unit test suite (compact failure report; full: --traceback / -v) tokensafe tests Contributing: CONTRIBUTING.md Security policy and vulnerability reporting: SECURITY.md Metrics and honesty contract: METRICS.md MIT License. Commercial licenses are available for self-hosted B2B and enterprise VPC deployments. Questions: corp@tokensafe.dev · tokensafe.dev
ai llm tokens token-optimization context-window cursor claude antigravity codex mcp mcp-server ast proxy jwt ed25519 zero-trust
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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.
None of the files in this release were uploaded with provenance metadata.
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.
Nov 24, 2026 2 release files No provenance
Nov 23, 2026 2 release files No provenance
Nov 22, 2026 2 release files No provenance
Nov 21, 2026 2 release files No provenance
Nov 20, 2026 2 release files No provenance
Nov 19, 2026 2 release files No provenance
Nov 18, 2026 2 release files No provenance
Nov 17, 2026 2 release files No provenance
Nov 16, 2026 2 release files No provenance
Nov 15, 2026 2 release files No provenance
Nov 14, 2026 2 release files No provenance
Nov 13, 2026 2 release files No provenance
Nov 12, 2026 2 release files No provenance
Nov 11, 2026 2 release files No provenance
Nov 10, 2026 2 release files No provenance
Yanked reason: Bump-only accidental release; never existed in git/npm history (1.8.0 → 2.0.0).
Nov 9, 2026 2 release files No provenance
Nov 8, 2026 2 release files No provenance




