Skip to main content

Get 5x more from your Claude Code token budget — audit, trim, and switch context profiles per project.

Project description

claude-lean

Get 5× more from your Claude Code token budget.

Audit, trim, and switch context profiles per project — without touching Claude Code itself.

Python License Status


Why

By default, Claude Code loads every enabled plugin's metadata into your context on every turn. For a fresh install with the default plugin set, that's often 500,000+ tokens of agent descriptions, skill metadata, and MCP preambles — regardless of whether you ever invoke them.

The result: shorter conversations before compaction, slower responses, higher cost, and a tax on multi-agent workflows. claude-lean makes that hidden cost visible — and gives you four levers to reclaim it.

The Four Levers

┌──────────────────────────────────────────────────────────────────┐
│                                                                   │
│   1. AUDIT     →   See exactly what's eating your context        │
│   2. APPLY     →   Disable what you don't use (with backup)      │
│   3. PROFILE   →   Different active set per project / cwd        │
│   4. RESTORE   →   One command back to any previous state         │
│                                                                   │
└──────────────────────────────────────────────────────────────────┘

Quick Start

# Install (zero hard dependencies beyond rich, which most setups have)
pipx install claude-lean

# 1. See what's costing you
claude-lean audit

# 2. Apply recommendations interactively (with diff + backup + dry-run safety)
claude-lean apply

# 3. Switch to a focused profile in a specific project
cd ~/my-python-project
claude-lean profile use python-ml

# 4. Undo anything
claude-lean restore --latest

Real Numbers From a Real Setup

A representative audit on a default-everything install:

─────────────────────────  claude-lean audit  ─────────────────────────

  Plugins enabled: 20  ·  Skills: 262  ·  Agents: 18
  Estimated system-prompt overhead per turn: 593,122 tokens

  Top contributors (tokens / turn):
    engineering-advanced-skills   129,302   ✓ keep
    engineering-skills            123,232   ✓ keep
    marketing-skills              111,126   ⚠ disable (no marketing work)
    c-level-skills                 68,660   ⚠ disable (no exec work)
    ra-qm-skills                   44,325   ⚠ disable (no regulatory work)

  17 findings · Estimated savings if applied: 298,283 tokens / turn
                                              ≈ 2.0× more headroom

With per-project profiles (level 3 above), that 2.0× compounds to 5×+ by loading only the plugins relevant to that project's stack.

How It Works

claude-lean is a standalone Python CLI, not a Claude Code plugin. It runs outside Claude Code and operates on the plain files in ~/.claude/. Because it never loads into your prompt context, it costs zero tokens per Claude conversation.

                ┌─────────────────────────────────┐
                │         claude-lean CLI          │
                │     (runs in your terminal)     │
                └────────────────┬────────────────┘
                                 │ reads / writes
                                 ▼
                ┌─────────────────────────────────┐
                │           ~/.claude/             │
                │  • CLAUDE.md                    │
                │  • settings.json                │
                │  • plugins/cache/               │
                │  • projects/*/memory/           │
                └─────────────────────────────────┘

See docs/how-it-works.md for the full architecture.

Safety

  • Every write creates a backup first to ~/.claude/.claude-lean-backups/{timestamp}/
  • Dry-run is the default for non-TTY usage — pipes don't accidentally mutate state
  • claude-lean restore --latest reverts the most recent change in one command
  • --list shows every snapshot you've ever made

See docs/safety.md for the full safety model.

Documentation

Doc Purpose
Getting Started First-time setup, install, the audit→apply loop
How It Works Architecture, the four subsystems, data flow
Safety Backup, restore, dry-run, what we never touch
FAQ Common questions, troubleshooting, limitations

Commands

Command What it does
claude-lean audit Scan ~/.claude/, report opportunities (read-only)
claude-lean audit --json Machine-readable output
claude-lean apply Interactive wizard, applies recommendations with diff + backup
claude-lean apply --dry-run Show what would change without writing
claude-lean apply --yes Skip interactive prompt (still respects --dry-run)
claude-lean profile list Show installed profiles
claude-lean profile show <name> Print a profile's contents
claude-lean profile use <name> Apply a profile (with backup + diff)
claude-lean restore --latest Revert the most recent change
claude-lean restore --list List all snapshots

Status

v0.1.0 — alpha. The core (audit, apply, restore, profile) is working and tested. The following are roadmapped for later versions:

  • v0.3claude-lean monitor (live token-usage dashboard from session logs)
  • v0.4 — Claude Code hooks integration (auto-switch profile on cd)
  • v1.0 — Profile marketplace + community-contributed profiles

License

MIT — see LICENSE.

Contributing

Issues and PRs welcome. Per-project profiles are intentionally easy to contribute — drop a TOML file in src/claude_lean/profile/stock/, add a test, ship a PR.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_lean-0.1.0.tar.gz (47.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_lean-0.1.0-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file claude_lean-0.1.0.tar.gz.

File metadata

  • Download URL: claude_lean-0.1.0.tar.gz
  • Upload date:
  • Size: 47.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for claude_lean-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5ab8afd4dd013de6710615aa4bd2d1f4b4a3000251354c1f233f7dde190608c0
MD5 03bfd637354602bc6e7238cd448d2ead
BLAKE2b-256 2ecbbc74d8bf51329f1201629cc76aaed502c4b8d8f9b84b7d1f4a1cbcdad68e

See more details on using hashes here.

File details

Details for the file claude_lean-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: claude_lean-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for claude_lean-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f598616e8f3aa0d171724e166fd9a60c4a8efbefdfc33b5ff508867eeb17966
MD5 b70758330d995229c9541754eac6f9e0
BLAKE2b-256 7a1d1d21f0dc152fc8341b578df70865d3911517e9096fdc3018631894dd4504

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page