Overview
Thecypher tool allows you to execute custom Cypher queries against the code knowledge graph for complex structural queries that other tools can’t answer. This is a power-user tool that requires understanding the graph schema.
When to use: Complex structural queries that search/explore can’t answer. READ
gitnexus://repo/{name}/schema first for the full schema.Next step: Use context() on result symbols for deeper context.Parameters
Cypher query to executeMust be valid Cypher syntax compatible with KuzuDB.
Repository name or path. Required when multiple repos are indexed. Omit if only one repo is available.
Response
Query results formatted as a Markdown table for easy reading
Number of rows returned by the query
Graph Schema
Node Types
- File - Source files
- Folder - Directories
- Function - Functions
- Class - Classes
- Interface - Interfaces
- Method - Class methods
- CodeElement - Generic code elements
- Community - Functional areas (auto-detected)
- Process - Execution flows
Multi-Language Nodes
Use backticks for language-specific types:`Struct`- Rust, C, Go structs`Enum`- Enumerations`Trait`- Rust traits`Impl`- Rust implementations
Relationships
All edges use a single CodeRelation table with atype property:
Relationship type:
CONTAINS- Folder contains file, file contains functionDEFINES- File defines a symbolCALLS- Function calls another functionIMPORTS- File imports from another fileEXTENDS- Class extends another classIMPLEMENTS- Class implements an interfaceMEMBER_OF- Symbol belongs to a communitySTEP_IN_PROCESS- Symbol is a step in an execution flow
Edge Properties
Relationship type (see above)
Confidence score (0-1) for fuzzy relationships
Human-readable explanation for the relationship
Step number for STEP_IN_PROCESS relationships
Example Queries
Find Callers of a Function
Find Community Members
Trace a Process
Find All Functions in a File
Find Unused Functions
Find Call Chains (2 Hops)
Find Classes Implementing an Interface
Find Hot Paths (Most Called Functions)
Find Cross-Module Dependencies
Find Files with No Tests
Example Usage
Basic Query
Process Trace Query
Multi-Repo Query
Example Response
| a.name | a.filePath |
|---|---|
| loginHandler | src/auth/login.ts |
| apiMiddleware | src/api/middleware.ts |
| testHelper | src/tests/helpers.ts |
Important Notes
Community vs Process
- Community: Auto-detected functional area (Leiden algorithm) — groups related code
- Process: Execution flow trace from entry point to terminal — shows how code runs
heuristicLabel (not label) for human-readable community/process names.Real-World Examples
Example 1: Finding Circular Dependencies
Example 2: Architecture Analysis
Example 3: Debugging Entry Points
Best Practices
Read the schema first
Read the schema first
Always
READ gitnexus://repo/{name}/schema before writing Cypher queries to understand available node types and relationships.Use relationship filters
Use relationship filters
Always filter CodeRelation edges by type:
[:CodeRelation {type: 'CALLS'}]. The graph has many relationship types.Limit result size
Limit result size
Add
LIMIT clauses to large queries to avoid overwhelming responses. Start with LIMIT 10 or LIMIT 20.Order results
Order results
Use
ORDER BY to make results more readable. Common orderings: line number, name, count aggregations.Use heuristicLabel for communities
Use heuristicLabel for communities
When querying Community or Process nodes, use
heuristicLabel (not label) for human-readable names.Follow up with context()
Follow up with context()
After finding symbols with Cypher, use
context() to get full relationship details and process participation.Common Patterns
Pattern: Find Dependencies
Pattern: Find Dependents
Pattern: Count Relationships
Pattern: Path Traversal
Use Cases
- Custom impact analysis: Beyond what
impact()provides - Architecture queries: “Show me all cross-module dependencies”
- Code smell detection: Find circular dependencies, unused code
- Process analysis: Trace specific execution flows
- Dependency mapping: Build custom dependency graphs
- Metrics: Count relationships, measure complexity
Limitations
Related Tools
- query - Simpler semantic search for most use cases
- context - Follow up on Cypher results for full context
- impact - Pre-built blast radius analysis
Related Resources
gitnexus://repo/{name}/schema- READ THIS FIRST - Full graph schemagitnexus://repo/{name}/clusters- Browse communities for query targetsgitnexus://repo/{name}/processes- Browse processes for query targets