---
title: "Test the docs in the build · Agent Wranglers"
url: https://agentwranglers.se/playbook/engineering/documentation/tested-docs
updated: 2026-10-20
licence: "All rights reserved"
---

# Test the docs in the build

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Documentation](https://agentwranglers.se/playbook/engineering/documentation)
- Rule: Check every link in the docs and run every code sample as a test in CI.
- How: Run a link checker, such as lychee or markdown-link-check, over the docs on every pull request. Check outside links in a weekly run, so another site's outage never blocks a merge. Run code samples with the language's own tool, such as Python doctest, Go example functions or Rust doc tests. For other languages, extract the fenced blocks and run them in a test. A sample that cannot run, such as a fragment, gets a marker that skips it.
- Check: Add a broken internal link and a sample whose output is wrong on a branch. CI fails on both.

Example:

```python
def order_total(prices: list[int]) -> int:
    """Return the sum of prices in cents.

    >>> order_total([1250, 400])
    1650
    """
    return sum(prices)
```

```go
func ExampleOrderTotal() {
	fmt.Println(OrderTotal([]int{1250, 400}))
	// Output: 1650
}
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers engineering playbook: https://agentwranglers.se/playbook/engineering/documentation/tested-docs`.

- Previous: [Keep a changelog written for users](https://agentwranglers.se/playbook/engineering/documentation/user-changelog)
- Next: [Draw diagrams as code](https://agentwranglers.se/playbook/engineering/documentation/diagrams-as-code)
- [Documentation](https://agentwranglers.se/playbook/engineering/documentation)
