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: Draw the Architecture and Read the Insights

The architecture operation rolls symbol-level edges up to the modules that declare them and returns a ready-to-render diagram alongside the nodes — Mermaid by default, Graphviz with "diagram": "dot". The insights operation returns the findings enola’s explainers produced over the same graph, each with the evidence facts behind it; min_confidence separates the structural findings that always score 1.0 from the heuristic ones below it.

Step 5: 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. query_facts also filters on a fact property with prop and prop_value; the dependency example above lists the packages declared in the repository’s manifests. There is also a delta operation, which needs no fact id: code_query={"operation": "delta"} reports what the last ingestion changed in each repository. Every operation’s full argument list, defaults, and the fact kinds a query can filter on are in the SearchType reference.

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.
A GitHub/GitLab repository URL passed to plain add() or remember() — with no content_type — is recognised as a repository by its shape, shallow-cloned, and ingested as one code-repo item that takes the same code graph route, plus the repository’s own documents:
Use remember(url, content_type="code") instead when you want only the code graph (no repository documents), several repositories in one call, or repo_credentials for a private remote. Clones land under COGNEE_REPOS_DIR (default ~/.cognee/repos) either way, and both paths need git on PATH and ALLOW_HTTP_REQUESTS enabled. Deeper forge URLs (/blob/, /tree/, /issues, GitLab’s /-/ pages) are still treated as web pages; see add() for the exact detection rules.
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.
recall() reaches the same deterministic operations without assembling a search() call. The "code" scope is explicit opt-in — neither "auto" nor "all" includes it — and code_query takes the same operation dict this guide uses:
Omitting code_query runs explore seeded with the query text, and entries come back with source="code", so a scope=["graph", "code"] call keeps the two lanes apart in the results. For the full parameter behavior, see recall().
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. For the exact release URL, the pinned version, the cache path, and the supported platform builds, see Where the enola binary comes from.

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.