| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Tip
No Anthropic subscription? See Using Without an Anthropic Subscription below.
npm install -g claude-code-infinitecccThis will guide you through setting up your PolyChat key which you can also get here.
The tool supports multiple environments (this selects the MemTree compression API only — Anthropic traffic always goes directly from your machine to api.anthropic.com):
Each environment maintains its own separate API key.
ccc runs a small proxy on 127.0.0.1 and launches Claude Code with only ANTHROPIC_BASE_URL pointed at it. Claude Code keeps its native login — token refresh, plan-default model selection, and rate-limit handling behave exactly like vanilla Claude Code, and your OAuth token is sent only to api.anthropic.com from your own machine.
Claude Code ──▶ localhost proxy (ccc)
├──(messages only, MemTree API key)──▶ api.polychat.co /v1/context_memory
│◀──(compressed messages)─────────────┘
├──(memory leg A + your local OAuth)──▶ api.anthropic.com
├──(eligible turns: full-history leg B)▶ api.anthropic.com
└──(eligible turns: local A/B grader)──▶ api.anthropic.com
In interactive sessions, ccc reports these MemTree states as display-only lines in Claude Code:
ccc installs a minimal session-only Claude Code plugin using the repeatable --plugin-dir option. Its MessageDisplay hook changes only what the terminal renders and never alters stored assistant content; a Stop hook supplies a fallback for tool-only responses. That fallback may be saved by Claude Code as non-model hook UI metadata, but it is excluded from resumed model and recap requests. Notices are never added to Anthropic responses or model context, and -p/non-TTY output is left unchanged. Legacy marker cleanup remains for transcripts created by older ccc releases. The payment state can also produce a separate terminal warning at startup.
Claude Code currently displays the original assistant text instead of MessageDisplay replacements while verbose mode is enabled. Turn verbose mode off to see the inline MemTree line.
|
When you send a message, we retrieve relevant details and summaries from the prior messages in your thread. These details and summaries populate a memory message. Following the memory message, we append a compressed version of your recent message history. The resulting context-window is dramatically smaller, allowing Claude to process your request with much greater efficacy, lower latency, and reduced cost.
ccc now checks whether memory is still the best context for each large follow-up turn:
Comparison is deliberately fail-safe: grader failure or timeout keeps memory; in speculative mode, a failed grader gets one off-path retry. A memory arm that dies mid-stream is recovered from the healthy full-history arm when doing so is transcript-safe, and client cancellation aborts both arms and the grader. A route and success notice are installed only after a complete successful response. In speculative mode, once the memory answer has finished — or has started a tool call — a late B verdict is recorded for research but never applied.
Qualifying turns cost more: they make two answer requests plus one grader attempt on the user's Anthropic subscription or API account. Speculative mode may make a second grader attempt after a retryable failure, for up to four Anthropic requests on that comparison turn. The gate avoids that overhead for compact contexts, and the losing answer is aborted right after grading.
Advanced/testing controls:
Buffered, grade-before-delivery A/B routing is the default.
ccc --ab-speculative opts into commit-A-immediately delivery with SSE splicing; ccc --ab-buffered explicitly selects the default buffered mode. If both flags are supplied before --, the last one wins. The transcript-safety question behind speculative mode — whether Anthropic accepts a spliced assistant message replayed as history — was validated by the S1 replay spike (scripts/spike-s1.mjs) against real Anthropic with Claude Code's own headers, including the tool-use splice shape.
CCC_AB_ROUTING=0 disables live A/B routing.
CCC_AB_FORCE_VERDICT=A|B|tie replaces the grader with an instant fixed verdict (no grader request). Staging-only: B forces the mid-stream splice/correction path so its UX can be eyeballed; combine with CCC_AB_FORCE_COMPARISON=1 to also bypass the context-size gate.
CCC_AB_GRADER_MODEL=<model> pins a fixed grader model; by default, each comparison automatically uses a grader from a different model family than its answer legs.
CCC_AB_PREFIX_TOKENS=<n> changes the answer prefix from its 1,000-token default.
CCC_AB_GRADER_MEMORY_TOKENS=<n> changes the cap on the memory section of the grader prompt from its 10,000-token default. Oversized memory is excerpted head+tail with an explicit elision marker; Answer A itself always sees the full memory.
CCC_AB_PREFIX_TIMEOUT_MS=<ms> and CCC_AB_GRADER_TIMEOUT_MS=<ms> change their 30-second defaults.
CCC_AB_SAMPLE_NO_PRIOR=0 skips comparison for models without an effective-context prior.
CCC_AB_FORCE_COMPARISON=1 bypasses the size gate for diagnostics.
Routing decisions, both-leg timings and usage, grader diagnostics, fallbacks, and delivery status are recorded in ~/.claude-code-infinite/logs/requests.jsonl.
This is not a MPC or tool for simply retrieving memories. While we are compatible with all MPC's, tools, and other Anthropic features, these do not prevent your context window from becoming detrimentally large. MCP's and tools are some of the biggest token bloaters and it's exactly these types of messages that we heavily reduce during our compression phase.
LLMs get exponentially less intelligent as their input grows.
References:
Furthermore, the above research primarily tests on needle-in-a-haystack tasks, which underestimates the effect for more difficult tasks encountered in coding.
This is why starting sessions from scratch provides such a significant uplift in ability. What we're essentially doing is keeping each session as close to from-scratch as possible by limiting the tokens in Claude's context window to around 30k, or 15% of the standard 200k context-limit, filled precisely with the information relevant to your last message. Read more about how MemTree works here.
It may seem strange that we are advocating for small context windows in a product called Claude Code Infinite. But Infinite is referring to the size of a new memory layer, the MemTree, which is a layer above the context window. This layer is larger and updated more slowly than the LLMs main input, just as disk is larger + slower than RAM.
So you can think of MemTree as an operating system's virtual memory manager. Just as an OS manages RAM by swapping less-used data to disk, MemTree manages the model's context window by intelligently recalling only the most relevant information from past interactions. This ensures that the model always has access to the most pertinent data without being overwhelmed by the entire history of the conversation.
If you want your session to apply to many different tasks, we recommend giving the overall high level goal you want for your session in the first message, e.g. "Refactor this project to remove code smells and bugs". Then followup with lower level tasks in subsequent messages. This as Anthropic models key heavily off the first message. You should also feel free to start new sessions for new tasks. This as the model will continue to have a focused context with your CLAUDE.md and first message always included. Reach out to support@polychat.co if you have any questions or concerns!
Add context to your status line to see how MemTree keeps your context small
/statusline add context % usedYou want your fresh session context to be 10k tokens or less. If your starting context is more than that, consider reducing the size of your custom MCP's and slash commands to ensure Claude performs at its very best
You can resume previous threads with /resume
ccc never touches your Anthropic credentials — Claude Code manages its own login exactly as it does without ccc. If you see auth errors, fix them the vanilla way: run /login inside Claude Code (or claude directly) and re-authenticate.
If you see an inline "⚠ MemTree degraded — this turn ran uncompressed" notice, the compression API is unreachable or your MemTree key is invalid/expired. Your session keeps working uncompressed. Check your key at polychat.co, or delete it from ~/.claude-code-infinite/config.json and re-run ccc to re-enter it.
Claude Code works with an Anthropic API key as well as a subscription — set ANTHROPIC_API_KEY as you would with vanilla Claude Code and run ccc as usual. MemTree compression works the same either way (and saves the most money on API-key billing, since you pay per token).
Note
To use without an Anthropic subscription, choose option 2. "Anthropic Console account", during the Claude Code setup. (Running /logout will also bring you back to this setup.)
You don't need to buy API credits, just login and Claude Code will let you complete setup.
Lastly run /logout within Claude Code and then run ccc
Anthropic API usage will be billed through https://polychat.co.
If you hit your Anthropic subscription's rate limits, you can still continue by running /logout and restarting ccc. This will bill tokens through your PolyChat subscription. Remember that you can use the /resume slash command to resume previous sessions.
| Back | FazBrowse Home | New Git URL |