> 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/guides/capture-a-baseline.md).

# Capture a baseline

A baseline is Kerno's record of how an endpoint behaves against your real running stack, and the reference point it uses to detect diffs on every future code change.

### Prerequisites

Before you begin, make sure you have:

* A Kerno environment running and healthy. See [Start the Environment](/docs/guides/start-the-environment.md).

### Step 1 — Generate a baseline plan

Ask your coding agent to implement a baseline for the endpoint you want to cover:

> "Use Kerno to implement a baseline for POST /users"

Kerno analyzes the endpoint's code paths and plans the scenarios it needs to test across functional behaviour, edge cases, error handling, and auth.

```mermaid
  flowchart LR
      A[Ask agent\nfor baseline] --> B[Kerno plans\nscenarios]
      B --> C[Review plan]
      C --> D{Happy?}
      D -->|No| E[Give feedback]
      E --> B
      D -->|Yes| F[Kerno implements\nand runs scenarios]
      F --> G[Baseline\ncaptured]
```

You can ask Kerno to create a baseline for a whole file or your entire app:

> "Use Kerno to implement a baseline for all endpoints in the users controller"

Kerno will resolve the right scope automatically and plan scenarios for every matched endpoint, pausing for your review before implementing.

{% hint style="info" icon="lightbulb" %}
**Tip:** Avoid targeting all endpoints if your app has a large number of them. Implementing scenarios for hundreds of endpoints at once can take several hours. Start with a specific file or controller, then expand coverage gradually.
{% endhint %}

For a full breakdown of how scopes work, see [Scopes ](/docs/references/scopes.md)reference.

### Step 2 — Review the plan

Kerno presents the plan before doing anything else. The plan lists the scenarios it will create and the behaviour each one covers.

Review it and give feedback directly: ask Kerno to adjust a specific scenario, add coverage for something missing, or skip scenarios you don't need. Kerno will regenerate the plan with your changes. Iterate until you are satisfied.

{% hint style="info" icon="lightbulb" %}
**Tip:** You can also let your coding agent review the plan and suggest improvements automatically. It will pass the feedback to Kerno and regenerate the plan without you having to do it manually.
{% endhint %}

### Step 3 — Approve and implement

Once you are satisfied with the plan, approve it. Kerno implements the scenarios and runs them against your live stack. The real responses from your stack are captured as the baseline.\
Implementation takes around 5 minutes per endpoint, but can vary: simple endpoints with few scenarios finish in a couple of minutes, while complex ones with heavy state setup and cleanup\
can take up to 10 minutes.

After implementation, ask your agent to show you the results for any scenario. You can inspect what each one returned, including the full response payloads. For more detail, the scenario files under `.kerno/scenarios/` show the full implementation: requests, assertions, state setup, and cleanup steps.

{% hint style="info" icon="lightbulb" %}
**Tip:** This operation run in the background. Avoid asking your agent for status updates every few seconds. Just wait for it to confirm completion.
{% endhint %}

{% hint style="warning" %}
If you want to modify a scenario, ask your agent to regenerate it with your feedback. Do not edit the scenario implementation code directly. Kerno will overwrite it on the next run.
{% endhint %}

### What's next

Now that you have a baseline, you're ready to start validating changes. Every time your coding agent modifies an endpoint, Kerno will run the relevant scenarios against your real stack and report any diffs against the baseline. See [Validate code changes](/docs/guides/validate-code-changes.md) to learn how.

### Resources

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><i class="fa-comment-question" style="color:$info;">:comment-question:</i> <strong>Support</strong></td><td>Get help from the Kerno team.</td><td><a href="https://discord.gg/UncXsxUz">https://discord.gg/UncXsxUz</a></td></tr><tr><td><i class="fa-lightbulb" style="color:$info;">:lightbulb:</i> <strong>FAQs</strong></td><td>Get answers to common questions.</td><td><a href="/pages/zJKOG1wiwndWnBdcDH4o">/pages/zJKOG1wiwndWnBdcDH4o</a></td></tr><tr><td><i class="fa-shield-check" style="color:$info;">:shield-check:</i> <strong>Security</strong></td><td>Learn how Kerno handles your code and data.</td><td><a href="/pages/a868OKb6TDxWBmJlCO1H">/pages/a868OKb6TDxWBmJlCO1H</a></td></tr></tbody></table>


---

# 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, and the optional `goal` query parameter:

```
GET https://kerno.gitbook.io/docs/guides/capture-a-baseline.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
