Skip to content

syncable-dev/memtrace-public

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memtrace

Memtrace

The persistent memory layer for coding agents.
A bi-temporal, episodic, structural knowledge graph — built from AST, not guesswork.

npm version license docs

Early Access — Memtrace is under active development. Core indexing and structural search are stable. Temporal features (evolution scoring, timeline replay) are functional but may have rough edges. Report issues here.


Memtrace gives coding agents something they've never had: structural memory. Not vector similarity. Not semantic chunking. A real knowledge graph compiled from your codebase's AST — where every function, class, interface, and API endpoint exists as a node with deterministic, typed relationships.

Index once. Every agent query after that resolves through graph traversal — callers, callees, implementations, imports, blast radius, temporal evolution — in milliseconds, with zero token waste.

npm install -g memtrace    # binary + 12 skills + MCP server — one command
memtrace start             # launches the graph database
memtrace index .           # indexes your codebase in seconds

That's it. Claude picks up the skills and MCP tools automatically.

memtrace-demo.mp4

Built-in UI at localhost:3030 — explore your graph, trace dependencies, spot dead code, and visualize architecture at a glance


Why Memtrace Exists

Good code intelligence tools already exist. GitNexus and CodeGrapherContext build AST-based graphs with symbol relationships, and they work well for understanding what's in your codebase right now.

Memtrace is a bi-temporal episodic structural knowledge graph. It builds on that same AST foundation and adds two dimensions:

  • Temporal memory — every symbol carries its full version history. Agents can reason about what changed, when it changed, and how the architecture evolved — not just what exists today. Six scoring algorithms (impact, novelty, recency, directional, compound, overview) let agents ask different temporal questions.
  • Cross-service API topology — Memtrace maps HTTP call graphs between repositories, detecting which services call which endpoints across your architecture.

On top of that, the structural layer is comprehensive:

  • Symbols are nodes — functions, classes, interfaces, types, endpoints
  • Relationships are edgesCALLS, IMPLEMENTS, IMPORTS, EXPORTS, CONTAINS
  • Community detection — Louvain algorithm identifies architectural modules automatically
  • Hybrid search — Tantivy BM25 + vector embeddings + Reciprocal Rank Fusion, all on top of the graph
  • Rust-native — compiled binary, no Python/JS runtime overhead, sub-15ms average query latency

The agent doesn't just search your code. It remembers it.

Benchmarks

All benchmarks run on the same machine, same codebase, same queries. No cherry-picking.

Does it find the right thing?

Search accuracy: Memtrace 97.3% vs ChromaDB 89.6% vs GitNexus 12.8%

How fast?

Search latency: Memtrace 13.4ms vs ChromaDB 60.6ms vs GitNexus 172.7ms vs CodeGrapher 510.5ms

How much context does it save?

Token usage: Memtrace 319K vs ChromaDB 1.91M — 83% reduction

How long to set up?

Indexing: Memtrace 1.5s vs Graphiti 6h vs Mem0 31m
Memtrace vs. general memory systems (Mem0, Graphiti)

Mem0 and Graphiti are strong conversational memory engines designed for tracking entity knowledge (e.g. User -> Likes -> Apples). They excel at that. For code intelligence specifically, the tradeoff is that they rely on LLM inference to build their graphs — which adds cost and time when processing thousands of source files.

Graphiti processes data through add_episode(), which triggers multiple LLM calls per episode — entity extraction, relationship resolution, deduplication. At ~50 episodes/minute (source), ingesting 1,500 code files takes 1–2 hours.

Mem0 processes data through client.add(), which queues async LLM extraction and conflict resolution per memory item (source). Bulk ingestion with infer=True (default) means every file passes through an LLM pipeline. Throughput is bounded by your LLM provider's rate limits.

Both accumulate $10–50+ in API costs for large codebases because every relationship is inferred rather than parsed.

Memtrace takes a different approach: it indexes 1,500 files in 1.2–1.8 seconds for $0.00 — no LLM calls, no API costs, no rate limits. Native Tree-sitter AST parsers resolve deterministic symbol references (CALLS, IMPLEMENTS, IMPORTS) locally. The tradeoff is that Memtrace is purpose-built for code — it doesn't handle conversational entity memory the way Mem0 and Graphiti do.

