How to Set Up Multi-Repo Search Across Multiple Codebases with Code-Review-Graph
Code-Review-Graph uses a JSON registry at ~/.code-review-graph/registry.json and the cross_repo_search_func orchestrator to query every registered repository and return a single merged result list.
Code-Review-Graph (CRG) is an open-source Python project that indexes source code into local SQLite graph databases for semantic and lexical search. By enabling multi-repo search, you can run a single query across any number of local codebases without manually switching directories. The workflow is implemented in code_review_graph/tools/registry_tools.py and exposed to MCP clients through code_review_graph/main.py.
Register Each Repository in the Global Registry
CRG stores repository locations in a global registry file located at ~/.code-review-graph/registry.json. Each entry maps a human-readable alias to an absolute filesystem path, which allows the search orchestrator to locate the per-repo SQLite graph later.
Use the built-in CLI to register a codebase. The register command is documented in docs/USAGE.md at lines 26–31, and the underlying read logic lives in list_repos_func inside code_review_graph/tools/registry_tools.py at lines 21–40.
# Register a second repo and give it a friendly alias
code-review-graph register /path/to/other/repo --alias mylib
# Verify the entry was written to ~/.code-review-graph/registry.json
code-review-graph list-repos
You can register as many repositories as needed. Every subsequent cross-repo search will iterate over this list.
Build the Graph Database for Every Codebase
Before cross_repo_search_func can return results, each registered repository must contain a built graph. CRG writes this to .code-review-graph/graph.db inside the repo root. The GraphStore class in code_review_graph/graph.py provides the thin SQLite wrapper that the search layer consumes.
Run the build step from inside each repository root:
cd /path/to/other/repo
code-review-graph build
Repeat this process for every registered codebase. If source files change, rebuild the individual graph to keep the index current.
Execute Multi-Repo Queries
Once registration and graph generation are complete, you can execute multi-repo search through the MCP tool layer or directly via Python.
MCP Client Integration
CRG exposes the capability as cross_repo_search_tool in code_review_graph/main.py at lines 48–66. Any MCP-compatible client—such as VS Code, Claude, or Cursor—can invoke this tool without additional configuration.
# Example prompt inside an MCP client
Search for AuthService across all repos
The client forwards the request to cross_repo_search_func, which handles repo discovery, per-repo querying, and result merging automatically.
Direct Python Usage
For scripts or custom tooling, import cross_repo_search_func from code_review_graph/tools/registry_tools.py. The implementation at lines 45–66 loads the registry, iterates over entries, and aggregates hits.
from code_review_graph.tools.registry_tools import cross_repo_search_func
# Simple cross-repo query
result = cross_repo_search_func(query="AuthService", kind="Class", limit=10)
print("Found", len(result["results"]), "matches across repos")
for item in result["results"]:
print(f"{item['repo']} → {item['name']} ({item['kind']})")
Internally, the function performs the following steps on every registered repo:
- Loads the registry —
Registry()at line 67. - Opens the local graph —
GraphStore(str(db_path))at line 92. - Executes search —
hybrid_searchat lines 94–96, defined incode_review_graph/search.py. - Annotates provenance — tags each hit with
repoandrepo_pathat lines 98–101. - Merges and ranks — sorts the combined list by local rank at lines 110–113 and returns the final payload at lines 112–122.
Optional Bash Wrapper
If you prefer a shell interface, wrap the Python API in a small script:
#!/usr/bin/env bash
# crg-multi-search – thin wrapper around the Python API
QUERY="${1:-}"
LIMIT="${2:-20}"
python - <<PY
from code_review_graph.tools.registry_tools import cross_repo_search_func
res = cross_repo_search_func(query="${QUERY}", limit=${LIMIT})
import json, sys
print(json.dumps(res, indent=2))
PY
Save the file, make it executable, and run ./crg-multi-search AuthService from anywhere on your system.
Summary
- Multi-repo search in Code-Review-Graph depends on the global registry at
~/.code-review-graph/registry.json. - Register each codebase with
code-review-graph registerand verify entries withcode-review-graph list-repos. - Build a local
graph.dbinside every repo so thatGraphStoreandhybrid_searchhave data to query. - Invoke searches through the MCP
cross_repo_search_toolor the Pythoncross_repo_search_func, both of which merge and rank results automatically.
Frequently Asked Questions
Where does Code-Review-Graph store the multi-repo registry?
The registry is stored at ~/.code-review-graph/registry.json. This file is created and updated by the register CLI command and is read by list_repos_func and cross_repo_search_func in code_review_graph/tools/registry_tools.py.
Can I search a repository that has not been registered?
No. cross_repo_search_func only iterates over repositories listed in the JSON registry. Unregistered codebases are ignored during the iteration phase, so you must run code-review-graph register /path/to/repo before they become searchable.
Does multi-repo search require vector embeddings to be configured?
Not strictly. The per-repo query relies on hybrid_search in code_review_graph/search.py, which combines full-text search (FTS5) with optional embedding similarity. If embeddings are unavailable, the keyword component still returns ranked results.
How does CRG handle duplicate symbols across multiple repositories?
Each hit is tagged with repo and repo_path at lines 98–101 of code_review_graph/tools/registry_tools.py before results are merged. The final list is sorted by local rank at lines 110–113, so you see the origin of every match and a unified relevance ordering.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →