# How Kerno works

Kerno maps your codebase, builds a test environment around it, generates a validation suite, and runs that suite on every code change to detect what changed.

{% code expandable="true" %}

```mermaid
  flowchart LR
      s1["1. Index codebase"] --> s2["2. Set up environment"] --> s3["3. Build baseline"] --> s4["4. Validate changes"] --> s5["5. Update baseline"]
```

{% endcode %}

{% stepper %}
{% step %}

#### Index your codebase <i class="fa-code">:code:</i>

Kerno parses every file and builds a SCIP-based dependency graph that maps every function, class, and endpoint to the code that produces it. The graph is stored locally and used to scope every validation to exactly the affected endpoints. See [Codebase indexing](/docs/core-concepts/codebase-indexing.md).
{% endstep %}

{% step %}

#### Set up your test environment <i class="fa-docker">:docker:</i>

Kerno analyzes your build files and generates a Dockerfile and Compose plan for your app and its real dependencies (databases, queues, caches), plus mocks for external services. [See Environment setup.](/docs/core-concepts/environment-setup.md)
{% endstep %}

{% step %}

#### Build a baseline of how your app behaves <i class="fa-clipboard-check">:clipboard-check:</i>

Kerno generates test scenarios for each endpoint covering functional behavior, edge cases, error handling, and auth. It runs them against your live stack and captures the responses as\
the baseline. This is the reference point for every future validation. See [Scenarios and baselines](/docs/core-concepts/scenarios-and-baselines.md)
{% endstep %}

{% step %}

#### Validate every change <i class="fa-vial-circle-check">:vial-circle-check:</i>

When you change code, Kerno uses the dependency graph to detect the blast radius and re-runs only the affected scenarios. It compares responses against the baseline and surfaces any diffs. If the diff is intentional, accept it and Kerno updates the baseline. If it is not, fix your code and run validation again.
{% endstep %}

{% step %}

#### Maintain everything <i class="fa-sparkles">:sparkles:</i>

As your codebase evolves, Kerno updates your environment, adds scenarios for new endpoints, retires stale ones, and heals tests when contracts change. Everything stays current without manual intervention.
{% endstep %}
{% endstepper %}


---

# 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/how-kerno-works.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.
