# Codebase indexing

### Deterministic codebase indexing

Most code tools that use LLMs rely on vector embeddings. Embeddings are an approximate way to find relevant code by similarity. They're useful but imprecise, and they don't reflect actual code structure.

Kerno indexes deterministically using [SCIP](https://github.com/sourcegraph/scip) (Source Code Intelligence Protocol). SCIP resolves symbols and cross-references in your codebase, so every function call, import, and variable reference gets a precise location that's reproducible across runs.

The result is a graph that's exact, not approximate. When Kerno asks "what calls this function?" or "which endpoint uses this model?", the answer is precise.

The index stays local. Relevant code excerpts are sent to LLM providers only when Kerno needs them to reason about a specific task. See [Security & Privacy](/docs/references/security-and-privacy.md).

```mermaid
   flowchart TD
       src["src/"]
       src --> routes["routes/"]
       src --> services["services/"]
       src --> models["models/"]

       routes --> userRouter["userRouter.ts"]
       services --> userService["userService.ts"]
       models --> userModel["userModel.ts"]

       userRouter --> createUser["POST /users"]
       userRouter --> getUser["GET /users/:id"]
       userService --> hashPassword["hashPassword()"]
       userService --> dbQuery["db.query()"]
       userModel --> emailField["email: string"]
       userModel --> idField["id: string"]
```

### What this means for you

A deterministic graph means three things.

* **Reliable blast-radius detection.** When you change code, Kerno knows exactly which endpoints, scenarios, and dependencies are affected. No false negatives.
* **No hallucinated context.** When Kerno asks an LLM to plan a scenario or update a baseline, it sends real code references, not similarity matches.
* **Faster updates.** Re-indexing on a code change takes a few seconds even on a large codebase because the graph updates incrementally.

### What gets indexed

Kerno indexes the git-tracked source files in your project, including application code, configuration, and build files. Files that are not tracked by git (dependency directories, build outputs, anything in `.gitignore`) are skipped automatically.

### Index updates

Kerno indexes your codebase on first use. After that, your AI coding agent syncs the workspace after code changes, so Kerno always runs against the latest version of your code.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kerno.gitbook.io/docs/core-concepts/codebase-indexing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
