| name | code-memory |
| description | Use when coding in a Git repository and semantic code search, AST-aware symbol lookup, documentation search, Git-history search, or dead-code discovery would help. |
Code Memory
code-memory is a local MCP server for code intelligence. It indexes a repository into a local SQLite database, extracts AST symbols, embeds code and documentation, and exposes tools for semantic code search, symbol lookup, documentation search, Git history search, index status, and dead-code candidates.
Use this skill when working in a local or GitHub-backed codebase and you need to:
- Understand an unfamiliar or large repository.
- Find concept-related code when exact text search is insufficient.
- Locate definitions, references, and file structure for symbols.
- Search project documentation alongside source code.
- Investigate regressions or design changes through Git history.
- Identify possible dead code before cleanup.
Do not use code-memory as the only source of truth. Use it for discovery, then verify important results with direct file reads, exact search such as rg, tests, or Git inspection.
MCP Workflow
When the code-memory MCP tools are available:
- Check whether the target repository is indexed:
check_index_status(directory="/absolute/path/to/repo")
- If the index is missing or stale, index the repository:
index_codebase(directory="/absolute/path/to/repo")
- Re-index after meaningful code changes when search freshness matters.
- Use direct reads and tests after retrieval; semantic matches can be approximate.
Core tools:
index_codebase(directory, cpu=false): index or update a repository.
check_index_status(directory): verify whether an index exists and is current.
get_index_stats(directory): summarize indexed files, symbols, and embeddings.
search_code(query, search_type, directory): search code semantically or structurally.
search_docs(query, directory, top_k=10): search indexed documentation.
search_history(query, directory, search_type, target_file, line_start, line_end): search Git history.
find_dead_code(directory, min_confidence=0.5, kinds=null, include_tests=false, top_k=50): find candidate unused code.
Use search_code search types as follows:
topic_discovery: find code related to a concept or feature.
definition: find where a symbol, function, class, or API is defined.
references: find likely usages of a symbol or API.
file_structure: understand modules, packages, and architectural layout.
Examples
Find concept-related implementation:
search_code(
directory="/home/jim/project",
query="authentication middleware",
search_type="topic_discovery"
)
Find a symbol definition:
search_code(
directory="/home/jim/project",
query="UserService",
search_type="definition"
)
Search documentation:
search_docs(
directory="/home/jim/project",
query="deployment configuration",
top_k=10
)
Investigate history for a file range:
search_history(
directory="/home/jim/project",
query="why retry behavior changed",
search_type="file_history",
target_file="src/client.py",
line_start=40,
line_end=90
)
Local State
code-memory creates local database files in indexed repositories:
code_memory.db
code_memory.db-wal
code_memory.db-shm
Add code_memory.db* to .gitignore for repositories you index. Treat the database as sensitive because snippets, symbols, and documentation from the repository may be stored in it.
Security And Operations
- The MCP server is local and has no telemetry.
- Model downloads may occur when embedding models are first used.
- Some embedding backends can load model code; use trusted models and repositories.
- If running over SSE or HTTP, bind only to
127.0.0.1 unless you intentionally want network exposure.
- If CUDA memory is a problem, index with
cpu=true or set CODE_MEMORY_DEVICE=cpu.
Useful environment variables include:
CODE_MEMORY_LOG_LEVEL
EMBEDDING_MODEL
CODE_MEMORY_DEVICE
CODE_MEMORY_BATCH_SIZE
CODE_MEMORY_MAX_WORKERS
CODE_MEMORY_RERANK
RERANK_MODEL