crg
CLAUDE.md76 starsChanged 8 months agoApache-2.0View on GitHub
Fork of code-review-graph with fixed multi-word search, qualified call resolution, dual-mode embedding (ONNX local + cloud chain via EMBEDDING_MODELS), and output pagination. See AGENTS.md va README.md de hieu architecture va configuration. - CLI and bundled Skills are the primary coding-harness surfaces. - MCP stdio is a secondary protocol adapter; it must not duplicate graph logic. - Graph state is local at <repo>/.code-review-graph/graph.db unless explicit self-host/multi-user configuration changes the data directory. - CRG has no hosted Cloudflare runtime in the target…
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- n24q02m/better-code-review-graphword for word, first seen Mar 22, 2026
Other versions1 project uses a version of this.
Word for word · 1
- n24q02m/better-code-review-graph★ 76100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- build-graphSkill
- review-deltaSkill
- review-prSkill
- impact-auditSkill
- onboard-repoSkill
- refactor-checkSkill
- review-deltaSkill
- review-prSkill
- security-sweepSkill
The file
We split this CLAUDE.md into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 117
Default timeout: 30 seconds per test
- Distinctive: line 125
No new public OCI publication.
- Distinctive: line 133
Commit message: enforce Conventional Commits
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
crg
Fork of code-review-graph with fixed multi-word search, qualified call resolution,
dual-mode embedding (ONNX local + cloud chain via EMBEDDING_MODELS), and output pagination.
See AGENTS.md va README.md de hieu architecture va configuration.
Cau truc
src/crg/-- Package chinh (src layout)server.py-- FastMCP server, 6 tools: graph + query + review (3 main) + config (incl. setup_*) + security + helptools.py-- MCP tool implementations (build, query, impact, review, search, embed, stats, docs, large functions)parser.py-- Tree-sitter parsing (14 langs) + call target resolutiongraph.py-- SQLite GraphStore, search, impact radius, NetworkX cacheincremental.py-- Git integration, file watching, incremental updatesembeddings.py-- Dual-mode embedding: local ONNX through the fastretrieval registry + cloud chain (EMBEDDING_MODELS) via OpenAI-compatible HTTP clients (hull_core.providers)docs/-- Help tool documentation (graph.md, query.md, review.md, config.md, recipes.md, security.md)
cli.py-- local CLI: no args starts MCP stdio; positional subcommands expose graph/query/review/security over the same domain services__init__.py-- Version export__main__.py--python -mentry (calls cli.main)py.typed-- PEP 561 marker
tests/-- Mirror source modulesskills/-- Claude Code skills (impact-audit, onboard-repo, refactor-check, review-delta, review-pr, security-sweep)hooks/-- SessionStart + UserPromptSubmit + PostToolUse hooks.claude-plugin/-- Plugin manifest + marketplace metadata
Local-first boundary
- CLI and bundled Skills are the primary coding-harness surfaces.
- MCP stdio is a secondary protocol adapter; it must not duplicate graph logic.
- Graph state is local at
<repo>/.code-review-graph/graph.dbunless explicit self-host/multi-user configuration changes the data directory. - CRG has no hosted Cloudflare runtime in the target topology. PyPI, CI, security, GitHub releases, and eligible stable MCP Registry publication remain active. Historical OCI tags remain available; new public OCI images do not.
Lenh thuong dung
uv sync --group dev # Cai dependencies
uv run pytest # Test tat ca
uv run pytest tests/test_graph.py::test_function_name -v # Test don le
uv run ruff check . # Lint
uv run ruff format . # Format
uv run ruff check --fix . && uv run ruff format . # Fix
uv run ty check # Type check (ty lenient config)
uv run crg # Chay MCP server (stdio, default)Cau hinh quan trong
- Python 3.13 bat buoc --
requires-python = "==3.13.*" - Ruff: line-length 88, target py313, rules E/F/W/I/UP/B/C4, ignore E501
- ty: lenient (unresolved-import, unresolved-attribute, possibly-missing-attribute all "ignore")
Architecture
Source files --> Tree-sitter parser --> SQLite graph (nodes + edges)
|
NetworkX BFS --> Impact radius
|
Embedding store --> Semantic search
FastMCP server --> secondary MCP adapter (6 tools: graph + query + review + config + security + help)- Parser (parser.py): Tree-sitter extracts nodes (File, Class, Function, Type, Test) and edges (CALLS, IMPORTS_FROM, INHERITS, IMPLEMENTS, CONTAINS, TESTED_BY, DEPENDS_ON). Resolves same-file bare call targets to qualified names.
- Graph (graph.py): SQLite with WAL mode. Multi-word AND-logic search. GraphNode/GraphEdge dataclasses.
- Incremental (incremental.py): Git diff detection, file hash tracking, re-parses only changed files.
- Embeddings (embeddings.py): Dual-mode -- local ONNX through the fastretrieval registry (default, zero-config) or cloud via the
EMBEDDING_MODELSchain (OpenAI-compatible HTTP clients; order = fallback, empty = local). Fixed 768-dim storage. - Server (server.py): 6 tools — graph (build/update/stats/embed/export/summarize), query (query/search/impact/large_functions/spot_check/renamed_in_diff/diff), review, config (status/set/cache_clear + setup_status/setup_start/setup_skip/setup_reset/setup_complete), security (scan/report/suppress/rule_list), help. Returns structured dict payloads over MCP; the CLI serializes them as JSON.
Embedding + LLM backends
Embedding (cloud backend) + the LLM summarizer dispatch through
OpenAI-compatible HTTP clients (hull_core.providers.openai_spec).
EMBEDDING_MODELS-- CSVprovider/model,...selection cho cloud embedding chain; entry dau tien active, cac entry sau la config luu (khong fallback runtime). Empty = local ONNX tu fastretrieval built-in registry.- Summary model lay tu
modelfield cua[models.chat]cell; cell chua cau hinh = summaries disabled. Summary-chain env cu khong con duoc doc. - Local (default): fastretrieval ONNX registry -- zero-config, ~570MB download on first use, 768-dim MRL truncation
- Transport + credential lay tu per-task
[models.<task>]cell trong instance config ($CRG_CONFIG_DIRhoac~/.crg/config.toml):base_url+api_key+model, plain OpenAI-spec HTTP qua hull-core, OpenRouter pre-wired default (hull config init). Env override:HULL_EMBED_API_KEY/HULL_CHAT_API_KEY. - Model-name prefix (
cohere/…,jina_ai/…,gemini/…,openrouter/…) chi chon wire detail (vd Cohereinput_type); khong chon key hay transport. Khong con per-vendor API-key env — ambient*_API_KEYvars are not read. DISABLE_LOCAL_EMBED-- skip local ONNX download;resolve_backendreturnsunavailable(not local) when no cloud chain is configured- Fixed 768-dim storage keeps the table schema valid across providers. Switching embedding MODEL changes the vector space; embeddings are tagged per provider and the cosine search restricts to the active provider, so a provider switch re-embeds rather than mixing incomparable vectors.
- Deprecated (honored one release voi warning): singular
EMBEDDING_MODEL+EMBEDDING_BACKEND(backend gio suy ra tu chain rong hay khong). Router auto-detect cu "Jina > Gemini > OpenAI > Cohere" da bo. Singular-summary-model va base-URL env vars la dead strings — khong con duoc doc.
BYO local embedding
LOCAL_EMBEDDING_MODEL-- built-in fastretrieval model ID, or a local directory containingfastretrieval-manifest.json.LOCAL_EMBEDDING_DIM-- required positive dimension for an external model ID without a manifest.LOCAL_EMBEDDING_MODEL_FILE-- ONNX file path inside a manifest-backed artifact, defaultonnx/model.onnx.LOCAL_EMBEDDING_POOLING-- explicitCLS,MEAN,LAST_TOKEN, orDISABLEDvalue for an external ID without a manifest.LOCAL_EMBEDDING_NORMALIZE-- explicit L2 normalization for an external ID without a manifest, defaulttrue.
CRG hỗ trợ reranker cục bộ opt-in qua LOCAL_RERANK_MODEL (Fastretrieval TextCrossEncoder model ID); bỏ trống nghĩa là tắt reranking, khi bật semantic search sẽ rerank pool kết quả và trả về rerank_score.
Directory artifact thiếu manifest hoặc model ID ngoài registry thiếu dimension sẽ bị từ
chối, không tự rơi về model mặc định.
Manual config example
~/.crg/config.toml:
[models.embed]
base_url = "https://openrouter.ai/api/v1"
api_key = "sk-or-..."
model = "jina-ai/jina-embeddings-v5-text-small"
[models.chat]
base_url = "https://openrouter.ai/api/v1"
api_key = "sk-or-..."
model = "minimax/minimax-m3:free"Pytest
asyncio_mode = "auto"-- KHONG can@pytest.mark.asyncio- Default timeout: 30 seconds per test
addopts = "--tb=short -q"- Coverage: 95%+ enforced
Release & Deploy
- Conventional Commits. Tag format:
v{version} - CD: PSR v10 -> PyPI; eligible stable releases -> MCP Registry
- No new public OCI publication. Historical tags remain; the Dockerfile supports source-built self-hosting only.
Pre-commit hooks
- Ruff lint (
--fix --target-version=py313) + format - ty type check
- pytest (
--tb=short -q --timeout=30) - Commit message: enforce Conventional Commits
Secrets (skret + AWS SSM)
- skret SSM namespace:
/better-code-review-graph/prod(regionap-southeast-1) - CI:
skret env -e prod --path=/better-code-review-graph/prod --format=dotenv >> $GITHUB_ENV - Local dev:
skret run -e prod -- <cmd>(uses AWS credential chain)
Luu y quan trong
- Lazy imports cho heavy deps (tree-sitter, fastretrieval, hull_core cloud clients, numpy) -- tranh startup cost
- MCP tools return structured error payloads (
{"error": ...}) and close local resources on every path. - GraphStore.upsert_edge takes EdgeInfo (fields: source, target), GraphEdge uses source_qualified/target_qualified
_make_qualified()builds qualified names asfile_path::nameorfile_path::parent.name- Supported languages: Python, TypeScript, JavaScript, Go, Rust, Java, C#, Ruby, Kotlin, Swift, PHP, C/C++, Solidity
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

