Skip to main content
A minimal guide to turning a code repository into a knowledge graph and querying it. The pipeline extracts facts such as modules, symbols, routes, storage, services, and dependencies with the external enola extractor, loads them as typed graph nodes and edges, and answers structured queries — no LLM or embedding provider involved.

Before You Start

  • Complete Quickstart to understand basic operations
  • Read Pipelines and Tasks for how a custom pipeline is assembled from tasks
  • Have the enola binary available: it is installed automatically on the first run (pinned release, checksum-verified, placed in ~/.cognee/bin), or install it yourself and point ENOLA_PATH at it
  • Set CODE_GRAPH_REPO_PATH to the repository you want to index — it defaults to the current working directory
  • No LLM Providers or embedding configuration is required: both the pipeline and SearchType.CODE are deterministic

Code in Action

What Just Happened

Step 1: Choose the Repository and Start Clean

The repository to index comes from CODE_GRAPH_REPO_PATH, falling back to the directory you run the script from. Pruning first means the graph you inspect afterwards contains only what this run extracted.

Step 2: Run the Code Graph Pipeline

get_code_graph_tasks() returns the three ordered tasks the pipeline runs: extract (run enola over the repository and map its facts to DataPoints), load the graph nodes, then load the typed relations as edges. Because nothing here calls an LLM or an embedding model, skip_connection_test=True skips the first-run provider checks so the pipeline runs without any API key.

Step 3: Query the Graph with SearchType.CODE

SearchType.CODE is driven by the structured code_query argument rather than by query_text, which stays empty here. The query_facts operation filters the extracted facts — by kinds in this case — and returns the first limit matches, so the result is a deterministic listing rather than a similarity ranking.

Step 4: Reuse the Same Shape for Other Operations

Every other operation is the same cognee.search() call with a different code_query. Take a fact id from the query_facts output above and feed it to explore to see a fact’s neighborhood, traverse to walk edges in one direction, find_path to connect two facts, or impact_analysis to see what depends on a fact. There is also a delta operation, which needs no fact id: code_query={"operation": "delta"} reports what the last ingestion changed in each repository.

Advanced Usage

get_code_graph_tasks(repo_path, index_vectors=True) also writes the extracted facts to the vector store, so semantic and LLM-backed retrievers can reach them. It is opt-in because SearchType.CODE reads the graph only; enabling it adds embedding calls and therefore needs an embedding provider configured.
Graph paths only exist inside a single dataset. To follow paths across repositories, generate one Enola append/multi-repository snapshot covering all of them and ingest that into one dataset. Repositories indexed into separate datasets are searched independently, and no path can connect them.
ENOLA_PATH always wins over the auto-installed binary, so point it at your own build to control the version. Setting ENOLA_AUTO_INSTALL=false disables the automatic download entirely — the run then fails with an install error instead of fetching the pinned release.

Pipelines

How tasks are orchestrated into a pipeline.

run_custom_pipeline()

The full parameter surface of the call this guide uses.

Custom Tasks and Pipelines

Write your own tasks and assemble them into a pipeline.