> For the complete documentation index, see [llms.txt](https://kerno.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kerno.gitbook.io/docs/core-concepts/how-kerno-works.md).

# How Kerno works

Kerno is runtime code and security review. It builds a deep understanding of your codebase and captures how your code operates. Every time you change code, it checks the change against that baseline to catch regressions, integration issues, and security gaps.

Your agent drives Kerno over MCP. It runs inside your agent's loop, so your agent validates what it just wrote, reads the results, and fixes what broke in the same session.

{% code expandable="true" %}

```mermaid
  flowchart LR
      s1["#nbsp;1. Index your codebase#nbsp;"] --> s2["2. Connect app"] --> s3["3. Generate tests"]
      s4["4. Validate code changes"] --> s5["5. Update tests"] --> s6["6. Learn and improve "]
```

{% endcode %}

{% stepper %}
{% step %}

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

Kerno analyzes your code and builds a graph of every function, class, model, and endpoint, and how they connect. The graph is stored locally and gives Kerno the exact blast radius of any code change, so it knows how a change affects the rest of your system. See [Codebase indexing.](/docs/core-concepts/codebase-indexing.md)
{% endstep %}

{% step %}

#### Connect Kerno to your running app <i class="fa-plug">:plug:</i>

Connect Kerno to your running app, local or remote, so it can validate your code changes against your repo's real services, dependencies, and framework.. See [Environment setup](/docs/core-concepts/environment-setup.md).
{% endstep %}

{% step %}

#### Generate baseline tests <i class="fa-clipboard-check">:clipboard-check:</i>

Kerno generates test scenarios covering your endpoint's functional behavior, edge cases, and security, then runs them against your real app to capture a baseline, a snapshot of your endpoint's current behavior. See [Scenarios and baselines](/docs/core-concepts/scenarios-and-baselines.md) and [Security testing](/docs/core-concepts/security-testing.md).
{% endstep %}

{% step %}

#### Validate code changes <i class="fa-vial-circle-check">:vial-circle-check:</i>

When you change code, Kerno maps its blast radius and re-runs the affected endpoints' test scenarios against your app, comparing the results to the baseline. It shows you exactly what your change altered, so you can tell whether each difference is intended or a bug. See [Change validation](/docs/core-concepts/change-validation.md).
{% endstep %}

{% step %}

#### Update tests <i class="fa-sparkles">:sparkles:</i>

When a difference is intentional, Kerno updates the suite to match the new behaviour. It rewrites the scenarios your change affected and writes new ones for any logic you introduced, so coverage keeps pace with your code without manual upkeep.
{% endstep %}

{% step %}

#### Update tests <i class="fa-brain">:brain:</i>

Kerno's memory learns from every interaction with your team, so its testing gets more tailored to your codebase over time. Custom rules capture your team's best practices and apply them consistently across every endpoint Kerno tests. See [Custom rules](/docs/core-concepts/custom-rules.md) and [Memory and learning](/docs/core-concepts/memory-and-learning.md).
{% endstep %}
{% endstepper %}
