Lesson 12 of 28Writing that engineers read
READMEs and Docs People Use
Write READMEs whose quickstart works, sort docs with Diátaxis, keep them in the repo and reviewed, write runbooks for bad nights, and stop docs going stale.
The last unit showed how much time goes on reading code nobody explained. This unit is about the writing that saves that time. It is your first day. The README says to run npm install && npm start. The install fails on a Node version mismatch, the start fails on a missing DATABASE_URL, and the fix is in a Slack thread from last March. By lunch you have asked three people for help, and each of them has lost twenty minutes. Every team pays this tax with every new hire, every on-call shift and every team that integrates with their service. Good docs are one of the cheapest ways to make a whole team faster, and writing them well is a skill that gets you noticed early, because almost nobody does it.
Who reads your docs, and when
Docs fail when they are written for the person who wrote them. Before you write anything, picture the reader and their situation.
- The new joiner has a fresh laptop and no context. They need a path from clone to running app that works without asking anyone.
- The on-call engineer is woken at 3 a.m. by an alert. They need the next step, fast, with commands they can copy.
- Another team wants to call your API. They need the contract: endpoints, auth, errors, limits.
- The future maintainer, often you in a year, wants to know why it was built this way before they change it.
Each reader wants a different kind of document. Trying to serve all four in one page is how you get a 3,000-word README nobody finishes.
The anatomy of a README
The README is the front door of a repo. It is the first file people see on the code host and the first thing a coding assistant reads. Its job is to orient, get someone running, and point to everything else.
# invoices-api
Creates, sends and tracks customer invoices. Called by the web app and the
nightly dunning job. Owned by the Billing team (#team-billing).
## Quickstart
Requires Docker and [uv](https://docs.astral.sh/uv/). Python is pinned in
`.python-version` and installed by uv.
```bash
cp .env.example .env
make setup # installs deps, starts Postgres, runs migrations, seeds data
make dev # http://localhost:8000/docs
```
## Common commands
| Command | What it does |
| ------------ | ---------------------------------- |
| `make test` | Unit and integration tests |
| `make lint` | Ruff and mypy |
| `make reset` | Drop and recreate the local DB |
## Configuration
All settings come from environment variables. See `.env.example` for every
variable with a safe local default. Production values live in the secrets
manager, never in this repo.
## Architecture
One FastAPI service, one Postgres database, one worker. See
[docs/architecture.md](docs/architecture.md) and the decisions in
[docs/adr/](docs/adr/).
## Troubleshooting
**`connection refused` on port 5432**: Postgres is not running. Run `make db`.
## Owners
Billing team, #team-billing. On-call runbooks: [docs/runbooks/](docs/runbooks/).Notice what each part does:
- Two lines of what and why. What the service does, who uses it, who owns it. A reader knows in ten seconds whether they are in the right place.
- A quickstart that is a script, not a story. Three commands, with prerequisites stated up front.
- Common commands in a table. People come back to the README for these more than anything else.
- Configuration by reference.
.env.exampleis the source of truth, so the README does not drift from it. - Links out for depth. Architecture, decisions and runbooks live in their own files. The README points to them.
- Owners. Who to ask is the most valuable fact in the file, and the one most often missing.
A quickstart that works on a clean machine
The quickstart is the most important section and the most likely to be broken. It works for the author because their laptop has the right Node version, a database left running from last month, and an environment variable set in their shell profile three years ago. None of that is in the README.
Make it reproducible:
- Pin tool versions in files the tools read:
.nvmrcor.node-version,.python-version, thepackageManagerfield inpackage.json. "Use Node 22" in prose is a wish; a pinned file is a fact. - Ship
.env.examplewith every variable the app reads and a safe local value for each. Missing config is the most common day-one failure. - Wrap setup in one command (
make setup,just setup,npm run setup). A script can be tested; a list of twelve steps in prose cannot. - Seed local data, so the app shows something real when it starts, not an empty screen.
- Test it like code. Some teams run the quickstart in CI on a fresh container. Others use a dev container definition so every machine starts identical. At minimum, follow it yourself on a clean checkout before you merge a change to it.
The best moment to fix a quickstart is your first week. You are the only person on the team who can still see the gaps. Make "fix what tripped me up in the README" your first pull request: it is low risk, immediately useful, and it tells the team you notice things.
Diátaxis: four kinds of docs
Diátaxis, a framework by Daniele Procida that many open source projects and companies use, says there are four kinds of documentation, because readers have four different needs. Most bad docs are two kinds mixed together.
A tutorial takes a beginner through a lesson with a guaranteed result: 'Build your first invoice end to end'. It chooses the path for them and explains little along the way.
The classic mixture is a how-to guide that stops halfway to explain the history of the auth system. The person rotating a key at 5 p.m. does not want the history. Move it into an explanation page and link to it in one line. Another is reference written as a story ("first you might want to set TIMEOUT..."), when the reader just needs a table of every variable and its default.
You do not need four folders on day one. A README plus a docs/ folder grows naturally into these four shapes. The value of Diátaxis is that when a page feels wrong, you can ask "which kind is this trying to be?" and usually find it is two.
Match each document to its Diátaxis kind.
Docs as code
The docs that stay accurate are the ones that live next to the code, in the same repo, as Markdown, changed in the same pull requests. That approach is called docs as code, and it gives docs everything code already has: history, review, ownership and CI.
- invoices-api/
- README.mdfront door: what, quickstart, commands, owners
- CONTRIBUTING.mdbranch, test and PR conventions
- .env.exampleevery config variable with a safe local default
- docs/
- architecture.mdexplanation: the big picture
- how-to/
- rotate-stripe-key.md
- add-payment-provider.md
- adr/
- 0003-use-postgres-for-jobs.mdone decision per file
- runbooks/
- high-error-rate.mdone per alert
- .github/
- CODEOWNERSwho reviews which paths, docs included
- pull_request_template.mdincludes a docs checkbox
- Review docs in PRs. A behaviour change and its doc update land together, and the reviewer checks both.
- Own them. A
CODEOWNERSentry fordocs/means somebody is asked to review every change. - Lint them in CI. A link checker (such as
lychee) catches dead links,markdownlintkeeps formatting consistent, and Vale can enforce a style guide (banned words, consistent product names). - Record decisions in ADRs. One short file per significant decision. ADRs and Async Written Updates covers how to write them.
- Publish if you need to. A static site generator such as Docusaurus or Astro Starlight can turn the same Markdown into a searchable site. Many internal repos never need more than the code host's Markdown rendering.
A link checker is simple at heart: find every link, check the target file exists, and check the heading anchor exists inside it. Here is the core of one. Run it, then fix the README text so it reports zero.
Press Run (⌘ Enter) to see what happens.Both bugs are typical. Someone renamed the ADR file and did not search for links to it, and someone guessed at an anchor. Neither shows up until a reader clicks, which is why the check belongs in CI.
Runbooks: docs for the worst moment
A runbook is a how-to guide for an operational situation, usually one specific alert. Its reader is stressed, tired and possibly new to the service. Every design choice follows from that. Being On Call covers how alerts and rotations work; here is how to write the page the alert links to.
Put the sections of a runbook for the alert 'InvoicesHighErrorRate' in the order a responder needs them.
- Tap the steps below in the right order.
Good runbooks share a few habits:
- Link the runbook from the alert itself. Nobody should have to search a wiki at 3 a.m.
- Commands are copy-paste ready, with the real service names, and flagged when they are dangerous.
- Mitigate first, diagnose later. "Roll back the last deploy" comes before "find the bug".
- Update it after every incident. The postmortem's action items often include "the runbook step 3 was wrong".
Comments, docstrings and generated reference
Not all documentation is prose in a docs/ folder. Clean Code covers the rule for comments: they explain why, because the code already says what. Two other kinds sit closer to the code.
Docstrings document the public surface: what a function or class does, its parameters, what it returns and raises. In Python this follows PEP 257, usually in Google or NumPy style. In TypeScript it is TSDoc or JSDoc comments, which editors show on hover. Write them for anything other people call. Skip them for a private helper whose name says it all.
Generated reference is built from the code, so it cannot drift. FastAPI generates an OpenAPI schema and interactive docs from your route signatures and models. TypeDoc does the same from TypeScript types, and Sphinx or mkdocstrings from Python docstrings. If you find yourself hand-writing a table of endpoints, generate it instead.
The strongest form is examples that run. Python's doctest executes the examples in docstrings and checks their output. Run this one: an example in the docs has caught a real bug.
Press Run (⌘ Enter) to see what happens.The docs promise that "0.5" means 50 cents, and the code returns 5, because "5" after the dot is read as five pence. Change the last line of parse_price to use int(pence.ljust(2, "0")) and run it again. Examples that run cannot quietly go stale.
What does this print?
pounds, _, pence = "0.5".partition(".")
print(int(pounds) * 100 + int(pence or 0))Keeping docs fresh
Wrong docs are worse than missing docs. Missing docs send people to ask someone. Wrong docs send them confidently down the wrong path, and teach them to distrust every other page.
- Put a docs checkbox in the PR template: "Docs updated, or not needed". It costs a second and catches the obvious misses.
- Keep docs close to what they describe. A how-to in the repo next to the code gets updated. A wiki page three clicks away does not.
- Give pages owners, and for important ones a "last reviewed" date, so stale pages are visible.
- Delete aggressively. An outdated page should be fixed or removed, not left with a "may be out of date" banner that everyone ignores.
- Treat questions as doc bugs. When someone asks in chat a question the docs should answer, answer with a link. If there is no link to give, write the page, then send the link.
Writing people can scan
Readers skim. They read the heading, the first sentence and any code block, then decide whether to keep going. Write for that.
- Lead with the answer. "To rotate the key, run
make rotate-key." Then the details. - Short sentences, active voice. "The job retries three times" beats "Retrying is performed by the job up to a maximum of three times".
- Headings that name tasks or questions: "Rotate the Stripe key", not "Key management considerations".
- Numbered steps for procedures, one action per step.
- Real examples with real values. One working command teaches more than a paragraph about flags.
- One name per thing. If it is a "workspace" in the UI, do not call it a "tenant" in the docs and an "org" in the API section.
- Cut "simply" and "just". If it were simple for the reader, they would not be reading the docs.
- README
- The front-door document of a repo: what it is, a quickstart, common commands, configuration, links and owners.
- quickstart
- The shortest path from a clean checkout to a running app, ideally one or two commands.
- Diátaxis
- A framework that sorts docs into tutorials, how-to guides, reference and explanation, by what the reader needs.
- docs as code
- Keeping docs as plain text in the repo, changed in pull requests, reviewed, owned and checked in CI like code.
- runbook
- Step-by-step instructions for an operational situation, usually one alert, written for a stressed responder.
- docstring
- Documentation attached to a function, class or module in the code, shown by editors and used to generate reference docs.
- doctest
- Examples in documentation that are run as tests, so the docs fail CI when they stop being true.