Memtrace vs. code graphers (GitNexus, CodeGrapherContext)

GitNexus and CodeGrapherContext both build AST-based code graphs with structural relationships — solid tools in the same space. Memtrace shares that foundation and extends it with temporal memory, API topology, and a Rust runtime:

Capability Memtrace GitNexus CodeGrapher
AST-based graph Yes Yes Yes
Structural relationships (CALLS, IMPLEMENTS, IMPORTS) Yes Yes Yes
Bi-temporal version history per symbol Yes — 6 scoring modes Git-diff only No
Cross-service HTTP API topology Yes No No
Community detection (Louvain) Yes Yes No
Hybrid search (BM25 + vector + RRF) Yes — Tantivy + embeddings No BM25 + optional embeddings
Language Rust (compiled binary) JavaScript Python
Search accuracy (1K queries) 97.3% 12.8% 0%*
Query latency (1K queries) 13.4 ms avg 172.7 ms avg 510.5 ms avg
Tokens per query 319 avg 254 avg 23 avg
Index time (1,500 files) 1.5 sec 10.5 sec ~3.5 min

*CGC's 0% reflects an output format mismatch — it returns symbol names without file paths, so our Acc@1 evaluator can't match them. CGC likely finds relevant symbols; the metric just can't confirm it. All numbers from live benchmark on the same machine, same codebase, same 1,000 queries.

The latency difference is primarily Rust vs. interpreted runtimes, and Memgraph's Bolt protocol vs. HTTP/embedding pipelines. The feature difference is temporal memory and API topology — dimensions Memtrace adds on top of the shared AST-graph foundation.

25+ MCP Tools

Memtrace exposes a full structural toolkit via the Model Context Protocol:

Search & Discovery

  • find_code — hybrid BM25 + semantic search with RRF
  • find_symbol — exact/fuzzy name match with Levenshtein

Relationships

  • analyze_relationships — callers, callees, hierarchy, imports
  • get_symbol_context — 360° view in one call

Impact Analysis

  • get_impact — blast radius with risk rating
  • detect_changes — diff-to-symbols scope mapping

Code Quality

  • find_dead_code — zero-caller detection
  • find_most_complex_functions — complexity hotspots
  • calculate_cyclomatic_complexity — per-symbol scoring
  • get_repository_stats — repo-wide metrics

Temporal Analysis

  • get_evolution — 6 scoring modes (compound, impact, novel, recent, directional, overview)
  • get_timeline — full symbol version history
  • detect_changes — diff-based impact scope

Graph Algorithms

  • find_bridge_symbols — betweenness centrality
  • find_central_symbols — PageRank / degree
  • list_communities — Louvain module detection
  • list_processes / get_process_flow — execution tracing

API Topology

  • get_api_topology — cross-repo HTTP call graph
  • find_api_endpoints — all exposed routes
  • find_api_calls — all outbound HTTP calls

Indexing & Watch

  • index_directory — parse, resolve, embed
  • watch_directory — live incremental re-indexing
  • execute_cypher — direct graph queries

12 Agent Skills

Memtrace ships skills that teach Claude how to use the graph. They fire automatically based on what you ask — no prompt engineering required.

Skill You say...
Search memtrace-search "find this function", "where is X defined"
Relationships memtrace-relationships "who calls this", "show class hierarchy"
Evolution memtrace-evolution "what changed this week", "how did this evolve"
Impact memtrace-impact "what breaks if I change this", "blast radius"
Quality memtrace-quality "find dead code", "complexity hotspots"
Architecture memtrace-graph "show me the architecture", "find bottlenecks"
APIs memtrace-api-topology "list API endpoints", "service dependencies"
Index memtrace-index "index this project", "parse this codebase"

Plus 4 workflow skills that chain multiple tools with decision logic:

