Install
openclaw skills install code-memory-skillUse when doing coding work in a Git repository and semantic code search, AST-aware symbol lookup, documentation search, Git-history search, or dead-code discovery would help.
openclaw skills install code-memory-skillcode-memory is a local MCP server for code intelligence. It indexes a project into a local SQLite database, extracts AST symbols where supported, embeds code/docs with sentence-transformers, and exposes MCP tools for code search, docs search, Git history, index stats, and dead-code candidates.
Upstream: https://github.com/kapillamba4/code-memory
Reviewed version: v1.0.32 / commit 563788a2a7d015699f20251d404aeb293346f40c.
Use this skill anytime coding a GitHub project or any local Git repository, especially when:
Do not use it as the only evidence for risky edits. It is retrieval assistance, not a replacement for rg, direct file reads, tests, typechecks, or human review.
Prerequisites:
>=3.13.uv/uvx recommended. Install uv with the official Astral installer or package manager.jinaai/jina-code-embeddings-0.5b, to the HuggingFace cache. Expect roughly 600 MB download and about 1 GB+ RAM when loaded.Recommended MCP command:
uvx code-memory
Pip install:
python3.13 -m pip install code-memory
code-memory
From source:
git clone https://github.com/kapillamba4/code-memory.git
cd code-memory
uv sync
uv run mcp run code_memory/server.py
Standalone binaries are published on GitHub Releases. Treat binaries as a supply-chain trust decision: prefer package/source installs unless there is a specific reason to use a binary.
Use stdio for normal per-project MCP hosting:
{
"mcpServers": {
"code-memory": {
"command": "uvx",
"args": ["code-memory"]
}
}
}
For a shared server, run:
uvx code-memory --transport sse --host 127.0.0.1 --port 8765
Then configure the MCP host to use:
{
"mcpServers": {
"code-memory": {
"url": "http://127.0.0.1:8765/sse"
}
}
}
Do not bind SSE to 0.0.0.0 or a public interface without an authenticated reverse proxy. The SSE endpoint is unauthenticated.
Before searching a project:
check_index_status(directory="/path/to/repo").index_codebase(directory="/path/to/repo").Core tools:
index_codebase(directory, cpu=false): builds/refreshes the local index. Use cpu=true if CUDA/MPS memory is constrained.check_index_status(directory): quick readiness check.get_index_stats(directory): index size, coverage, model, and database health.search_code(query, search_type, directory): semantic/structural code lookup. search_type is topic_discovery, definition, references, or file_structure.search_docs(query, directory, top_k=10): README/docs/docstring search.search_history(query, directory, search_type, target_file, line_start, line_end): Git history, file history, blame, and commit details.find_dead_code(directory, min_confidence=0.5, kinds=null, include_tests=false, top_k=50): candidate unused functions/classes/methods. Verify manually before deleting anything.Useful examples:
index_codebase(directory="/home/jim/project")
search_code(query="authentication middleware", search_type="topic_discovery", directory="/home/jim/project")
search_code(query="UserService", search_type="definition", directory="/home/jim/project")
search_code(query="send_email", search_type="references", directory="/home/jim/project")
search_docs(query="deployment architecture", directory="/home/jim/project", top_k=5)
search_history(query="timeout", search_type="commits", directory="/home/jim/project")
search_history(query="", search_type="file_history", target_file="src/auth.py", directory="/home/jim/project")
find_dead_code(directory="/home/jim/project", min_confidence=0.75)
code_memory.db in the indexed project root.code_memory.db-wal and code_memory.db-shm..gitignore is respected, including nested .gitignore files. Built-in skipped dirs include .git, .venv, venv, node_modules, caches, dist, build, target, bin, and obj..gitignore or exclude/remove the database after accidental indexing.code_memory.db* to .gitignore unless there is a deliberate reason to version the index. Usually there is not.Current upstream requires Python >=3.13 and declares these runtime dependencies:
mcp[cli]sentence-transformerssqlite-vectree-sittertree-sitter-python, tree-sitter-javascript, tree-sitter-typescript, tree-sitter-java, tree-sitter-kotlin, tree-sitter-go, tree-sitter-rust, tree-sitter-c, tree-sitter-cpp, tree-sitter-rubygitpythonpathspecmarkdown-it-pyeinopsxxhashDevelopment dependencies include pytest, pytest-asyncio, pytest-cov, ruff, and mypy.
Supported AST parsing: Python, JavaScript/TypeScript, Java, Go, Rust, C/C++, Ruby, Kotlin.
Fallback whole-file indexing: C#, Swift, Scala, Lua, shell, YAML/TOML/JSON, HTML/CSS, SQL, Markdown, text, and similar source-like files.
Environment variables:
CODE_MEMORY_LOG_LEVEL: DEBUG, INFO, WARNING, or ERROR.EMBEDDING_MODEL: HuggingFace model id. Changing it invalidates/rebuilds indexes.CODE_MEMORY_DEVICE: auto, cuda, mps, or cpu.CODE_MEMORY_BATCH_SIZE: embedding batch size, default 64.CODE_MEMORY_MAX_WORKERS: parser thread pool size, default 4.CODE_MEMORY_RERANK: true/1/yes enables cross-encoder reranking.RERANK_MODEL: HuggingFace model id for reranking.Observed positives:
.gitignore and common dependency/build/cache folders are skipped during indexing.Important risks and controls:
sentence-transformers loads the embedding model with trust_remote_code=True. The default HuggingFace model therefore becomes executable code. For sensitive environments, pre-vet/pin the model or use a trusted local/bundled model via EMBEDDING_MODEL.--host 127.0.0.1; never expose it directly to a LAN or internet interface.code_memory.db* contains searchable code snippets and embeddings. Treat it as sensitive project data; do not commit, sync, or share casually..gitignore before indexing private repos.find_dead_code is heuristic. Reflection, decorators, framework registration, dynamic dispatch, exports, and tests can make live code appear unused.index_codebase(directory) first, then search again.directory is inside a Git repository.index_codebase(..., cpu=true) or set CODE_MEMORY_DEVICE=cpu.index_codebase; indexing is incremental.