Graph-backed code intelligence for Hermes Agent — powered by codebase-memory-mcp
Replaces grep/search_files with structural graph queries that understand your code's architecture — functions, classes, call chains, packages, routes. 158 languages. Sub-ms queries. 120x fewer tokens.
Hermes ships with search_files (regex grep) and read_file (raw text). Those match comments, strings, and formatting equally. This plugin adds:
- Structural search — find by label (Function, Class, Route), name pattern, file scope, degree
- Call graph traversal — who calls what, across files and packages (import-aware, type-inferred)
- Architecture overview — languages, packages, entry points, Louvain clusters in one call
- Dead code detection — functions with zero callers
- Impact analysis — blast radius of your current git diff
- Cypher queries — read-only graph query language for complex analysis
The result: 120x fewer tokens for code navigation tasks and zero false-positive matches.
Install codebase-memory-mcp: No manual install needed. The plugin auto-downloads the binary on first use.
hermes plugins install Galaxy-VN/hermes-cbm-plugin
hermes plugins enable cbmThat's it. No MCP config, no binary install — the plugin handles everything.
| Tool | What it does | Replaces |
|---|---|---|
cbm_index |
Index a repository into the graph | — |
cbm_search |
Structural search by label, name, degree | search_files / grep |
cbm_search_code |
Graph-augmented grep (deduplicates into functions). Supports regex=true for alternation patterns |
search_files |
cbm_trace |
Call graph BFS traversal (callers/callees) | grep for function calls |
cbm_architecture |
Languages, packages, clusters, hotspots | Manual exploration |
cbm_query |
Cypher-like graph queries | Complex grep chains |
cbm_code_snippet |
Read source for a specific symbol | read_file on whole file |
cbm_dead_code |
Find functions with zero callers | grep + manual analysis |
cbm_changes |
Map git diff to affected symbols | Manual impact analysis |
cbm_schema |
Graph schema (node/edge counts) | — |
cbm_projects |
List indexed projects | — |
cbm_delete |
Remove a project from the graph | — |
The plugin automatically injects hints into built-in tool descriptions:
search_files→ "PREFER cbm_search_code for code-level search"read_file→ "PREFER cbm_architecture / cbm_search for codebase understanding"
No prompt changes needed — the model naturally prefers the graph tools.
After enabling, load the skill for detailed usage guidance:
skill_view("cbm:cbm-intelligence")
Note: The skill lives inside the plugin's skills/ directory. If skill_view doesn't find it, ensure the skills/ directory was copied during installation (see Troubleshooting).
/cbm status → Show CBM binary status, indexed projects
/cbm index → Index the current project
/cbm search → Search the knowledge graph
/cbm trace → Trace call paths
/cbm arch → Architecture overview
/cbm dead → Find dead code
/cbm projects → List indexed projects
/cbm clear → Remove a project
/cbm help → Show usage
The plugin forces cbm into every subagent's default toolsets, so delegate_task spawns automatically get graph-backed code intelligence. Steering hints are injected into child prompts.
The plugin auto-indexes the current project on session start (git repos only). To disable:
# Not currently configurable via config.yaml — remove the on_session_start hook
# by editing __init__.py if needed.The plugin downloads codebase-memory-mcp from GitHub releases on first use. Binary is stored at:
- Linux/macOS:
~/.local/bin/codebase-memory-mcp - Windows:
~/.local/bin/codebase-memory-mcp.exe
To use a custom binary, add it to PATH before starting Hermes.
__init__.py ← Plugin registration, steering, hooks, toolset injection
schemas.py ← Tool schemas (what the LLM sees)
tools.py ← Tool handlers (subprocess calls to CBM CLI)
cli.py ← /cbm slash command handlers
auto_index.py ← Auto-indexing logic (git repo detection, project naming)
skills/
cbm-intelligence/
SKILL.md ← Bundled skill with usage guidance
tests/
test_cbm_plugin.py ← Unit tests
User: "What calls ProcessOrder?"
Agent calls: cbm_trace(function_name="ProcessOrder", direction="inbound")
CBM binary: executes graph query, returns structured results
Agent: presents the call chain in plain English
The plugin wraps the codebase-memory-mcp CLI as native Hermes tools. The binary does all the heavy lifting (tree-sitter parsing, graph storage, query execution). The plugin adds steering, auto-indexing, and Hermes integration.
| Approach | Tokens | Notes |
|---|---|---|
| 5 grep/read cycles | ~412,000 | File-by-file exploration |
| 5 CBM queries | ~3,400 | Graph-backed exploration |
| Savings | 99.2% | Structural queries replace brute-force |
158 languages via vendored tree-sitter grammars. Full Hybrid LSP type resolution for: Python, TypeScript, JavaScript, JSX, TSX, PHP, C#, Go, C, C++, Java, Kotlin, Rust, Perl.
MIT
The plugin's skills/ directory must exist at ~/.hermes/plugins/cbm/skills/. If missing:
# Copy from source repo
cp -r skills/ ~/.hermes/plugins/cbm/skills/Then restart Hermes. The skill registers via ctx.register_skill() in __init__.py.
Set regex=true — the pipe is matched literally by default:
cbm_search_code(pattern="foo|bar", regex=true)
Use Method label, not Function:
cbm_query(query="MATCH (f:Method)-[:CALLS]->(g:Method) WHERE f.name = 'main' RETURN g.name")