Skip to content

Quick Start

Get from zero to querying your codebase in 5 minutes.

Step 1: Parse a Repository

Parse and ingest a multi-language repository into the knowledge graph.

cgr start --repo-path /path/to/repo1 --update-graph

cgr start --repo-path . --update-graph indexing the pallets/click repository

For additional repositories:

cgr start --repo-path /path/to/repo2 --update-graph
cgr start --repo-path /path/to/repo3 --update-graph

Two more repositories, itsdangerous and markupsafe, synced into the same graph with cgr start --update-graph

The graph is shared across projects, and syncing one leaves the others intact.

To start over from an empty graph:

cgr start --repo-path /path/to/repo1 --update-graph --clean

--clean deletes every project in the shared graph, not just the one named by --repo-path. It asks for confirmation when other projects would be lost; pass --yes to skip that prompt in scripts and CI.

cgr start --update-graph --clean asking for confirmation before deleting the other indexed project, then rebuilding requests

Control Memgraph batch flushing:

cgr start --repo-path /path/to/repo --update-graph --batch-size 5000

cgr start --update-graph --batch-size 5000 indexing pallets/flask with 5000-relationship flushes

The system automatically detects and processes files for all supported languages.

Step 2: Query the Codebase

Start the interactive RAG CLI:

cgr start --repo-path /path/to/your/repo

Specify custom models:

cgr start --repo-path /path/to/your/repo \
  --orchestrator ollama:qwen2.5-coder \
  --cypher ollama:qwen2.5-coder
cgr start --repo-path /path/to/your/repo \
  --orchestrator google:gemini-3.6-flash \
  --cypher google:gemini-3.5-flash-lite

Example queries:

  • "Show me all classes that contain 'user' in their name"
  • "Find functions related to database operations"
  • "What methods does the User class have?"
  • "Show me functions that handle authentication"
  • "List all TypeScript components"
  • "Find Rust structs and their methods"
  • "Add logging to all database connection functions"
  • "Refactor the User class to use dependency injection"

Step 3: Export Graph Data

Export during graph update (this repository's project only):

cgr start --repo-path /path/to/repo --update-graph -o my_graph.json

Export existing graph without updating (every indexed project, or one with --project-name):

cgr export -o my_graph.json
cgr export -o my_project.json --project my-project

cgr start --update-graph -o my_graph.json exporting one project, then cgr export for the whole graph and for one project

Work with exported data in Python:

from codebase_rag.graph_loader import load_graph

graph = load_graph("my_graph.json")
summary = graph.summary()
print(f"Total nodes: {summary['total_nodes']}")
print(f"Total relationships: {summary['total_relationships']}")

functions = graph.find_nodes_by_label("Function")
for func in functions[:5]:
    relationships = graph.get_relationships_for_node(func.node_id)
    print(f"Function {func.properties['name']} has {len(relationships)} relationships")

The graph_loader snippet saved as load.py and run against an exported my_graph.json

What Next?