Deep Dive

Powerful features for codebase intelligence

Every tool you need to understand, query, edit, and optimize your codebase.

Architecture

Source Code
PythonTypeScriptJavaScriptRustJavaCC++LuaC#GoPHPDartScala
Tree-sitter AST Parsing
Language-agnostic abstract syntax tree analysis
Knowledge Graph (Memgraph)
15 Node Types
ProjectPackageFolderFileModuleClassFunctionMethodInterfaceEnumTypeUnionModuleInterfaceModuleImplementationExternalPackage
15 Relationship Types
CONTAINS_PACKAGECONTAINS_FOLDERCONTAINS_FILECONTAINS_MODULEDEFINESDEFINES_METHODIMPORTSEXPORTSEXPORTS_MODULEIMPLEMENTS_MODULEINHERITSIMPLEMENTSOVERRIDESCALLSDEPENDS_ON_EXTERNAL
RAG System
NL → Cypher → Results → AI Response

Tree-sitter AST Parsing

Robust, language-agnostic parsing using Tree-sitter grammars. Extracts functions, classes, modules, imports, and call relationships with full source location tracking.

LanguageStatusExtensions
PythonFully Supported.py
TypeScriptFully Supported.ts, .tsx
JavaScriptFully Supported.js, .jsx
RustFully Supported.rs
JavaFully Supported.java
CFully Supported.c
C++Fully Supported.cpp, .h, .hpp, .cc, .cxx, .hxx, .hh, .ixx, .cppm, .ccm
LuaFully Supported.lua
C#Fully Supported.cs
GoFully Supported.go
PHPFully Supported.php
DartFully Supported.dart
ScalaIn Development.scala, .sc

Knowledge Graph Architecture

Your codebase stored as an interconnected graph in Memgraph. Nodes represent code entities, edges represent relationships like calls, imports, contains, and inherits.

Nodes: Function, Class, Module, File, Package
Edges: CALLS, IMPORTS, CONTAINS, INHERITS, IMPLEMENTS, FLOWS_TO
Properties: name, file_path, line_number, source_code, language

Natural Language Querying

Ask questions in plain English. The AI translates your intent into Cypher queries, executes them against the graph, and returns human-readable answers.

# Natural Language Queries
> "What functions call the authenticate method?"
> "Show me all classes that implement the Logger interface"
> "Find functions with more than 50 lines in the auth module"
> "What are the dependencies between the payment and user modules?"

AI-Powered Code Editing

Surgical code replacement that targets specific functions using AST analysis. Preview diffs before applying changes with exact code block modifications.

# Surgical Code Replacement
> surgical_replace_code(
file_path="auth/login.py",
target_code="...existing block...",
new_code="...updated code..."
)
✓ Replaced code block in auth/login.py (lines 42-51)

Interactive Code Optimization

AI analyzes your codebase with language-specific best practices. Review each suggestion interactively and apply with confidence.

# AI-Powered Optimization
$ cgr optimize python --repo-path ./auth
Suggestions:
1. [auth/login.py:42] Add rate limiting to authenticate_user
Impact: HIGH | Type: Security
[Accept] [Reject] [Modify]
2. [auth/token.py:15] Use constant-time comparison for token validation
Impact: HIGH | Type: Security
[Accept] [Reject] [Modify]

Dead Code Detection

Find functions and methods unreachable from any entry point by walking CALLS and REFERENCES edges from roots. CI-friendly with --fail-on-found.

# Find code unreachable from any entry point
$ cgr dead-code --fail-on-found
Dead code candidates (3):
auth/legacy.py:12 validate_md5_token (function)
api/v1/users.py:88 UserSerializer.to_xml (method)
utils/compat.py:5 py2_urlencode (function)
Exit code 1 (CI gate triggered)

Semantic Code Search

Find functions by describing what they do. Search by intent rather than exact names.

# Semantic Search — find by intent, not by name
> semantic_search("error handling functions")
Found 5 results for "error handling functions":
1. auth.exceptions:handle_auth_error (score: 0.923)
2. api.middleware:error_handler (score: 0.891)
3. db.retry:handle_connection_failure (score: 0.847)
4. payments.stripe:handle_webhook_error (score: 0.812)
5. utils.logging:log_and_reraise (score: 0.798)
> semantic_search("user authentication and login")
Found 3 results:
1. auth.login:authenticate_user (score: 0.951)
2. auth.token:verify_jwt_token (score: 0.887)

MCP Server / Claude Code

Full MCP server integration with 13 tools available directly in Claude Code. Index, query, edit, and search without leaving your terminal.

list_projectsdelete_projectwipe_databaseindex_repositoryupdate_repositoryquery_code_graphget_code_snippetsurgical_replace_coderead_filewrite_filelist_directorysemantic_searchask_agent

Graph Export & Real-Time Updates

Export your knowledge graph data for external analysis. The graph updates in real-time as your codebase changes — re-parse to capture the latest structure.

{
"nodes": [
{
"node_id": 0,
"labels": ["Module"],
"properties": {
"qualified_name": "auth.login",
"name": "login",
"path": "auth/login.py"
}
},
{
"node_id": 1,
"labels": ["Function"],
"properties": {
"qualified_name": "auth.login:authenticate_user",
"name": "authenticate_user",
"decorators": []
}
},
{
"node_id": 2,
"labels": ["Class"],
"properties": {
"qualified_name": "auth.login:AuthService",
"name": "AuthService",
"decorators": []
}
}
],
"relationships": [
{
"from_id": 0, "to_id": 1,
"type": "DEFINES",
"properties": {}
},
{
"from_id": 1, "to_id": 5,
"type": "CALLS",
"properties": {}
}
],
"metadata": {
"total_nodes": 1247,
"total_relationships": 3891,
"exported_at": "2025-01-15T10:30:00+00:00"
}
}

Extensible Language Support

Adding a new language is straightforward thanks to the unified Tree-sitter architecture. Each language parser produces the same graph schema, so all query and editing tools work automatically with new languages.