Learnings

Senior engineering skills

Design Docs and Technical Writing

A design doc is how a decision gets made once, by the right people, and stays made. This page shows the shape of one, a complete worked example (moving the bank's money transfers from synchronous to queued processing), bad and better versions of the hard sections, decision records, diagrams, review, and two templates to copy. Every document, number, date and name in the examples is invented for this page.

Why and when

Part 1 of 6 · what a document buys, and when to skip it

A meeting against a document

Why and when

A decision made in a meeting lives in the memory of the people who were there. A week later each of them holds a different version.

A week after a decision made in a meeting.
A week after the same decision written down: one version, any reader, any time.
  • Writing is also the cheapest test of a design: a gap that hides in talk shows on the page.

When a design doc is worth it

Why and when

Match the writing to the cost of being wrong. A two-way door can be walked back through cheaply, a one-way door cannot.

SizeRiskReversible?Write
Under a dayLowYes, revert the commitA good pull request description
Days, one teamLow to mediumYes, two-way doorA one-pager or an ADR
Weeks, or crosses teamsMediumYes, with effortA design doc
Any sizeHigh: money, data, securityNo, one-way doorA design doc and an ADR
An urgent fix in an incidentAlready happeningNot the questionFix first, then a post-mortem

One-way doors: a data model others read, a public API, a vendor contract, anything that deletes data. Size does not matter here: a one-line schema change can be one.

The life of a design doc

Why and when

The status line at the top of the doc says where it is in this cycle. A doc without a status is assumed to be current, which is how stale designs get built.

Statuses of a design doc. A rejected doc is kept: it answers "why did we not".
StepWhoOutput
ProblemAuthor, with the people who feel itHalf a page that others agree is true
DraftAuthor, one early readerA design and at least two alternatives
ReviewNamed reviewers, with a deadlineComments, each resolved in the doc
DecisionOne named approverA dated line in the decision log
BuildThe teamThe doc updated when the design changes
ArchiveAuthorStatus "Implemented", links to the code and the runbook

Anatomy and a worked example

Part 2 of 6 · the sections, then one whole doc written out

The sections, in order

Anatomy and a worked example

The order follows the reader's questions: why, what, why this way, what can go wrong, how it ships, what was decided.

Fourteen sections in seven groups. A reader can stop after any group and still have a whole answer.
SectionQuestion it answersLengthCommon mistake
Title and statusWhat is this, and is it current?4 linesNo status, no date, no approver
Context and problemWhat hurts, for whom, how much?1 to 2 paragraphsDescribes the solution
Goals and non-goalsWhat does done look like, and what is out?3 to 5 bullets eachGoals that cannot be measured
RequirementsWhat load, latency, correctness?A small table"Fast" and "scalable" with no number
Proposed designHow does it work?1 diagram, half a pageCode-level detail, no picture
AlternativesWhat else was possible?A table, 3 to 4 rowsStrawmen, or "do nothing" missing
Trade-offsWhat do we give up?3 to 5 bulletsOnly benefits listed
Risks and mitigationsWhat could go wrong, and then what?A tableNo likelihood, no owner
Rollout and rollbackHow does it reach users, and come back?Phases with dates"Deploy to production"
Testing and observabilityHow do we know it works, today and at 3 am?5 bulletsTests only, no metrics or alerts
Security and privacyWhat new data, access or attack surface?3 bullets"N/A"
CostWhat does it cost to build and to run?2 linesRun cost forgotten
Open questionsWhat is not decided yet?A short listNo owner, no date
Decision logWho decided what, when?One line per decisionDecisions left in comment threads

Related: the first four groups are the same order as the interview framework in System Design Foundations: requirements, estimates, design, deep dives.

Example: status, context and problem

Anatomy and a worked example

The doc proposes moving the bank's transfers from synchronous to queued processing. The header says who decides and by when, and the problem is stated with numbers and no solution.

Example: goals, non-goals, requirements

Anatomy and a worked example

Each goal is a number someone can check after launch. Non-goals name the nearby work a reader would otherwise assume is included.

Note: "time to final state" gets worse on purpose, from 4.2 s to 5 s. Writing that row is what makes the trade visible before anyone builds it.

Example: the proposed design

Anatomy and a worked example

One before picture, one after picture, then a few lines for what the pictures cannot show.

Before: the client waits for the partner bank.
After: the API only records the intent. A worker does the slow part.

Example: alternatives and trade-offs

Anatomy and a worked example

Every option is scored on the same criteria, which come from the goals. The option not chosen still gets its real strength written down.

OptionG1: double debitsG2: accept p99New partsEffortVerdict
A. Do nothing, add serversStill 37 a quarter4.2 s: the partner is the limitNoneDaysFixes neither goal
B. Stay synchronous, add idempotency key04.2 s, 1.8% still time outNone2 weeksMeets G1 only. Built first, as phase 0
C. Queue with outbox and workers0About 150 msQueue, workers, relay6 weeksChosen: meets G1 to G3
D. Event log with a saga per transfer0About 150 msEvent log, saga engine4 monthsMore than three steps need. Revisit if steps grow

Example: risks, rollout, testing

Anatomy and a worked example

Each risk has a likelihood, an impact and a mitigation that already exists in the design. Each rollout phase has an exit condition and a way back.

Example: security, cost, open questions, decision log

Anatomy and a worked example

The last sections are short, and they are the ones readers come back for a year later.

Shape to copy: the whole doc is about two pages. Detail that reviewers do not need to decide (table definitions, queue settings) goes in an appendix or the pull request.

The hard sections

Part 3 of 6 · a bad and a better version of each

Problem statement: symptom or problem

The hard sections

A problem statement names who is hurt, how much and why, and contains no solution. If it names a technology, it is a solution in disguise.

BadBetter
"Transfers are slow, so we need a queue.""On salary days 1.8% of transfers time out, because the request waits up to 6 s for the partner bank."
"The transfer service does not scale.""Retries after a timeout debited 37 customers twice last quarter."

Test: could two different designs solve this statement? If only one can, rewrite it.

Goals and non-goals

The hard sections

A goal is a result you can measure after launch. A non-goal is something reasonable that a reader would expect, and that you are choosing not to do.

BadBetter
Goal"Make transfers reliable and fast.""Zero double debits. Accept p99 under 200 ms on a salary day."
Goal"Introduce a queue." (a task)"99.9% of transfers final within 30 s." (a result)
Non-goal"Rewriting the whole bank." (nobody expected it)"Scheduled transfers." (the next thing someone will ask for)

Alternatives without strawmen

The hard sections

A reviewer trusts the choice only if the losing options were given a fair hearing. Always include "do nothing" and the cheapest partial fix.

BadBetter
"We considered cron jobs. They are outdated.""A cron sweep every minute meets G1 and G2, and fails G3: final state takes up to 60 s."
One option, described three waysOptions that differ in kind: do nothing, patch, queue, event log
The rejected option has no strengths"B takes 2 weeks and meets G1. We build it first."

Interview point: "what else did you consider, and what would make you choose it?" is the most common follow-up to any design story. The alternatives table is the answer.

Trade-offs with numbers

The hard sections

A trade-off names what gets worse, by how much, and why that is acceptable. An adjective cannot be reviewed, a number can.

BadBetter
"Slightly more latency.""The final result arrives 0.4 s after the response at the median, 5 s at p99."
"Some operational overhead.""A queue and 4 workers: about 18,000 rupees a month and 2 new alerts."
"Eventually consistent.""For up to 5 s a customer can see PENDING. The balance already shows the debit."

Risks: likelihood and impact

The hard sections

Place each risk on a two by two. The cell decides how much design effort it earns.

Low impactHigh impact
LikelyAutomate it. A job that always fails: retries, then dead-letter queueDesign it out. A job delivered twice: idempotency key
UnlikelyAccept it. One line in the doc, no workDetect and rehearse. Queue outage: outbox, alert, runbook
BadBetter
"The queue might go down.""Queue outage: low likelihood, high impact. Outbox rows wait, the relay resumes. Owner: reliability."

Rollout with a way back

The hard sections

A rollout plan is a list of phases, each with an exit condition and a rollback that has been tried. Mark the point after which there is no way back.

Dotted arrows are rollback points. After the old path is deleted, rollback means a redeploy.
BadBetter
"Deploy to production in sprint 14.""Flag on for staff, then 10%, 50%, 100%. Hold each step 3 days."
"Roll back if there are issues.""Roll back if any double debit, or final state p99 over 5 s for 10 minutes. Flag off, workers drain the queue."

Decision records and diagrams

Part 4 of 6 · the smallest useful document, and pictures that explain

An ADR, worked

Decision records and diagrams

An architecture decision record (ADR) is one decision on one page, numbered, kept in the repository next to the code. It is never edited after acceptance: a later ADR supersedes it.

  • Status values: Proposed, Accepted, Rejected, Deprecated, Superseded by ADR-N.
  • Consequences list the bad ones too. That is the part a future reader needs.

ADR, design doc, RFC, one-pager, post-mortem

Decision records and diagrams

Five documents, five jobs. Teams use the names loosely, so check what yours means by "RFC" before writing one.

DocumentPurposeLengthLifetimeAudience
One-pagerAgree the problem is worth solving1 pageUntil the decision to startManager, product, leads
Design docChoose and explain one design2 to 6 pagesUpdated until shipped, then archivedReviewers, the building team
RFCAsk many teams for comment on a shared change2 to 6 pagesOpen for a fixed comment periodEveryone affected
ADRRecord one decision and its consequencesHalf a pagePermanent, never editedFuture maintainers
Post-mortemLearn from an incident1 to 3 pagesPermanent, actions trackedThe whole engineering group

Related: the shape of a blameless post-mortem is on Debugging in Production. A design doc often ends as two or three ADRs: one per decision worth keeping.

Which diagram for which question

Decision records and diagrams

Pick the diagram from the question the reader is asking. Two questions need two diagrams.

QuestionDiagramShows
Who and what does this system talk to?ContextThe system as one box, users and external systems around it
What runs, and what talks to what?Container, componentServices, databases, queues, and the calls between them
What happens, in what order?SequenceMessages between parties over time
Where does this data go?Data flowStores and processes, arrows named by the data
What states can this thing be in?StateStates and the events that move between them
Where does it run?DeploymentRegions, networks, machines, what is replicated

The C4 levels

Decision records and diagrams

C4 is four zoom levels of the same system. A design doc usually needs levels 1 and 2, and level 3 only for the part that changes.

Each level zooms into one box of the level above. Never mix levels in one picture.

Note: a C4 "container" is anything that runs or stores data (a service, a database, a queue). It does not mean a Docker container.

Five rules, and a redraw

Decision records and diagrams

The first diagram tries to show everything about transfers at once. The second answers one question: what happens to a transfer after it is accepted?

Before: machines, tables and classes in one picture, no labels on the arrows, abbreviations only the author knows.
After: one idea, one level, five boxes, every arrow says what moves.
RuleCheck
One idea per diagramYou can write its caption as one short sentence
Label the arrowsEach arrow says what moves or what is asked
A legend only if neededIf shapes or colours carry meaning, say what. Better: do not make them carry any
Same notation throughoutA box is always the same kind of thing, in every diagram of the doc
Readable at a glanceAbout 9 boxes at most, real names, no crossing lines

Writing and review

Part 5 of 6 · sentences, readers, and getting to a decision

Eight writing rules, and bottom line up front

Writing and review

These eight fix most technical writing. Apply them when editing, not while drafting.

RuleBadBetter
Lead with the conclusion"We looked at several options over two weeks and...""We recommend option C. Reasons below."
One idea per paragraphProblem, design and risk in one blockThree short paragraphs, each with a first sentence that states its point
Numbers over adjectives"Significantly faster""p99 from 4.2 s to 150 ms"
Active voice"The balance is updated.""The worker updates the balance."
Define terms oncejob, task, message, event for one thing"A job is one queued transfer." Then only "job"
Short sentencesOne 45-word sentence with three "which"Three sentences, under 20 words each
Lists for parallel itemsFive steps in one paragraphA numbered list of five steps
Owner and date on open questions"TBD: retention period""Retention, 14 or 90 days: Hemkesh Agrawani, 11 Nov"

"Bottom line up front" is the first rule applied to a whole document: write in the order of the reader's attention, not the order you discovered things.

Every level down has fewer readers. Put nothing they need below where they stop.

One change, three readers

Writing and review

The same change, written three times. Nothing is hidden from anyone: each reader gets the part they act on first.

ReaderAsksGive them
ExecutiveWhat changes for customers, what does it cost, how risky?Outcome, cost, date, the worst case
ReviewerIs it right, what is missing?Design, numbers, alternatives, assumptions
On-callHow do I know it broke, how do I stop it?Signals, thresholds, the switch, the runbook

Asking for review

Writing and review

Say what kind of feedback you want, from whom, by when, and what happens after. "Please take a look" gets typo fixes or silence.

  • Show a rough draft to one person early. A wrong direction is cheap to fix on day 2.

Reviewing someone's doc

Writing and review

Review the decision first and the wording last. Label each comment as blocking, a question, or a suggestion.

CheckAsk
Is the problem real?Who is hurt, how often, how do we know?
Are the numbers there?Load, latency, cost, and where each came from
What is missing?An alternative, a failure case, a reader (security, support, on-call)
What is the riskiest assumption?What must be true for this to work, and has anyone tested it?
Can it be undone?Where is the one-way door, and is it marked?

Disagreement and the decision

Writing and review

A review ends with a decision by a named person, written in the doc. It does not need everyone to agree.

A comment thread that passes three replies becomes a short call, and the result goes back into the doc.
TermMeansUse for
ConsensusEveryone thinks this is the best optionRare, slow. Team values, working agreements
ConsentNobody has a blocking objection: "I can live with it"Most design decisions
Disagree and commitState the objection once, on record, then build the decision as if it were yoursAfter the approver has decided

Everyday technical writing

Writing and review

Most of an engineer's writing is small. The same rule holds for all of it: the first line carries the point.

DocumentMust containTiny example
Pull request descriptionWhat, why, how tested, how to roll back"Adds Idempotency-Key to POST /transfers. Why: retries caused double debits. Tested: retry returns the same transfer. Rollback: revert, the column is nullable."
Commit messageSubject under 50 characters, imperative. Body says why"Reject transfers with a reused key" then "A retry used to create a second transfer."
Incident updateImpact, status, next action, time of next update"14:20. 1 in 50 transfers delayed about 2 minutes. No money lost. Adding workers. Next update 14:50."
Status reportOn track or not, what changed, what you need"Amber. Phase 2 slips 3 days: partner sandbox was down. Need: a sandbox contact."
Email asking for a decisionThe decision, options, your pick, the deadline"Decision needed by Thursday: keep dead-letter jobs 14 or 90 days? I recommend 14. Reply '14' or '90'."
READMEWhat it is, how to run it, how to test it, who owns it"Transfer workers. Run: make run. Test: make test. Owner: payments team."
API doc entryPurpose, parameters, responses, errors, one example"POST /transfers. 202 with id. 409 if the key was used with a different body. 422 if the balance is too low."
Runbook stepOne action, the exact command, the expected result"3. Set flag transfers.queued to off. Expect: queue depth falls to 0 within 5 minutes."

Related: commit messages and pull requests are covered in full on Git in Depth.

Reference

Part 6 of 6 · failure modes, templates, interview answers

How design docs fail

Reference

Seven ways, and the fix for each.

FailureFix
Solution before problemGet the problem section agreed before drafting the design
No alternatives"Do nothing", the cheap patch, and one option different in kind
No numbersA requirements table: today and design-for
No rolloutPhases, exit conditions, rollback, the one-way door
Too long2 to 6 pages, the rest in an appendix. Summary first
Written after the factShare the problem and a rough draft before writing code. If it is already built, write an ADR instead
Never updatedA status line, an update when the design changes, "Implemented" with links at the end

A design doc template

Reference

Copy it, answer each prompt, and delete any section that truly does not apply, saying why in one line.

An ADR template

Reference

One file per decision, numbered in order, in docs/adr/ of the repository it affects.

Interview questions

Reference

These are behavioural questions about influence. Answer with one real story and the document that carried it.

QuestionShape of a good answer
How do you drive a technical decision across teams?Agree the problem first, write options with numbers, name one approver and a date, record the decision where everyone can find it
When do you write a design doc, and when not?By cost of being wrong: one-way doors and cross-team work get a doc, a reversible one-day change gets a pull request
Tell me about a design of yours that was challenged.What the objection was, what you changed because of it, what the doc said afterwards
You disagree with the decision. What do you do?State it once with evidence, get it recorded, then commit fully. Reopen only with new data
How do you handle a review that will not converge?Move from comments to a short call, write both options side by side, let the approver decide
How do you explain a technical trade-off to a non-engineer?Outcome, cost, risk, date. One number each, no mechanism
How do you keep documents from going stale?A status line, ADRs that are superseded and never edited, docs next to the code, "update the doc" in the definition of done

Related: how to talk through a design live, without a document, is on the Interview Playbook.

Cheat sheet

Reference

When you need toDo this
Decide whether to write a docSize, risk, reversibility: one-way doors always get one
Start a docThe problem, with numbers and no solution, agreed first
Justify the choiceOne alternatives table, columns from the goals, "do nothing" included
Ship safelyPhases, exit conditions, rollback, the one-way door marked
Keep one decision foreverAn ADR: context, decision, status, consequences
Be readAnswer first, numbers over adjectives, written for the reader
Get a decisionAsk for specific feedback by a date, one approver, consent, then commit

Back to Senior Skills.