ctx-tree intercepts all Claude Code native tools and all MCP tool calls โ reads, searches, web fetches, commands, agent invocations, skills โ and routes them through a persistent SQLite property graph. Context shrinks 95โ99%. Knowledge accumulates across sessions.
Every tool call dumps raw file contents, grep output, and web pages straight into the context window. A session that reads 8 files, runs a few web fetches, and calls some MCP tools burns 60โ80k tokens on raw data โ leaving almost nothing for reasoning. The session stalls before the work is done.
ctx-tree intercepts every tool call via Claude Code hooks โ native and MCP. Content lands in a persistent SQLite property graph, chunked by symbol and indexed. Claude gets back a compact nodeId reference, not raw bytes. The same file read next week costs zero tokens โ it's already in the graph.
Sessions that previously stalled at 40k tokens now run to completion. Knowledge accumulates across sessions โ prior reads surface instantly via ctx_tree_compose. You can explore an entire codebase, debug a production incident, and ship a feature all in one session. Context rot disappears.
SQLite ยท FTS5 ยท Per-project ยท Content-hash deduplication ยท Click any node to explore
File content is semantically chunked (functions, classes, modules) into file_chunk nodes linked by next edges. Each chunk carries source_uri, content, size, and embedding. Claude gets compact references instead of raw source. Click any node to explore its properties.
FTS5 full-text search stores matched files as file_chunk nodes linked via result edges. Click any file node to expand its semantic chunk stream inline. Re-runs return cached node IDs instantly.
Fetched pages are stored as web_content nodes with an accessibility tree, ref numbers, and content chunks. Click the web_content node to see the full accessibility tree โ each element has a ref you can use with Bash tools.
Long-running commands stream output as output_chunk nodes via next edges โ like a Python generator. Read-only mode captures stdout. Read-write mode also allows sending stdin to the process.
Search results are stored as web_result stub nodes with URL, status, title, etag, and last-updated. Failed fetches are marked red. Any result can be expanded via ctx_tree_browse.
Agent tool calls create a nested subgraph โ its own session, turns, tool calls, and results. When complete, the subgraph collapses to a summary node returned to the calling agent. The full subgraph remains inspectable.
Invoking a Skill creates a skill node backed by a SKILL.md file. The file is chunked into step/diagram chunks, linked to referenced assets, and connected to its plugin. Cached on second load via content hash.
ctx-tree intercepts all MCP tool calls, not just native Claude Code tools. Every MCP server invocation creates a mcp_tool node linked to the mcp_server and tool call result, storing arguments, output, and timing metadata.
Every turn is a linear graph: prompt โ thinking โ response โ tool_calls โ questions โ choices
Turns descend from sessions. Each turn contains a sequential chain: user prompt, LLM thinking blocks, response text, tool calls, and AskUserQuestion nodes with choice nodes. Selected choices continue the conversation (green).
A non-trivial session โ drag nodes, scroll to zoom, click to inspect
PreToolUse ยท PostToolUse ยท SessionStart ยท UserPromptSubmit ยท Stop
Every hook, when it fires, and exactly what it does
startup or resume events. Skips compaction and clear noise so the injection doesn't repeat mid-session.ctx_tree_neighbors, ctx_tree_search, ctx_tree_compose, ctx_tree_recent), and the readโnodeIdโcompose workflow pattern.prompt node in the graph with a content-hash URI. Injects the resulting nodeId into context so subagents can reference the prompt without re-reading it. Prior prompts surface in future sessions via ctx_tree_search.ctx_tree_read, ctx_tree_grep, ctx_tree_browse, ctx_tree_monitor) as additionalContext. Claude sees the denial as a tool error and immediately retries with the correct ctx-tree tool โ no round-trip wasted.session node. Injects the ctx-tree tool map into the subagent prompt. If the store is populated, runs an FTS keyword search on the task text and prepends the top hits so the subagent starts with relevant context. Writes a state file timestamped for the PostToolUse capture hook to collect after the subagent finishes.skill://<name> in the graph store. If found, denies the Skill tool and injects a compact reference pointing to the cached node โ Claude calls ctx_tree_compose([nodeId], budget) instead of reloading from disk. Cache miss: passthrough, skill loads normally.~/.ctx-tree/proxy-mode flag file exists. Provides a lighter alternative to the hard-redirect hook โ advises rather than denies.Read directly โ call this instead: ctx_tree_read({file_path: โฆ})". Does not deny; Claude is nudged but not blocked. Useful for gradual adoption or debugging.note summary node as a child of the parent session. Emits summarizes edges from the summary to each captured subagent node. Deletes the state file. Result: ctx_tree_neighbors(sessionNodeId) surfaces the full subagent work without the parent agent managing any links.note node keyed by skill://<name>. Content-hash deduplication means re-saving the same skill is a no-op. The PreToolUse recall hook will find this node on the next invocation and short-circuit disk access.url, link, href).ctx_tree_browse and stores it as a compact web_chunk node. Does not inject any context or block the response. The stored pages surface in future sessions via ctx_tree_search and the Agent enrichment hook's FTS pass.stop_hook_active). Requires the ctx-tree store to be initialized and a valid transcript_path in the hook payload.thinking node (if thinking blocks are present, including redacted) and a response node (text blocks concatenated). Wires the full conversation chain via follows edges (prompt โ thinking โ response) and causal derived_from edges. Position-based dedup via source_uri prevents double-storing on replay.Walker ยท Chunker ยท Embedder ยท Indexer ยท Summarizer ยท Dedupe
Semantic ยท Hybrid ยท Compose ยท JSONPath ยท Metadata ยท Neighbors ยท PathToRoot ยท Recent
How nodes move through raw โ processing โ indexed โ stale โ pruned
Plugin marketplace ยท hooks auto-configured ยท works with any Claude Code project
~/.claude/settings.json automatically.ctx_tree_read automatically.