For Developers
The memory layer for autonomous AI agents. Use the SDK to build AI apps with persistent memory, or use MCP to give your IDE deep codebase understanding.
Trevec is the memory layer for autonomous AI agents. It gives any AI app persistent, user-scoped memory with sub-50ms retrieval — and gives coding agents structural understanding of your entire codebase.
Trevec has two main interfaces:
Python and npm packages for building AI apps with persistent memory. Chatbots, tutors, advisors, support agents — any app that needs to remember.
pip install trevecornpm install trevecCLI and MCP server for your daily coding. Gives Claude Code, Cursor, Windsurf, and Codex deep structural understanding of your codebase.
curl -fsSL dl.trevec.dev/install.sh | shInstall Trevec with a single command:
macOS (Apple Silicon & Intel) and Linux (x64 & arm64). Windows via PowerShell: irm dl.trevec.dev/install.ps1 | iex
pip install trevecThen get started:
trevec mcp setupOne-time: configure all your AI toolscd your-project && trevec initPer repo: index, write rules, doneThat’s it. Your AI tools now have structural understanding of your entire codebase.
The Python and npm SDK for building AI apps with persistent memory. Use it in your FastAPI, Django, Express, or any backend.
pip install trevecnpm install trevecGive your AI agent persistent, user-scoped memory. Each user’s data is isolated. Works without any API key, cloud service, or external database.
from trevec import Trevec
tv = Trevec() # ephemeral (in-memory)
tv = Trevec("my-app") # persistent (~/.trevec/my-app/)tv.add("I love hiking in Denver", user_id="alex")
tv.add("Allergic to peanuts", user_id="alex")
tv.add("Prefers Python over JavaScript", user_id="bob")results = tv.search("hobbies", user_id="alex")
# → [{"memory": "I love hiking in Denver", "score": 3.0}]
# bob can't see alex's data:
tv.search("hiking", user_id="bob") # → []tv.add([
{"role": "user", "content": "What is calculus?"},
{"role": "assistant", "content": "The study of change..."},
], user_id="student_01")tv.get_all("alex") # all memories for a user
tv.delete("memory_id_123") # delete specific memory
tv.delete_all("alex") # GDPR: delete all user dataIndex a codebase with Tree-sitter, then query it with hybrid search. Use this in your coding agents or any tool that needs to understand code.
tv = Trevec.for_repo("/path/to/repo")
stats = tv.index()
print(f"Indexed {stats['nodes_extracted']} nodes in {stats['total_ms']}ms")result = tv.query("How does authentication work?")
print(result["context"]) # formatted source code
print(result["total_tokens"]) # token count
print(result["retrieval_ms"]) # latency
for node in result["nodes"]:
print(f"{node['file_path']}:{node['start_line']} {node['name']}")Trevec integrates with popular AI frameworks. Here’s the pattern for FastAPI — the same approach works with Django, Flask, Express, or any backend.
from fastapi import FastAPI
from trevec import Trevec
app = FastAPI()
tv = Trevec("my-app")
@app.post("/chat")
async def chat(user_id: str, message: str):
# Retrieve relevant context for this user
memories = tv.search(message, user_id=user_id, limit=5)
context = "\n".join([m["memory"] for m in memories])
# Build prompt with context (send to your LLM)
prompt = f"Context:\n{context}\n\nUser: {message}"
# Save the interaction
tv.add(message, user_id=user_id)
return {"prompt": prompt, "memories_used": len(memories)}The CLI and MCP server for your daily coding. Gives Claude Code, Cursor, Windsurf, Zed, and Codex deep structural understanding of your codebase.
curl -fsSL dl.trevec.dev/install.sh | shThree commands. Works with Claude Code, Cursor, Codex, and Claude Desktop.
trevec mcp setupOne-time global setup. Configures MCP for Claude Code, Cursor, Claude Desktop, and Codex. No per-project wiring needed.
trevec initSet up Trevec in your project. Indexes your codebase, writes IDE rules, and registers the project. One command, ready to go.
trevec indexRe-index your codebase. Rebuilds the semantic graph and stores everything locally. Usually handled by init.
trevec mcp doctorRun health checks on your setup. Verifies binary, index, MCP wiring, and memory configuration.
trevec ask <query>Query your codebase from the terminal. Returns structurally relevant code context with file paths and spans.
trevec inspect <file>View the topology of a file. All functions, classes, and their relationships (callers, callees, imports).
trevec mcp removeRemove Trevec MCP configuration from all AI tools. Clean uninstall.
See how context flows automatically between tools. Plan in Claude Code, continue in Cursor. Trevec remembers everything.
Automatically. No copy-pasting. No repeating yourself. The context follows you from one tool to the next.
Every debugging session, design discussion, and refactor across every tool is captured. Ask about months of work and get a complete, code-linked summary.
Total Recall
Every debugging session, design discussion, and refactor across every tool is captured in one place. Ask Trevec about months of work and get a complete, code-linked summary in seconds.
Stop wasting tokens and time re-explaining your codebase. Trevec remembers it for you.
Can you summarize everything I worked on since November? I need it for my performance review. Key projects, architectural decisions, and impact.
These tools are automatically available to your AI agents after running trevec mcp setup and trevec init in your project.
get_contextPrimary tool for understanding code. Ask a natural-language question, get structurally relevant code with file paths, line ranges, and related functions.
search_codeHybrid search over your indexed codebase. Find specific functions, classes, or patterns by name or keyword.
read_file_topologyInspect the structure of a file. All code nodes and their relationships. Use before modifying a file to understand dependencies.
remember_turnSave important context to episodic memory. Debugging sessions, architecture decisions, and code reviews persist across sessions.
recall_historySearch episodic memory for past discussions. Recover context from previous sessions about any topic.
get_file_historyRetrieve discussion history for a specific file. See what was previously discussed: prior bugs, design decisions, review comments.
summarize_periodGenerate a bullet-point summary of work within a time range. Perfect for daily standups or weekly recaps.
repo_summaryHigh-level overview of your repository: languages, file counts, entry points, hotspots, and detected conventions. Great for onboarding.
neighbor_signaturesGiven a list of files, returns the external API surface they depend on. Imported symbols with signatures. Use before modifying a file.
batch_contextRun multiple get_context queries in a single call. Each query gets its own budget. Reduces round-trips for related questions.
Tree-sitter parses every file into ASTs. Functions, classes, modules become nodes. Imports, calls, inheritance become edges.
Hybrid search combining full-text and semantic matching. Ranked by structural relevance, not just keywords.
Results are enriched with related code automatically. Context is assembled to fit your model's token limit and streamed via MCP.
Install Trevec and give your AI agents persistent memory.
Download Now