terraphim-agent is a command-line AI agent that searches before it answers. It runs
local knowledge graph queries, imports session history from Claude Code and Cursor,
captures failed commands via post-tool-use hooks, and surfaces past corrections when
you encounter a recurring error.
Install it with one command:
cargo install terraphim-agent
What it does
- Session search: query across imported Claude Code and Cursor session logs.
- Knowledge-graph search: match queries against role-configured Aho-Corasick automata.
- Learning capture: the
learnsubcommand records failed commands and their corrections. - Command rewriting: pre-tool-use hooks rewrite
npm installtobun add,pip installtouv add, etc. via a thesaurus. - Learning compile:
learn compileconverts capturedToolPreferencecorrections into a thesaurus JSON that thereplacecommand loads directly, closing the feedback loop from failure to live rewrite. - Listener dispatch: the listener executes
terraphim-agentsubcommands triggered by@adf:<agent-name>Gitea mentions, with three security layers (allowlist, metachar rejection, CommandGuard), and posts results back as markdown comments.
See the command rewriting how-to and the blog post Teaching AI Agents to Learn from Their Mistakes for worked examples.