# When docs and code disagree, the code wins. Then fix the doc.

> Today I Learned: When docs and code disagree, the code wins. Then fix the doc.

Canonical: https://short.inc/today-i-learned/the-code-wins-over-any-document

Date: 02 nov 26
Author: Zeno Popovici

Be honest, when did you last update your README?

Give an agent a README that's out of date and it follows the README. It can't know which of the two you trust. So tell it:

```text
The code wins over any document.
When they disagree, say so and fix the document.
```

"Say so" is the half I care about. I want to hear about the disagreement, because every now and then the document is right and the code is the bug.

For that case, add this:

```text
If the answer is "the code is wrong", give me a suggested fix.
Never change the behaviour silently.
```

We ran this over one of our existing repositories. The agents fixed the outdated documents themselves and only showed us the real clashes: 15 of them, out of 72 findings. We decided all 15 the same day.
