| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Persistent memory for AI coding - semantic search, git history, and intelligent context preservation
Code Memory is an MCP (Model Context Protocol) server that gives AI coding assistants long-term memory of your codebase through semantic search, git history analysis, and intelligent context preservation.
AI coding assistants forget:
Code Memory provides:
npm install -g code-memory# Initialize in your project
cd your-project
code-memory init
# Index your codebase
code-memory reindex
# Start the MCP server
code-memory serve
# Search from CLI
code-memory search "authentication flow"From the project where you want Code Memory available, choose a scope:
# Share with this project via .mcp.json
claude mcp add --transport stdio --scope project code-memory -- code-memory serve
# Or make it available to all projects via ~/.claude.json
claude mcp add --transport stdio --scope user code-memory -- code-memory serveVerify the connection with claude mcp get code-memory.
Find code by meaning, not just keywords:
code-memory search "user authentication logic"
# Finds auth code even if it doesn't contain the word "user"How it works:
Fast keyword-based search powered by tantivy:
code-memory search --fulltext "async function"Extract architectural decisions from your git history:
code-memory trace-decision "why microservices"Finds:
Understand what depends on what:
code-memory find-related "UserService"Analyzes:
Supported languages: Rust, TypeScript, JavaScript, Python, Go, Java, C++, C#, Ruby, PHP, Swift, Kotlin, Scala, Haskell, Elixir, Clojure
Learn from your coding sessions:
code-memory sessionsExtracts:
Remember important facts:
# Via MCP server
remember("We use JWT for auth because of scalability requirements")Code Memory provides 7 MCP tools for AI assistants:
Search codebase with semantic + full-text search:
search_code({
query: "authentication flow",
limit: 10
})Get detailed explanation of a symbol:
explain_code({
symbol: "UserService",
context_lines: 20
})Find why a decision was made:
trace_decision({
topic: "why microservices",
max_results: 5
})Find related code and dependencies:
find_related({
symbol: "AuthController",
relationship_type: "both" // "depends_on" | "depended_by" | "both"
})Store persistent knowledge:
remember({
key: "auth-strategy",
value: "We use JWT for stateless auth across microservices"
})Manually trigger reindexing:
index_project({
force: true
})Retrieve learned patterns:
get_session_patterns({
pattern_type: "architecture", // or "errors", "refactoring", "testing"
min_confidence: 0.7
})Initialize Code Memory in a project:
code-memory initCreates .code-memory/ directory with:
Start the MCP server:
code-memory serveRebuild the code index:
code-memory reindex # Incremental
code-memory reindex --force # Full rebuildSearch from the command line:
code-memory search "query"
code-memory search "query" --lang rust
code-memory search "query" --limit 20Show index statistics:
code-memory statsView session patterns:
code-memory sessions
code-memory sessions -n 10 # Top 10
code-memory sessions -c 0.8 # Min confidence 0.8
code-memory sessions -f json # JSON outputBackup and restore knowledge:
code-memory export knowledge.json
code-memory import knowledge.jsonConfiguration is stored in .code-memory/config.toml:
[indexing]
# File patterns to index
include = ["**/*.rs", "**/*.ts", "**/*.js", "**/*.py"]
# File patterns to ignore
exclude = ["**/node_modules/**", "**/target/**", "**/.git/**"]
# Maximum file size (in bytes)
max_file_size = 1048576 # 1MB
[search]
# Number of results to return by default
default_limit = 10
# Minimum relevance score (0.0-1.0)
min_score = 0.5
[git]
# Analyze git history for decisions
analyze_history = true
# How far back to look (in days)
history_depth = 365
[embedding]
# Embedding model (local, no API calls)
model = "all-MiniLM-L6-v2"
# Embedding dimension
dimension = 384code-memory/
├── src/
│ ├── indexer/ # Code indexing with tantivy
│ │ ├── walker.rs # File system traversal
│ │ ├── parser.rs # Symbol extraction
│ │ └── code_index.rs
│ ├── search/ # Search engines
│ │ ├── fulltext.rs # Tantivy full-text search
│ │ ├── semantic.rs # Fastembed semantic search
│ │ └── hybrid.rs # Combined ranking
│ ├── git/ # Git history analysis
│ │ ├── history.rs # Commit parsing
│ │ └── decisions.rs # Decision extraction
│ ├── graph/ # Dependency graphs
│ │ ├── imports.rs # Import parsing
│ │ └── analyzer.rs # Graph analysis
│ ├── sessions/ # Session tracking
│ │ ├── tracker.rs # Event extraction
│ │ └── patterns.rs # Pattern learning
│ ├── mcp/ # MCP server
│ │ ├── server.rs # JSON-RPC server
│ │ ├── tools.rs # Tool handlers
│ │ └── protocol.rs # MCP protocol
│ └── cli.rs # CLI interface
└── .code-memory/
├── config.toml # Configuration
├── index/ # Search index
└── knowledge.json # Persistent facts
Full support (symbol extraction + imports):
Additional languages supported for full-text search only.
| Feature | Code Memory | grep/ripgrep | GitHub Copilot |
|---|---|---|---|
| Semantic search | ✅ | ❌ | ✅ (API) |
| Offline | ✅ | ✅ | ❌ |
| Git history | ✅ | ❌ | ❌ |
| Dependency graphs | ✅ | ❌ | ❌ |
| Session learning | ✅ | ❌ | ✅ |
| MCP integration | ✅ | ❌ | ❌ |
| Cost | Free/$20 | Free | $10+/mo |
Code Memory understands meaning, not just text:
No. Everything runs locally:
Approximately:
Yes! Code Memory is an MCP server, so it works with any MCP-compatible tool:
Code Memory only accesses files you explicitly index. It never:
# Check for errors
code-memory reindex --verbose
# Force rebuild
code-memory reindex --force
# Check config
cat .code-memory/config.toml# Verify index exists
code-memory stats
# Rebuild index
code-memory reindex --force
# Check file patterns in config# Check if port is in use
lsof -i :8080
# Start with verbose logging
code-memory serve --verbosegit clone https://github.com/mstuart/code-memory.git
cd code-memory
cargo build --releasecargo test # Run all tests
cargo test --lib # Unit tests only
cargo test --test mcp_tools # Integration testsContributions welcome! Please:
MIT License - see LICENSE for details
Built with:
Give your AI assistant a memory. Never lose context again. 🧠
npm install -g code-memory| Back | FazBrowse Home | New Git URL |