Skill You say...
memtrace-codebase-exploration "I'm new to this project", "give me an overview"
memtrace-change-impact-analysis "what will break if I refactor this"
memtrace-incident-investigation "something broke", "root cause analysis"
memtrace-refactoring-guide "help me refactor", "clean up tech debt"

Temporal Engine

Six scoring algorithms for different temporal questions:

Mode Best for
compound General-purpose "what changed?" — weighted blend of impact, novelty, recency
impact "What broke?" — ranks by blast radius (in_degree^0.7 × (1 + out_degree)^0.3)
novel "What's unexpected?" — anomaly detection via surprise scoring
recent "What changed near the incident?" — exponential time decay
directional "What was added vs removed?" — asymmetric scoring
overview Quick module-level summary

Uses Structural Significance Budgeting to surface the minimum set of changes covering ≥80% of total significance.

Compatibility

Editor / Agent MCP Tools (25+) Skills (12) Install
Claude Code npm install -g memtrace — fully automatic
Claude Desktop Automatic — shared with Claude Code
Cursor (v2.4+) npm install -g memtrace — fully automatic
Windsurf Coming soon Add MCP server manually
VS Code (Copilot) Add MCP server manually
Cline / Roo Code Add MCP server manually
Codex CLI Coming soon Add MCP server manually
Any MCP client Add MCP server manually

MCP tools work with any editor or agent that supports the Model Context Protocol. Skills are workflow prompts that teach the agent how to chain tools — Claude Code, Claude Desktop, and Cursor (v2.4+) all load them natively from the same SKILL.md format.

Setup

Claude Code + Claude Desktop

npm install -g memtrace handles everything automatically — binary, 12 skills, MCP server, plugin, and marketplace all register in one command for both Claude Code and Claude Desktop.

For manual setup:

claude plugin marketplace add syncable-dev/memtrace
claude plugin install memtrace-skills@memtrace --scope user
claude mcp add memtrace -- memtrace mcp -e MEMGRAPH_URL=bolt://localhost:7687

Cursor

Cursor v2.4+ supports Agent Skills natively, and npm install -g memtrace handles everything automatically — no separate Cursor plugin is needed because Cursor reads the same SKILL.md format as Claude.

What the installer writes:

  • MCP server~/.cursor/mcp.json (global — works in every project you open)
  • 12 skills + 4 workflows~/.cursor/skills/memtrace-*/SKILL.md

For a project-local install (so the skills travel with your repo and teammates get them on clone), run inside the project:

memtrace install --only cursor --local

This writes to .cursor/mcp.json and .cursor/skills/ relative to the project root instead of your home directory.

For a manual install (without the npm package), clone this repo and copy the skills directly:

cp -R plugins/memtrace-skills/skills/* ~/.cursor/skills/

Then register the MCP server manually (see the "Other Editors" JSON below).

Other Editors (Windsurf, VS Code, Cline)

After npm install -g memtrace, add the MCP server to your editor's config:

{
  "mcpServers": {
    "memtrace": {
      "command": "memtrace",
      "args": ["mcp"],
      "env": { "MEMGRAPH_URL": "bolt://localhost:7687" }
    }
  }
}
Config file locations by editor
Editor Config file
Windsurf ~/.codeium/windsurf/mcp_config.json
VS Code (Copilot) .vscode/mcp.json in your project root
Cline Cline MCP settings in the extension panel

Uninstall

memtrace uninstall              # removes skills, MCP server, plugin, and settings
npm uninstall -g memtrace       # removes the binary

Already ran npm uninstall first? The cleanup script is persisted at ~/.memtrace/uninstall.js:

node ~/.memtrace/uninstall.js

Languages

Rust · Go · TypeScript · JavaScript · Python · Java · C · C++ · C# · Swift · Kotlin · Ruby · PHP · Dart · Scala · Perl — and more via Tree-sitter.

Requirements

Dependency Purpose
Memgraph Graph database — auto-managed via memtrace start
Node.js ≥ 18 npm installation
Git Temporal analysis (commit history)

Documentation · npm · Issues

Built by Syncable · Proprietary EULA · Free to use

About

The missing memory layer for coding agents

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages