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.
remember(url, content_type="code", repo_credentials="<token>") clones a private https remote using an out-of-band token β€” a GitHub App installation token, for example. It is sent as HTTP basic auth under the x-access-token username, the scheme GitHub expects. The token reaches git through environment-level config rather than the URL, so nothing derived from the URL can carry it: the clone directory name, the persisted git remote, log lines, and git’s own error output all use the credential-free URL. repo_credentials is code-only β€” passing it with any other content_type raises ValueError.Credentials embedded in the URL userinfo (https://x-access-token:<token>@github.com/org/repo.git) still work, but are the legacy path. Either way, the source recorded on each result item is redacted, so a token never surfaces in a remember() result.To connect a whole organization instead of one repository at a time, see the GitHub integration.
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.