๐ŸŒณ SQLite property graph ยท hook-intercepted ยท persistent across sessions

Context rot, eliminated.

ctx-tree intercepts every Claude Code tool call โ€” native and MCP โ€” and routes content through a persistent SQLite graph. Claude gets compact node references instead of raw data. 95โ€“99% context reduction.

Context savings โ€” without vs. with ctx-tree

โŒ Without ctx-tree

Read file
~4,200 tok
Grep (8 files)
~8,400 tok
WebFetch
~11,000 tok
MCP tool
~3,600 tok

โœ… With ctx-tree

Read file
~60 tok
Grep (8 files)
~160 tok
WebFetch
~110 tok
MCP tool
~70 tok
โœฆ Knowledge accumulates across sessions โ€” re-reads cost zero tokens
How it works โ€” every tool call
๐Ÿ”—
Hook fires
PreToolUse
โ†’
๐Ÿšซ
Native blocked
deny emitted
โ†’
๐ŸŒณ
ctx_tree_*
MCP tool runs
โ†’
๐Ÿ’พ
Node stored
SQLite graph
โ†’
๐Ÿ“Ž
nodeId returned
~60 tokens
โ†’
๐ŸŽฏ
compose()
recall on demand

The same file read again โ€” next turn or next week โ€” costs zero tokens. It's already in the graph.

MCP tools
ctx_tree_read
Read file with tree-sitter semantic chunking. Returns nodeId + symbol index; chunks stored for future compose() calls.
ctx_tree_grep
Ripgrep search with results stored as graph nodes. Each matching file links to its semantic chunk stream.
ctx_tree_browse
Fetch a URL and store it as a web_content node with accessibility tree representation. Returns compact reference.
ctx_tree_search
FTS5 keyword search across all stored nodes โ€” current session and all prior sessions for this project.
ctx_tree_compose
Budget-bounded context bundle from seed nodeIds. Assembles a focused context slice without re-reading anything.
ctx_tree_neighbors
Graph walk from a node โ€” find callers, imports, same-module siblings, derived nodes, and summarized subgraphs.
ctx_tree_path_to_root
Walk the parent chain from any node to the session root. Understand how a chunk fits into the larger picture.
ctx_tree_recent
Surface nodes captured in prior sessions. Instant orientation without re-reading anything from last time.
ctx_tree_monitor
Run a command and stream output as chunk nodes. Read-write mode supports stdin sends in the same graph.
Hooks โ€” fires automatically, zero configuration after install
SessionStart
On every session startup or resume
Injects the ctx-tree tool guide and redirect reminders into context.
UserPromptSubmit
User submits a prompt โ‰ฅ 100 chars
Stores prompt as observation node. Injects nodeId so subagents reference it without re-reading. Surfaces in future sessions via ctx_tree_search.
PreToolUse
Read (code files) ยท Grep ยท Bash grep/cat ยท WebFetch ยท Monitor
Hard-denies native tool. Emits exact ctx_tree_* replacement call as additionalContext โ€” Claude retries immediately with the correct tool.
PreToolUse
Agent tool
Injects ctx-tree tool map + FTS context hits from prior work into subagent prompt. Creates session node. Writes state file for capture hook.
PreToolUse
Skill tool
Cache hit: denies and injects ctx_tree_compose reference โ€” zero disk I/O. Cache miss: passthrough, first load stores the skill for next time.
PostToolUse
Agent tool completes
Creates summary note node linking all subagent work. ctx_tree_neighbors(sessionId) surfaces the full subagent graph from the parent session.
PostToolUse
Skill tool completes ยท WebSearch completes
Skill: stores content as cached node for instant recall next time. WebSearch: fire-and-forget browse of each result URL โ€” pages available in future searches.
Install
1
Add the agent marketplace
/plugin marketplace add joeblackwaslike/agent-marketplace
2
Install ctx-tree
MCP server, all hooks, and skills โ€” configured automatically.
/plugin install ctx-tree@agent-marketplace
3
Requirements
brew install bun ripgrep # macOS # Linux: curl -fsSL https://bun.sh/install | bash && apt install ripgrep

Built on mcp-exec โ€” context-efficient MCP workflow execution. ยท Full interactive visualization ยท Design spec