Architecture decision records
The code shows what you built; it never says why. Learn the one-page record that keeps the reason, the options you rejected and when to think again, and why you never rewrite it.
The lesson in text
Click a paragraph to hear it.01Why is this here?
Monday, 10:30. Theo joined StayHub two weeks ago. He opens a pull request: delete the outbox table. To him, it looks like complexity nobody uses.
Omar replies within a minute. That table is why we stopped losing bookings. In the spring, nine bookings vanished, and two hotels resold rooms that were already taken. Theo answers: how was I supposed to know? I searched the docs.
There was nothing to find. This quarter, the team made six big architecture decisions, and none of them was written down. Three engineers spent two hours in the chat, digging through old threads to explain one table.
In this lesson, you'll learn the cheapest fix in software architecture: a one-page note called an architecture decision record, or ADR. What goes in it, when to write one, and how it stops your team, and your AI coder, from undoing good decisions.
02The ship's logbook
Think of a ship's logbook. Every day, the captain writes down what happened, and why. Changed course to the south, because a storm is coming from the west.
When the weather changes, she doesn't rub out yesterday's entry. She writes a new one: back on the old course, the storm has passed. The old entry stays exactly as it was.
So a new captain can open the book and follow every turn, and the reason for each one. Nobody has to guess why the ship went south in March.
That's what an ADR is: one entry in your project's logbook. The code shows what you built. The record keeps why, what you rejected, and what would change your mind.
| On the ship | In your project |
|---|---|
| The logbook | docs/adr/: one numbered, dated file per decision |
| One entry: "south, because of the storm" | One ADR: the decision and its reason |
| Never rub out yesterday's entry | Never edit an accepted ADR's decision |
| A new entry: "back on course, storm passed" | A new ADR that supersedes the old one |
| The next captain follows every turn | The next engineer, or agent, reads why |
03What goes in one
An ADR is short: one page, sometimes two. It lives in the code repository, next to the code, in a folder like docs/adr. Each one gets a number and a date.
It starts with the context: the situation, with numbers. For the outbox: checkout took 2.8 seconds, about fifty bookings failed a day, and nine booking events were lost. Numbers freeze what you believed, so a reader next year can check whether it's still true.
Then the decision drivers: the few things that matter most. Here: never lose a booking event, add nothing new to run, and keep checkout fast.
Then the options: at least two, and real ones. Publish the event right after saving the booking. An outbox table with a small relay. Or a managed Kafka cluster. Each with honest pros and cons, the way a sensible colleague would argue for it.
Then the decision, and its consequences, good and bad. The outbox means no lost events. But every reader of those events must handle duplicates. The bad part matters most: it's what stops the next person from deleting it.
# 0004 · Booking events go through an outboxnumber and titleStatus: Accepted · dateProposed → Accepted → (later) Superseded## Contextcheckout p95 2.8 s, ~50 failed bookings a day, 9 events lost## Decision driversnever lose a booking event; nothing new to run; fast checkout## Optionspublish right after saving · outbox + relay · managed Kafka## Decisionoutbox table in PostgreSQL, relay to our workers## Consequences+ no lost events, p95 ~0.5 s · − every reader must handle duplicates## Revisit ifa separate service reads booking events, or we pass 6 readersLast, a revisit trigger: when should we think again? Not "if needs change". Something you can check: if a separate service starts reading booking events, or if we pass six readers.
04Never rewrite the log
Every ADR has a status. It starts as proposed, and the team reviews it like code, in a pull request. People challenge the numbers and add options before anything is built.
Once the team agrees, it becomes accepted, with a date. From then on, nobody edits the decision. Not even when it's clearly out of date.
When a revisit trigger fires, you write a new ADR that says: this replaces number four. The old one changes in one place only: its status becomes superseded, with a link to the new one. Exactly like the logbook.
- 1ProposedReviewed like code, in a pull request: challenge the numbers, add options
- 2AcceptedDated. From now on, the decision is never edited
- 3SupersededA revisit trigger fired: a new ADR replaces it; only the old status line changes, with a link
Why so strict? Because the value is the trail. What did we believe, with which numbers, on which date? Rewrite it, and you hide why things changed.
05When to write one
Not every choice needs one. Picking a library to format dates doesn't. Hundreds of tiny records bury the important ones.
Write one when a decision is expensive to undo, when it crosses teams, or when someone will question it later. The outbox, the payment port, the photo function: all three. A choice that looks strange but is deliberate is the best candidate of all.
| Decision | ADR? | Why |
|---|---|---|
| Booking events through an outbox | Yes | Looks like unused complexity; removing it loses bookings |
| PaymentPort with Stripe and Adyen adapters | Yes | Crosses teams; shapes every payment change |
| Photo function capped at 50 instances | Yes | The number looks arbitrary; it protects the database |
| Which library formats dates | No | Cheap to change; nobody will ask why |
Each one takes thirty minutes to an hour. The outbox record alone would have saved two hours of digging, in a single morning.
By the end of that week, StayHub's log had seven entries. Number one: we record decisions. Then the modular monolith, the module boundaries, the outbox, the payment port, the photo function, and ports only where the rules are rich. Seven pages for a whole quarter of architecture.
0001Record architecture decisions0002A modular monolith with a worker mode0003Module boundaries, checked in CI0004Booking events go through an outbox0005A PaymentPort with Stripe and Adyen adapters0006Photo resizing on functions, capped at 500007Ports only where the rules are rich06The arbitrary number
Here's what happens without them. Remember the photo function, and its cap of fifty instances at once? A few weeks later, an engineer found that setting while trying to make thumbnails faster.
Fifty looked like an arbitrary number, and nothing in the repository explained it. So the cap was removed, with a sensible note: no reason to limit this. The reviewer didn't know the reason either, and approved.
The next Sunday evening, about 350 instances started. Each one wanted a database connection. The shared spaces ran out again, and bookings failed for six minutes.
- 1The cap of 50 looks arbitraryNothing in the repository explains it
- 2It's removed: "no reason to limit this"The reviewer doesn't know the reason either
- 3Sunday evening: ~350 instancesEach one wants a database connection
- 4Connections run out: bookings fail for 6 minutesThe same failure the cap was there to prevent
- 5Fix: ADR-0006 + a comment next to the setting# see docs/adr/0006
Nobody was careless. The reason lived in a few people's heads, and in an old chat thread. That's the real risk: not bad decisions, but good ones undone by people who couldn't see why.
The fix took half an hour: ADR number six, photo resizing on functions, with the cap and its reason. And one comment right next to the setting: see docs/adr, number six.
07Your AI coder reads them too
This matters even more with AI coders. Ask Claude Code to clean up unused code, and it may propose exactly what Theo did: nothing in the booking path reads the outbox, so let's remove it.
The reason exists, in ADR number four. But nothing told the agent to look. So add one line to your project's CLAUDE.md: before changing anything an ADR covers, read docs/adr.
Claude Code can also draft the records for you, from your notes. Give it the facts, and ask it to mark anything it isn't sure of as a to-do. Then check that it didn't invent a single number.
Before changing anything an ADR covers, read docs/adr/.so the agent finds the reason| When Claude Code drafts an ADR, check | Red flag |
|---|---|
| Every number comes from your notes | A figure you never gave it ("cut latency by 43%") |
| At least two real options | One good option and two silly ones |
| Honest consequences | Only benefits |
| A revisit trigger you can check | "If needs change" |
| A new ADR when a decision changes | An accepted ADR rewritten to match new code |
08Your job as lead
The decision itself stays yours. The agent is good at writing the page, but it can't know what your team believed, or which risk you're willing to take. You choose the option, and you own its downsides.
When you review an ADR, check four things. Real options, not one good one and two silly ones. Honest consequences, including what gets harder. A revisit trigger you can check. And a link from the code to the record.
And when a decision changes, ask for a new ADR that supersedes the old one. Never an edit.
Let's recap. The code shows what. The ADR keeps why: the context with numbers, the drivers, real options, the decision and its costs, and when to think again. Never rewrite the log; add a new entry. That's the end of this module. Next, we design whole systems, step by step.
Check yourself
0/10 answered1What is an architecture decision record (ADR)?
2Theo's pull request deletes the outbox as "unused complexity", and three engineers spend two hours in chat explaining it. What would have prevented this?
3An accepted ADR is now clearly out of date. What do you do?
4Which of these deserves an ADR?
5Which is a good revisit trigger for the outbox ADR?
6Claude Code drafts an ADR from your notes, and it says the outbox "cut latency by 43%". You never gave it that number. What do you do?
7You ask Claude Code to clean up unused code. Its plan: "remove the outbox table, nothing in the booking path reads it". ADR-0004 exists, but CLAUDE.md doesn't mention ADRs. What do you do?
8Why does an ADR list the bad consequences of the chosen option?
9Bookings failed for 6 minutes after someone removed the photo function's cap of 50. What was the real cause?
10Why should an ADR's context contain numbers, like "checkout took 2.8 seconds"?
Save your progress — create a free account
Free. No card. Your finished lessons follow you to any device, and you can ask questions in the community.
Create my free accountEvery lesson is free while we build. Lock in €9/month for later.
The first 100 members keep the founding price for as long as they stay. Reserving is free: no card, nothing is charged.
See the founding offer