# How to audit existing docs against your code

Source: https://rimfe.com/guides/audit-documentation-against-code
Updated: December 2, 2026

Pull request review stops new drift. It does nothing for the pages that went wrong before you started checking. An audit reads the docs you already have against the code as it is today. Do it by hand for a small docs set, or run one on a schedule, then fix the worst pages first.

## Decide what the audit checks

A useful audit checks statements the code can confirm or refute. It does not grade style, tone or typos, and it does not try to list every missing page in the same pass. Keeping it narrow is what makes it finishable.

- Defaults, limits and timeouts stated in prose or tables.
- Flags, options, config keys and environment variables.
- Endpoints, parameters, response fields and status codes.
- Function names and signatures in code samples.
- File paths, commands and links to other pages.

## Step 1. List the pages and rank them

List every page in scope. Rank them by how much a wrong statement costs: the quickstart, installation, configuration reference and API reference come first, because readers follow them step by step. Archived versions and changelogs record history and need no audit.

```bash
# Every docs page with its line count, longest first
find docs \( -name '*.md' -o -name '*.mdx' \) -exec wc -l {} + | sort -rn
```

## Step 2. Check names mechanically first

Many wrong statements are names that no longer exist, and a shell finds those without reading a page. Compare the names the code reads with the names the docs mention. The commands below do it for environment variables in a Node project. Swap the first pattern for `os.environ`, `os.Getenv` or your language's equivalent.

```bash
# Read by the code, named on no docs page
comm -23 \
  <(grep -rhoE 'process\.env\.[A-Z0-9_]+' src | sed 's/process\.env\.//' | sort -u) \
  <(grep -rhoE '\b[A-Z][A-Z0-9]*_[A-Z0-9_]+\b' docs | sort -u)

# Named in the docs, read by no code
comm -13 \
  <(grep -rhoE 'process\.env\.[A-Z0-9_]+' src | sed 's/process\.env\.//' | sort -u) \
  <(grep -rhoE '\b[A-Z][A-Z0-9]*_[A-Z0-9_]+\b' docs | sort -u)
```

## Read the output as leads

The first list shows variables nobody documented. The second shows names the docs mention that the code never reads: renamed variables, removed ones, and some that belong to other tools, which you can ignore. Run the same comparison for CLI flags and config keys where your code defines them in one place.

## Step 3. Read the ranked pages against the code

Names are the easy half. For values and behavior, open each high-ranked page next to the code it describes. For every checkable statement, find the line that decides it: the default in the config loader, the limit in the handler, the status code in the error path. Record a finding only when you can quote both sides.

| Page and line | Docs say | Code says | Fix |
| --- | --- | --- | --- |
| `docs/configuration.md:42` | Requests time out after 30 seconds. | `timeoutMs = 10_000` in `src/http/client.ts` | Change 30 to 10 |
| `docs/cli.md:18` | `--out-dir` sets the build folder. | Flag renamed to `--output` in `src/cli/build.ts` | Rename the flag and its sample |

## Step 4. Fix in small pull requests, by owner

Group the findings by page owner and open one small pull request per area. A reviewer can check a ten-line docs diff against two quotes. A two-hundred-line cleanup across the whole site sits unreviewed. If your repository has a `CODEOWNERS` file, GitHub requests the right team on each pull request without you choosing.

## Run the audit with Rimfe

A Rimfe docs audit does steps 2 and 3 for you. It reads each docs page in scope on the default branch and compares it with the code it describes: files the page names in backticks, files your code mappings point to, and files whose names match the page's topic. It reports a conflict only when it can quote both the page and the code.

It also lists, without AI, names and local links that no longer exist, deprecated names used without a notice, wrong agent instructions, hidden instructions and stale claims. It does not report missing docs, style or typos.

1. Open the repository in the dashboard and choose the Docs audits tab.
2. Check the preview: the docs pages found and the pages this audit will check.
3. Choose Start audit. The result page updates while it runs.

## Audit limits and plans

An audit runs on your Docs tier when you have one, and otherwise on your own AI key. Each audit lists up to 150 pages and checks up to 30. Pages over 120,000 bytes are not checked. You can start one manual audit per repository a day, one at a time. When some pages are left unchecked, the result is Partial and names each page with its reason. The next audit checks those first.

|  | Hobby | Startup | Business and Enterprise |
| --- | --- | --- | --- |
| Audits per repository | Not included | 1 per month | Unlimited |
| Weekly audit | No | No | Yes |

## Turn findings into a docs pull request

On a completed audit with findings, choose Open docs PR. Rimfe fixes up to three pages, starting with those that have the most Docs conflict findings, and opens one pull request on the default branch, or on the docs repository when docs live elsewhere. Pages it cannot fix safely are listed in the description to update by hand. It does not fix other finding kinds, such as broken references and stale claims. It needs Docs PRs turned on in the repository settings, and a workspace owner or admin to ask.

Export Markdown downloads the full result, including the pages not checked, if you would rather split the work by owner yourself.

## Keep it running

An audit is a snapshot. Drift returns through dependencies that change behavior and pull requests that merged with findings open. On Business and Enterprise, turn on Weekly audit on the Docs audits tab. It skips a repository that has not changed since its last full audit, never opens a docs PR on its own, and notifies you only when it finds something. On Startup, run the monthly audit by hand.

## Common mistakes

- Auditing every page with the same care. Rank first, so the quickstart is checked before an archived migration guide.
- Mixing the audit with a rewrite. Fix what is wrong now, and plan rewrites separately.
- Recording findings without quotes. A finding you cannot quote on both sides is a hunch, and the fix will be argued over.
- Auditing once and stopping. Without pull request review in place, the same pages drift again.

## Takeaway

Rank the pages, check names with a script, read values against the code, and fix by owner in small pull requests. Then keep pull request review on so the audit stays true.

## Related

- [What is docs debt?](https://rimfe.com/learn/docs-debt)
- [What is documentation drift?](https://rimfe.com/learn/documentation-drift)
- [Docs audits](https://docs.rimfe.com/how-it-works/audits)
