# Prevent documentation drift

import { Aside, Steps } from '@astrojs/starlight/components';

<Aside type="note" title="Request access">
  Docs Agent is available to all plans, but we grant access on request. Contact support@ekline.io to request access.
</Aside>

Documentation falls behind code the moment a PR merges without a corresponding docs update. This is documentation drift — and it compounds until users file support tickets or teammates spend time figuring out what the code actually does today.

This guide sets up two safeguards that work together to catch drift automatically:

| Safeguard | When it runs | What it does |
|-----------|--------------|--------------|
| **Automatic PR review** | When a PR opens | Analyzes the diff and triggers a docs update when EkLine detects documentation impact |
| **Scheduled drift audit** | On a cadence you set | Reviews recent code activity and fixes the highest-priority undocumented change |

Together, they catch drift at the source (when a PR opens) and sweep for anything that slipped through (on a schedule).

## Before you begin

You need:

- An EkLine account with Docs Agent enabled.
- The [EkLine GitHub App connected](/agent/github-app-setup/) to at least one repository.
- At least one documentation path configured for your repository in **Settings → Organization → GitHub Integration**.

## Step 1: Verify automatic PR review is enabled

Automatic PR review is on by default. Confirm it is active for your repositories before continuing.

<Steps>
1. Go to your [EkLine Dashboard](https://ekline.io/dashboard).

2. Navigate to **Settings → Organization → GitHub Integration**.

3. Locate your documentation repository under **Documentation Repositories** and confirm the **Enable monitoring** toggle is on.

4. If the toggle is off, switch it on. EkLine saves the change immediately.
</Steps>

EkLine analyzes every non-draft pull request opened against a monitored repository and posts a comment when it detects documentation impact.

<Aside type="tip">
If this is a new installation of the GitHub App, toggle monitoring on for any repository you want to watch. Existing open PRs are not re-analyzed — the detection runs the next time a PR becomes ready for review.
</Aside>

## Step 2: See it detect a real change

The fastest way to confirm automatic PR review works is to open a pull request that changes code with documentation impact.

<Steps>
1. Open a pull request against a monitored repository. Use a change that has a clear documentation impact — for example, adding a new API endpoint, renaming a configuration option, or removing a deprecated feature.

2. Make sure the PR is **ready for review** and not a draft.

3. Wait about 30 seconds. EkLine reads the diff, title, and description, then compares the changes against your existing documentation.

4. Check the PR comments. EkLine posts one of the following:

   | Result | What it means |
   |--------|---------------|
   | No comment | Low confidence — the change likely does not affect documentation |
   | Suggestion comment | Medium confidence — EkLine recommends a docs update and includes `@ekline-ai` so you can trigger it manually |
   | Auto-trigger comment | High confidence — EkLine has already started a documentation session and links to a docs PR when ready |
</Steps>

If EkLine posts a comment, automatic drift detection is working.

<Aside type="note">
EkLine assesses each pull request once when it transitions to ready for review. Commits pushed after that point do not re-trigger the analysis. To re-assess, mention `@ekline-ai` manually in a new PR comment.
</Aside>

## Step 3: Set up a weekly scheduled drift audit

The automatic PR review catches impact as PRs open. The scheduled drift audit catches changes that merged before EkLine was connected, or changes that fell below the automatic trigger threshold.

<Steps>
1. Click **Scheduled Agents** in the left navigation.

2. Click **New Agent**.

3. In the template picker, search for and select **Docs Drift Review**.

   EkLine auto-fills the name and prompt:

   ```text
   Audit the last 30 days of GitHub activity for customer-facing
   changes that lack documentation, then fix the highest-priority gap.
   ```

4. Review the prompt. The default works for most teams. You can adjust the lookback window — for example, change `last 30 days` to `last 7 days` for a tighter weekly cadence — but leave the rest of the prompt as written.

5. Set the schedule to **Weekly** and pick a day and time. Monday morning is a common choice — it sweeps everything that shipped the previous week before your team starts new work.

6. Enable **Raise a pull request** so each run opens a PR with the documentation fix.

7. Optionally, enable **Send a Slack notification** and enter your docs channel name (for example, `docs-team`) to receive a run summary in Slack each week.

8. Click **Create Agent**.
</Steps>

The agent appears in your list and runs at the next scheduled time.

## Verify the setup

Confirm both safeguards are active:

- [ ] **Enable monitoring** is active for your documentation repository in **Settings → Organization → GitHub Integration**.
- [ ] A **Docs Drift Review** scheduled agent appears in **Scheduled Agents** with status **Enabled**.

To see the scheduled agent's output before the first scheduled run, check back after the scheduled time. Click the chevron next to the agent to expand its run history, then click the run timestamp to open the full Docs Agent session.

## Troubleshooting

| Issue | Solution |
|-------|----------|
| EkLine never comments on PRs | Verify the GitHub App is installed on the repository and **Enable monitoring** is on. The agent skips draft PRs — convert them to ready for review. |
| Auto-trigger fired but no docs PR appeared | The agent may still be processing. Wait up to a minute, then check the PR comments for a link to the EkLine session. |
| Scheduled agent shows a failed run | Click the run timestamp in run history to open the full session. Common causes: the repository is no longer accessible, or there were no code changes in the audit window. |
| Docs PR from drift review is off-target | Comment on the docs PR and mention `@ekline-ai` with feedback. The agent resumes the session and pushes corrections. |

## Next steps

- [Automatic PR review](/agent/automatic-pr-review/) — Understand the confidence tiers and what each detection level means.
- [Scheduled agents](/agent/scheduled-agents/) — Explore the full template library for recurring documentation tasks.
- [GitHub PR bot](/agent/github-integration/) — Trigger documentation sessions manually from any PR comment.
- [Create documentation](/agent/create/) — Generate READMEs, API references, and guides from your codebase.