ctxtree

For Claude Code

Pick up old work without paying for all of it.

Claude Code keeps a session's cache for an hour on a Claude plan, or five minutes on an API key. Come back later, and the whole session is read in again. In a long session, that can be hundreds of thousands of tokens.

ctxtree starts a new session from a small, folded map of the old one instead. Every word of the old session is still there to open.

with Pythonpip install ctxtree
with Nodenpx ctxtree

Needs Python 3.8 or newer. Free and open source, Apache-2.0.

Type ctxtree in a project folder

It tells you what your last session there was doing, if its cache is still warm, and what each way back costs.

$ ctxtree
api: your last session here (3f9a1c02) was active Nov 30 14:02, 3 hours ago.
The task: "move the billing webhooks to the new queue"
Its cache has cooled. Going back to it re-caches its whole window: 612k tokens, about $4.90 at list price.
Starting fresh from the folded view instead: about 52k tokens, about $0.42 at list price, with every word still reachable.

  ctxtree resume   start a new session from the folded view
  ctxtree show     read the folded view yourself
  ctxtree level    see or change how much it holds (now auto)

A made-up project. Prices are list prices for current Claude models.

How it works

1

It folds the log.

ctxtree reads the session's log from your disk. It folds it into a tree: stretches of work, the turns in them, and one short line for each tool call.

2

The new session starts small.

ctxtree resume starts Claude Code with a short opening: a map of the work, and the task you were on, word for word.

3

It opens what it needs.

When the agent needs more, it searches and opens the old text. Nothing is summed up or thrown away. Each part opens to the exact words in the log.

Does it work?

We asked an agent 50 questions about earlier work in five real sessions, and graded the answers blind.

49 of 50

right, working from the folded view with search and open

32 of 50

right, going back to the old session itself

The folded way cost less than a sixth as much in total: $3.39 against $22.18 at list price. Going back to the session got all 20 right where nothing had been compacted, but only 12 of 30 where compaction had dropped older work.

It's a small test. Take it as a good sign, not as proof.

You pick how much it holds

It works like Claude Code's effort setting. The default, auto, holds the task you were on word for word and a map of the rest: about 8k to 24k tokens. More held means less to open later, but a bigger bill when a cache runs out.

  • low 2k
  • medium 8k
  • auto 8k to 24k
  • high 24k
  • xhigh 64k
  • max every turn

ctxtree level high saves one. A size such as 30k works too.

Commands

Each one works on the newest session in the folder you are in, unless you give a session id.

ctxtree
what your last session here was doing, and what each way back costs
ctxtree resume
start a new session from the folded view
ctxtree show
the map, then recent turns word for word
ctxtree search 'queue'
where a word appears, in what was said and in tool output
ctxtree open t21.3
one part in full: e3 a stretch of work, t21 a turn, t21.3 one tool call
ctxtree status --json
warm or cooled, and the costs, for other tools to read
ctxtree check --all
prove nothing is lost: every tool call opens to exactly what the log holds

What it touches

  • It reads Claude Code's logs in ~/.claude/projects. It sends nothing anywhere.
  • It writes three small things: the level you save, the opening for resume (only you can read it), and the sizes of fresh starts.
  • It never watches what you type.
  • It knows Claude Code's log format only. A sub-agent's own steps are left out; its result shows as the tool call that started it.