- Installation
- Claude Code Integration
- Architecture
- MCP Tools Reference
- CLI Reference
- Library API
- Configuration
- Supported Languages
- How Indexing Works
- Semantic Search
- Git Integration
- Troubleshooting
CodeXRay works with every major JavaScript package manager and runtime.
npx codexray # Zero-install, runs interactive installer
npm install -g codexray # Global installpnpm add -g codexray
pnpm dlx codexray # Zero-install equivalentyarn global add codexraybun add -g codexray
bunx codexray # Zero-install equivalentNode.js 18–24 is required. CodeXRay uses native tree-sitter bindings, glob v11, fs.promises, and ES2022 features that require Node 18+.
To check your version: node -v
CodeXRay runs as an MCP (Model Context Protocol) server. When Claude Code starts, it launches the CodeXRay server as a subprocess. Claude's explore agents can then call CodeXRay tools directly to query the code graph instead of scanning files.
npx codexrayThis interactive installer:
- Writes
~/.claude.json— adds thecodexrayMCP server entry - Sets auto-allow permissions — all 16 tools are pre-approved so Claude never asks for permission
- Handles Windows — automatically wraps
npxincmd /con Windows - Project init — optionally initializes
.codexray/and indexes the current project - CLAUDE.md — optionally writes tool usage instructions for Claude
If you prefer to configure manually, add this to ~/.claude.json:
{
"mcpServers": {
"codexray": {
"command": "npx",
"args": ["-y", "codexray", "serve"]
}
},
"autoAllowPermissions": [
"mcp__codexray__codexray_search",
"mcp__codexray__codexray_context",
"mcp__codexray__codexray_callers",
"mcp__codexray__codexray_callees",
"mcp__codexray__codexray_impact",
"mcp__codexray__codexray_node",
"mcp__codexray__codexray_deps",
"mcp__codexray__codexray_overview",
"mcp__codexray__codexray_deadcode",
"mcp__codexray__codexray_hotspots",
"mcp__codexray__codexray_files",
"mcp__codexray__codexray_status",
"mcp__codexray__codexray_semantic",
"mcp__codexray__codexray_path",
"mcp__codexray__codexray_circular",
"mcp__codexray__codexray_complexity"
]
}On Windows, use cmd /c wrapping:
{
"mcpServers": {
"codexray": {
"command": "cmd",
"args": ["/c", "npx", "-y", "codexray", "serve"]
}
}
}After adding the config, restart Claude Code for the MCP server to load.
CodeXRay works with any MCP client (Cursor, Windsurf, etc.) that supports stdio-based MCP servers. The command to start the server is:
codexray serve [path]codexray/
├── src/
│ ├── core/
│ │ ├── database.ts # SQLite graph engine, TF-IDF, FTS5
│ │ ├── indexer.ts # File discovery, parsing, watch mode
│ │ └── context.ts # Smart context builder with scoring
│ ├── parsers/
│ │ ├── registry.ts # Language detection, tree-sitter loading
│ │ └── extractor.ts # AST → symbols + edges extraction
│ ├── mcp/
│ │ └── server.ts # MCP protocol server with 16 tools
│ ├── cli/
│ │ └── index.ts # CLI + Claude Code installer
│ ├── utils/
│ │ └── config.ts # Config, git hooks, gitignore
│ └── index.ts # Public library API
Source Files → tree-sitter AST → Symbol Extraction → SQLite Graph
│
┌────────────────┼────────────────┐
▼ ▼ ▼
FTS5 Index TF-IDF Index Graph Edges
(keyword) (semantic) (calls, imports)
nodes — every extracted symbol (function, class, method, etc.)
id,kind,name,qualified_name,file_path,start_line,end_linelanguage,signature,docstring,exported,complexity
edges — relationships between symbols
source_id → target_id,kind(calls, imports, extends, implements, etc.)
files — indexed file tracking for incremental sync
file_path,hash,language,node_count,line_count
search_tokens — TF-IDF index for semantic search
node_id,token,tf(term frequency),source(name/signature/docstring)
idf_cache — inverse document frequency cache
token,idf,doc_count
nodes_fts — FTS5 virtual table for keyword search
Get a high-level project overview. Use this first when starting work on any project.
Returns: file count, languages, symbol distribution, directory structure, hotspot symbols.
Build comprehensive task-relevant context. The most powerful tool — replaces reading multiple files.
Parameters:
query(required) — task description, e.g. "fix authentication bug"maxNodes— max symbols to return (default: 25)includeCode— include source code snippets (default: true)format—markdown,json, orcompactfileFilter— only include files matching this string
FTS5 keyword search for symbols by name.
Parameters:
query(required) — symbol name or keywordkind— filter by kind (function, class, method, etc.)limit— max results (default: 20)
TF-IDF semantic search — find code by meaning, not just name.
Parameters:
query(required) — natural language descriptionlimit— max results (default: 20)
Example: Search "user authentication" and find login(), validateToken(), AuthService.
Get detailed info about a specific symbol including full source code.
Parameters:
name(required) — symbol namekind— optional kind filterincludeCode— include source (default: true)
Find all functions/methods that CALL the specified symbol.
Parameters:
name(required) — symbol namelimit— max results (default: 30)
Find all functions/methods that the specified symbol CALLS.
Parameters:
name(required) — symbol namelimit— max results (default: 30)
Get the full dependency tree — everything a symbol imports, extends, implements, or uses.
Parameters:
name(required) — symbol name
Blast radius analysis — recursive BFS tracing all transitive callers, grouped by depth.
Parameters:
name(required) — symbol namedepth— max BFS depth (default: 3)
Find the shortest connection between two symbols in the graph.
Parameters:
from(required) — source symbol nameto(required) — target symbol namemaxDepth— max search depth (default: 10)
Rank symbols by total connectivity (callers + dependencies).
Parameters:
limit— max results (default: 20)
Find unreferenced symbols — functions/classes never called or imported.
Parameters:
kinds— symbol kinds to check (default: function, method, class)exportedOnly— if false, only check non-exported symbols
Detect circular import/call dependencies using DFS.
No parameters. Returns all detected cycles up to 20.
Find functions exceeding a cyclomatic complexity threshold.
Parameters:
threshold— minimum complexity score (default: 10)
Browse the indexed file tree with per-file symbol counts.
Parameters:
filter— filter by path substringlanguage— filter by language
Index health check — total files, symbols, edges, languages, freshness.
| Command | Description |
|---|---|
codexray |
Interactive Claude Code installer |
codexray install |
Same as above (explicit) |
codexray init [path] |
Initialize project |
codexray index [path] |
Full index + semantic build |
codexray sync [path] |
Incremental sync |
codexray watch [path] |
Real-time file watching |
codexray status [path] |
Index statistics |
codexray query <q> |
FTS5 search from CLI |
codexray semantic <q> |
TF-IDF semantic search |
codexray context <q> |
Build task context |
codexray overview [path] |
Project overview |
codexray hooks <action> |
Git hook management |
codexray serve [path] |
Start MCP server |
codexray uninstall |
Remove from Claude Code |
cxr works for all commands: cxr init -i, cxr status, cxr query auth, etc.
import CodeXRay from 'codexray';
// Initialize
const cxr = await CodeXRay.init('/path/to/project', { index: true });
// Or open existing
const cxr = CodeXRay.open('/path/to/project');
// Search
cxr.search(query, kind?, limit?) // FTS5 keyword search
cxr.semanticSearch(query, limit?) // TF-IDF semantic search
// Graph traversal
cxr.getCallers(nodeId) // Who calls this?
cxr.getCallees(nodeId) // What does this call?
cxr.getDependencies(nodeId) // Full dep tree
cxr.getImpact(nodeId, depth?) // Blast radius
cxr.findPath(fromId, toId) // Shortest path
// Analysis
cxr.findDeadCode(kinds?) // Unreferenced symbols
cxr.findHotspots(limit?) // Most connected
cxr.findCircularDeps() // Circular imports
cxr.getComplexityReport(threshold?) // High complexity
cxr.getStats() // Index statistics
// Context
cxr.buildContext(query, opts?) // Smart context
cxr.formatContext(result, format?) // Format output
cxr.buildOverview() // Project overview
// Index management
await cxr.index(force?) // Full index
await cxr.sync() // Incremental sync
// Cleanup
cxr.close(){
"version": 1,
"projectName": "my-app",
"exclude": [
"node_modules/**", "dist/**", "build/**", ".git/**",
"*.min.js", "*.bundle.js", "*.lock", "*.map"
],
"maxFileSize": 1048576,
"gitHooksEnabled": true
}| Field | Default | Description |
|---|---|---|
exclude |
common patterns | Glob patterns to exclude |
maxFileSize |
1048576 (1MB) | Skip files larger than this |
gitHooksEnabled |
false | Enable post-commit auto-sync |
| Language | Extensions | Parser |
|---|---|---|
| TypeScript | .ts, .tsx |
tree-sitter-typescript |
| JavaScript | .js, .jsx, .mjs, .cjs |
tree-sitter-javascript |
| Python | .py, .pyw |
tree-sitter-python |
| Go | .go |
tree-sitter-go |
| Rust | .rs |
tree-sitter-rust |
| Java | .java |
tree-sitter-java |
| C# | .cs |
tree-sitter-c-sharp |
| PHP | .php |
tree-sitter-php |
| Ruby | .rb |
tree-sitter-ruby |
| C | .c, .h |
tree-sitter-c |
| C++ | .cpp, .hpp, .cc, .cxx |
tree-sitter-cpp |
| Swift | .swift |
tree-sitter-swift |
| Kotlin | .kt, .kts |
tree-sitter-kotlin |
Functions, methods, classes, interfaces, types, enums, structs, traits, variables, constants, modules, namespaces, React components, React hooks, routes, middleware, tests, decorators, properties.
calls, imports, extends, implements, returns_type, uses_type, has_method, has_property, contains, exports, renders, decorates, overrides, tests.
- Scan — discover all source files matching supported extensions, excluding configured patterns
- Hash — compute SHA-256 hash for each file to detect changes
- Parse — tree-sitter parses each file into an AST
- Extract — walk AST to find symbols (functions, classes, etc.) and references (calls, imports)
- Store — upsert nodes and intra-file edges into SQLite
- Resolve — match cross-file references to their target symbols (import → definition, call → function)
- TF-IDF — build semantic search index from symbol names, signatures, and docstrings
- Compare file hashes with stored values
- Re-parse only added/modified files
- Remove symbols from deleted files
- Re-resolve cross-file references
- Rebuild TF-IDF index
Uses chokidar with 300ms debouncing to detect file changes and trigger incremental sync in real-time.
CodeXRay implements TF-IDF (Term Frequency × Inverse Document Frequency) for semantic code search with zero external dependencies.
- Tokenization — splits camelCase, snake_case, dot.notation into individual words
- Term Frequency (TF) — how often a token appears in a symbol's name/signature/docstring
- Inverse Document Frequency (IDF) — how rare a token is across all symbols
- Weighted Scoring — name matches score 4x, signature 2x, docstring 1.5x, qualified name 1x
- Stop Words — common programming keywords filtered out
- Zero dependencies — no transformers.js (~500MB), no ONNX runtime, no model downloads
- Instant build — builds in <1 second for most projects vs minutes for embedding generation
- Deterministic — same query always returns same results
- No GPU needed — runs on any machine
- Sufficient quality — for code symbol search, TF-IDF with domain-aware tokenization performs comparably to embeddings
codexray hooks install # Install hook
codexray hooks remove # Remove hook
codexray hooks status # Check statusThe hook runs codexray sync in the background after each commit, keeping the index fresh without blocking your workflow.
CodeXRay automatically adds .codexray/ to your .gitignore during init. The database is local to each developer's machine.
- Verify
~/.claude.jsoncontains thecodexrayentry:cat ~/.claude.json - Fully restart Claude Code (quit and reopen, not just new conversation)
- On Windows, ensure
cmd /cwrapping is present in the args
Run codexray init --index in your project directory to create .codexray/.
tree-sitter uses native bindings that need compilation:
npm rebuild tree-sitterIf that fails, ensure you have build tools installed:
- macOS:
xcode-select --install - Ubuntu:
apt install build-essential - Windows:
npm install -g windows-build-tools
codexray index --force # Force full re-index
codexray hooks install # Enable auto-syncIncrease the exclude patterns in .codexray/config.json to skip generated code, vendored dependencies, etc.
Ensure CLAUDE.md exists in your project root with CodeXRay instructions:
codexray init --claude-mdThis tells Claude's agents to prefer CodeXRay tools over file scanning.