Lighten · for Claude Code

Use fewer tokens in Claude Code

Every reply re-reads the whole conversation, so long sessions get expensive and burn through your usage limits. Lighten keeps them light: earlier guided compaction, memory across sessions and shorter noisy output. Free, and everything runs on your machine.

Install
$ uv tool install lighten$ lighten install

v0.3.1 · Claude Code 2.1.121+ · Python 3.10+ · Linux and macOS

Lighten

Compact. Remember. Trim.

Auto-compaction at 200k tokens, with guidance on what to keep

Memory note after compaction, /clear or a new session

Noisy test, install and build output shortened before Claude sees it

Errors, warnings and file views never touched

lighten audit: before vs with Lighten, from your own history

The problem

Why long Claude Code sessions get expensive

Claude has no memory between replies. To answer, it re-reads the whole conversation: every message, every file it opened, every line of test output. A reply in a 400k-token conversation costs about twice as much as one at 200k.

Claude Code's auto-compaction waits until the conversation is close to the model's limit, which can be near a million tokens. Until then, every reply carries everything. In our own sessions, more than 80% of the cost came from replies where the conversation was already over 200k tokens.

Features

What Lighten does

Four changes that keep the conversation small without losing the thread.

01

Compacts earlier, and better

Sets Claude Code's autoCompactWindow to 200k tokens instead of near 1M, and tells the summary what to keep: your goal, decisions, changed files, unresolved errors and next steps.

02

Remembers across sessions

Keeps a small local log of requests, changed files and failing commands. After a compaction, /clear or a new session in the same project, Claude gets a short note so you don't lose your place.

03

Shortens noisy output

Passing-test lists and install or build progress are removed before Claude sees them. Errors, warnings and anything unrecognised are always kept, and the full output is saved locally.

04

Shows you the numbers

lighten audit reads your local Claude Code history and compares sessions before and with Lighten: tokens per message, cost per message, time per message and plan-limit snapshots.

How It Works

Claude Code hooks, run locally

lighten install adds these hooks to ~/.claude/settings.json and sets autoCompactWindow to 200,000. Each hook is a local Python call of about 100 ms. If anything goes wrong, the hook exits quietly and Claude Code carries on unchanged.

PostToolUse
Shortens noisy Bash output through updatedToolOutput, before it enters the context window.
PreCompact
Adds guidance to the compaction prompt: keep the goal, decisions, changed files, open errors and next steps.
PostCompact
Saves the compaction summary locally.
SessionStart
After a compaction, /clear or a fresh start in the same project, hands Claude a short note (up to about 1k tokens).
UserPromptSubmit
Logs your request to the local session log. Adds nothing to the context.
PostToolUseFailure
Logs failing commands so they show up in the memory note.

Results

Measured, not guessed

Live A/B test on a Claude subscription: the same long session (16 messages, 48 replies) with and without Lighten.

79%

fewer tokens in a long session (16.7M → 3.6M)

~25%

less of the 5-hour plan limit for the same work

11/11

tasks completed, the same as without Lighten

One test, so treat these as an example rather than a promise. The same facts were recalled in both runs. Short sessions that never reach 200k tokens see little change. Measure your own sessions with:

Audit
$ lighten audit

Install

Set up in two minutes

You need Claude Code 2.1.121 or newer and uv (or pipx). uv fetches Python 3.10+ if needed.

  1. 1

    Install the CLI

    Run uv tool install lighten (or pipx install lighten).

  2. 2

    Add the hooks to Claude Code

    Run lighten install. It backs up ~/.claude/settings.json and adds Lighten's hooks without removing your own settings.

  3. 3

    Check the install

    Run lighten status. It should report "Hook self-test: OK".

  4. 4

    Restart Claude Code

    Restart Claude Code or start a new session so the hooks load.

Install
$ uv tool install lighten   # or: pipx install lighten$ lighten install$ lighten status   # Hook self-test: OK
Options
$ lighten install --compact-window 300000   # 150k – 1M$ lighten install --no-compact-window$ LIGHTEN_DISABLED=1 claude   # one session without Lighten
Uninstall
$ lighten uninstall --purge$ uv tool uninstall lighten

lighten install backs up your settings first, keeps your own hooks and leaves an autoCompactWindow you set yourself alone. Get uv from docs.astral.sh/uv.

Local only. Nothing uploaded.

Lighten has no server. Everything lives in ~/.lighten on your machine:

  • Per-project session logs: your requests, changed file paths and commands
  • The last compaction summary for each project
  • Full copies of shortened output, deleted after 7 days
  • Plan-limit snapshots (percentages and times)

Known limits

  • Failing commands are not shortened. Claude Code does not let hooks rewrite the output of a command that failed.
  • File views (cat, sed, head, git diff and similar) are never touched. If you mostly read code, the savings come from compaction and memory.
  • Earlier compaction is a trade-off: each one costs a summary call and can lose detail. The window can't go below 150,000 tokens.
  • Token savings are larger than plan-limit savings, because your plan counts cached re-reads as much cheaper than new work.
  • Tested on Linux. macOS should work; Windows is untested.

FAQs

Frequently asked questions

How do I reduce token usage in Claude Code?

Keep conversations short. Every reply re-reads the whole conversation, so cost grows with conversation length. Compact earlier, use /clear between unrelated tasks, and keep noisy command output out of the context. Lighten automates this: it starts compaction at 200k tokens with guidance on what to keep, hands Claude a short memory note after a compaction or /clear, and shortens noisy output before Claude sees it.

What is context engineering?

Context engineering is deciding what goes into a language model's context window, and what stays out, so the model has what it needs for the task without wasted tokens. For coding agents like Claude Code that means managing conversation length, compaction, memory between sessions and the size of tool output.

Why does Claude Code use so many tokens in long sessions?

Claude re-reads the entire conversation on every reply, including earlier tool output. A session at 400k tokens costs roughly twice as much per reply as one at 200k. In the author's own sessions, more than 80% of cost came from replies where the conversation was over 200k tokens.

How much does Lighten save?

In one long-session A/B test (16 messages, 48 replies) Lighten used 79% fewer tokens and about 25% less of the 5-hour plan limit, with the same tasks completed and the same facts recalled. Short sessions that never reach 200k tokens see little change. Run lighten audit to measure your own sessions.

Does Lighten send my code or prompts anywhere?

No. Everything runs on your machine and is stored in ~/.lighten. Nothing is uploaded. lighten audit --share writes a report you can choose to send, and it contains numbers only: no code, file paths, prompts or commands.

Will Claude lose context or make more mistakes?

Lighten never blanks new tool results. It only removes known noise such as passing-test lists and progress lines, keeps errors and warnings, and saves the full output on disk so Claude can read it again. Compaction is guided to keep goals, decisions, changed files and open errors.

Is Lighten free? Is it open source?

Lighten is free to install and use. It is not open source: you may not copy, modify, redistribute or resell it.

How do I uninstall Lighten?

Run lighten uninstall to remove the hooks and restore your compaction setting, add --purge to delete ~/.lighten, then run uv tool uninstall lighten.

Is Lighten made by Anthropic?

No. Lighten is an independent project by Shryxa and is not affiliated with or endorsed by Anthropic.

Keep your next long session light

Two commands, free, and nothing leaves your machine.

Install
$ uv tool install lighten$ lighten install
View on PyPI

Lighten is an independent project and is not affiliated with or endorsed by Anthropic. "Claude" and "Claude Code" are trademarks of Anthropic.

Read the guides: How to reduce Claude Code token usage and Context engineering for Claude Code.

See all Shryxa products or explore Shryxa's AI and software engineering services.