Rolling Context for Claude Code

A transparent proxy that gives Claude Code rolling context compression — old messages get automatically summarized while recent messages stay fully verbatim. You never hit the context wall, and you never lose important details.
Zero config. Uses your existing Claude Code auth. No API key needed. Just install and forget.
Claude Code's built-in /compact replaces your entire conversation with a lossy summary. After a few compactions, you're summarizing a summary of a summary. This plugin only compresses old messages — recent context stays untouched.
/compact vs Rolling Context
| /compact (built-in) | Rolling Context |
|---|
| What gets compressed | Everything | Only old messages |
| Recent context | Summarized (lossy) | Kept verbatim |
| When it runs | Manual or at threshold | Automatic, background |
| Latency impact | Blocks until done | Zero — async |
| After multiple compressions | Summary of summary of summary | Fresh rolling merge each time |
| Original transcript | Replaced | Preserved (JSONL unchanged) |
How It Works
Claude Code ──► Rolling Context Proxy (:5588) ──► Anthropic API
│
├─ context < 100K tokens? pass through unchanged
│
└─ context > 100K tokens?
1. summarize old messages with Haiku (background, async)
2. keep ~40K tokens of recent messages verbatim
3. inject compressed context on next request
4. never blocks, never adds latency
Instead of replacing everything, this plugin:
- Keeps recent messages untouched — recent context stays verbatim
- Only compresses when needed — triggers at 100K (real API token count), compresses old messages, grows naturally until next trigger
- Merges summaries — each compression cycle merges with the previous summary, building a rolling timeline
- Never blocks — compression runs in the background, applied on the next request
- Full transcripts preserved — Claude Code still saves everything to JSONL in
~/.claude/projects/
Install
Option 1: Claude Code Plugin (recommended)
Run these two commands inside Claude Code:
/plugin marketplace add https://github.com/NodeNestor/nestor-plugins
/plugin install rolling-context
Restart your terminal and start a new Claude Code session. On the first start, the plugin configures ANTHROPIC_BASE_URL and starts the proxy. Since the env var only takes effect on the next terminal, restart your terminal once more — after that, everything works automatically. No pip install needed — pure Python stdlib.
Option 2: Manual install
Linux / macOS:
git clone https://github.com/NodeNestor/claude-rolling-context.git ~/claude-rolling-context
cd ~/claude-rolling-context
bash install.sh
Windows (PowerShell):
git clone https://github.com/NodeNestor/claude-rolling-context.git $HOME\claude-rolling-context
cd $HOME\claude-rolling-context
powershell -ExecutionPolicy Bypass -File install.ps1
The installer configures ANTHROPIC_BASE_URL and registers the plugin. Restart your terminal and you're done. Requires Python 3.7+ (no pip install needed — pure stdlib).
How Compression Works
When the message array exceeds the trigger threshold:
BEFORE (hit 100K trigger):
[msg1] [msg2] [msg3] ... [msg60] [msg61] ... [msg100]
|<——————————————— ~105K tokens ——————————————>|
AFTER (compressed):
[rolling summary] [ack] [msg61] ... [msg100]
|<— ~5K summary —>| |<—— verbatim ————————>|
NEXT CYCLE (grows back to 100K, triggers again):
[rolling summary] [ack] [msg61] ... [msg140]
|<——————————————— ~105K tokens ——————————————>|
→ new summary merges old summary + msg61-msg100
→ keeps msg101-msg140 verbatim
The summary preserves a structured record of everything that happened:
- Active Goal — what the user is currently asking for, constraints, do/don't rules
- Previous Goals — completed or shifted-away-from goals (kept brief)
- Timeline — chronological numbered steps: every file change, decision, error, and user instruction
- Current State — what's done, in progress, and next
- Key Details — file paths, configs, decisions that must survive compression
Goals evolve naturally across rolling compressions — the latest request stays prominent while completed goals move to the previous section. User instructions are never lost.
Architecture
The proxy is fully stateless — no sessions, no databases, no tracking. It works by hashing message content: