Skip to main content

Overview

The cypher 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

string
required
Cypher query to executeMust be valid Cypher syntax compatible with KuzuDB.
string
Repository name or path. Required when multiple repos are indexed. Omit if only one repo is available.

Response

string
required
Query results formatted as a Markdown table for easy reading
number
required
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 a type property:
string
Relationship type:
  • CONTAINS - Folder contains file, file contains function
  • DEFINES - File defines a symbol
  • CALLS - Function calls another function
  • IMPORTS - File imports from another file
  • EXTENDS - Class extends another class
  • IMPLEMENTS - Class implements an interface
  • MEMBER_OF - Symbol belongs to a community
  • STEP_IN_PROCESS - Symbol is a step in an execution flow

Edge Properties

string
required
Relationship type (see above)
number
Confidence score (0-1) for fuzzy relationships
string
Human-readable explanation for the relationship
number
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

Rendered:

Important Notes

Single Relationship TableAll relationships use a single CodeRelation table with a type property. Always filter relationships using {type: 'CALLS'} syntax, not separate relationship types.Correct:
Incorrect:
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
Use 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

Always READ gitnexus://repo/{name}/schema before writing Cypher queries to understand available node types and relationships.
Always filter CodeRelation edges by type: [:CodeRelation {type: 'CALLS'}]. The graph has many relationship types.
Add LIMIT clauses to large queries to avoid overwhelming responses. Start with LIMIT 10 or LIMIT 20.
Use ORDER BY to make results more readable. Common orderings: line number, name, count aggregations.
When querying Community or Process nodes, use heuristicLabel (not label) for human-readable names.
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

Performance ConsiderationsComplex path queries (*1..5) on large codebases can be slow. Start with small hop counts and add LIMIT clauses.
  • query - Simpler semantic search for most use cases
  • context - Follow up on Cypher results for full context
  • impact - Pre-built blast radius analysis
  • gitnexus://repo/{name}/schema - READ THIS FIRST - Full graph schema
  • gitnexus://repo/{name}/clusters - Browse communities for query targets
  • gitnexus://repo/{name}/processes - Browse processes for query targets