A design doc for one feature
A design doc is the cheapest place to find the flaw in your own feature: the hardest constraint traced with dates, two designs argued fairly, and one named person who decides
Ferrowave keeps idempotency keys for 7 days and lets customers schedule a payout batch up to 30 days ahead. On 3 December a payroll customer's system schedules a batch for 25 December with key K, never saves the answer, and on 12 December sends the same request again with the same K. In a design that relies on the key alone, what happens?
This chapter is about the design doc you write for a feature you are about to build, as a mid-level engineer. It is the small sibling of the cross-team document in writing RFCs and design docs, and that chapter owns the full process: approver panels, comment windows, review forums and records of decisions. Here the scope is one feature, one team’s code and mostly your own judgement. The document is one to three pages, it takes two days, and it ends when your tech lead says yes.
The running case is Ferrowave’s scheduled payouts. Ferrowave, the bulk-payouts API with 38 engineers in six teams, is adding a feature: a customer submits a payout batch now and schedules it for a date and time up to 30 days ahead. Adigun, a mid-level engineer in Payouts Core, builds the scheduler and the executor. Olaoluwa, Payouts Core’s tech lead, approves the design.
Why write one at your level
At foundations level someone else decided what to build and you built it. At practitioner level you take a feature from ticket to production, so you are the one who chooses its shape, and you can be wrong about it for days before anyone notices. The code review catches a bug in a line. It rarely catches a wrong shape, because by then the shape is four days old and every comment costs rework.
A design doc moves that conversation earlier. It does three things for you.
- It makes you find the hard part. Writing “the scheduler polls a table” is easy. Writing what happens on day 9 is not, and the paragraph you cannot write is where the design is thin.
- It tells the people you touch before you touch them. Ferrowave’s scheduler needs a holiday calendar from Bank Connectors, a scheduling screen from Customer Console and a scheduled-versus-executed line from Reconciliation and Ledger. They find out in a document they can answer, not in a pull request they can only reject.
- It leaves a reason behind. In a year, someone on a four-person on-call rota will ask why the scheduler is a table and not a queue. The doc answers.
When to write one, and when to skip it
Writing costs time, so the question is whether there is a decision worth the time. Malte Ubl, who has described how design docs work at Google, makes the same point: a design doc is overhead unless the problem has real alternatives, and one that reads like an implementation manual should have been the code. Three questions settle it.
- Is there a real choice? Two designs that a sensible colleague would argue for. If there is one sensible way, write the code and a good description.
- Does it touch another team, money, personal data or someone else’s pager? If yes, the other team should hear it from you first.
- Would a wrong choice be expensive to undo? A new table that stores customers’ payout files is expensive. A new function behind a flag is not.
Ferrowave’s scheduler answers yes three times: a table versus a scheduler, three neighbouring teams, and bank account numbers held for up to thirty days longer than today. A tweak to a retry delay answers no three times, and a pull request is the right size of writing. The rule of thumb in the staff chapter is the same: a mini design doc, one to three pages, for a real choice inside one team, and a full RFC when the change crosses teams or is hard to reverse. Your scheduler is borderline, since it crosses three teams. Olaoluwa’s call is that it stays a mini doc, because the neighbours supply one input each and none runs it.
The model: eight parts, each answering a question
Each part exists because a reviewer would otherwise ask the question in a comment.
| Part | The question it answers | Length |
|---|---|---|
| Header and the ask | What do you need decided, by whom, by when? | 4 lines |
| Context, with numbers | Why now, and how big is this? | A short paragraph and a few figures |
| Goals and non-goals | What is this for, and what will it not do? | 3 to 5 lines |
| The design | How does it work, and where is the hard part? | Half a page, plus one trace |
| Alternatives | What else did you consider, including doing nothing? | A paragraph each |
| Trade-offs and the trigger | What does this give up, and when do we revisit? | 3 lines |
| Rollout, rollback and on-call | How does it ship, how do we get back, who gets paged? | A short list |
| Open questions and the decision log | What is unknown, who owns it, and what was decided? | A table |
You can write the parts in a different order from the one the reader sees. Write the hard constraint first, then the design, then the alternatives, and the ask last.
Start with the hard constraint
Every feature has one fact that could break the first design you think of. Find it before you draw anything. State it in a sentence, then trace it through the design with dates, the way a debugger traces a request.
At Ferrowave the sentence is: keys are kept 7 days, schedules run up to 30 days ahead, and a retried scheduled batch must not pay twice. A duplicate can enter in two places, and the trace shows both.
| Day | What happens | What protects it |
|---|---|---|
| 0 | The customer’s system creates a schedule for day 30 with key K | The payouts gateway remembers K |
| 3 | Its job retries the create call | The gateway replays the first answer |
| 9 | It retries again | The gateway has forgotten K. Only the schedule row can protect this |
| 30, 06:00 | The executor claims the batch and submits it under a key derived from the schedule id | First use of that key, so its 7 days start now |
| 30, 06:04 | A worker crashes and the batch is retried | The same derived key is replayed |
| 37 or later | Someone replays the run by hand | The row says the batch is done, so nothing is sent |
The rows teach more than the prose does. A key protects the first 7 days of a 30-day schedule and leaves the other 23, about 77 percent, to something else. The design needs two guards with two lifetimes: the schedule row remembers the customer’s key for the whole life of the schedule, and the run uses a key the executor derives from the schedule id, which has its first use on the day. If instead you created the payouts on day 0 and held them until day 30, the key would be 30 days old when you released them, and the whole problem would sit on the day that matters. That is why the doc rejects that alternative.
This is the idempotency material from the idempotency lesson and the payments chapter on moving money exactly once, applied to one feature. The point for the doc is that the trace is written down, with dates, where a reviewer can check it.
Argue two designs fairly
A design doc with one design is a decision announcement. Reviewers can only agree or object, and objections arrive as redesigns. Two designs, each argued as its supporters would argue it, let the reviewer test your reasoning.
The seed choice at Ferrowave is a table that a worker polls every minute, in about a week, or a durable scheduler with timers on the queue, in about two weeks. Written fairly, the scheduler’s case is real: it fires exactly on time, it scales to far more schedules than a poll can read, and other teams might reuse it. Written fairly, the table’s case is also real, and it rests on numbers. If all 210 customers kept four batches scheduled at once there would be 840 rows, and an index on status and due time makes the minute’s poll a small read. The 41 customers who asked cluster on the 25th and the last working day, so the heavy minute is about 31 batches at 06:00. The table is also the record Reconciliation and Ledger needs and the thing the cancel button changes, so it exists whichever design you choose. A scheduler with timers adds a second place where each schedule lives and a second place to disagree with the first.
Check the facts a rival depends on. A timer 30 days out only works if your queue can delay a message that long. If its longest delay is shorter, the timers need a rounds counter or a hierarchy of wheels, which is the subject of the timer wheels lesson, and your design now owns a small timekeeping component. Ask before you promise that to a reviewer.
Then do the part people skip: name what the chosen design gives up and the number at which you would change your mind. Adigun’s doc says the table design gives up exact timing, since a poll every 60 seconds can start a batch up to a minute late, and gives up headroom, since it is comfortable at hundreds of rows and not at millions. The trigger to revisit is more than 50,000 pending schedules or a second team needing timers. Both numbers are Adigun’s own estimates and are labelled so. This is simple first written into a document, with its cost and its exit.
Numbers beat adjectives
Reviewers argue about “will it scale” until someone brings a figure. A design doc earns trust by replacing adjectives with measurements, and where no measurement exists, by saying so and bounding the guess.
Adigun measured one thing: a spike in staging that submitted 31 test batches of about 300 payouts each, about 9,400 in all, through the existing path with four workers against the sandbox bank. It took 6 minutes 40 seconds, or 400 seconds, about 23 payouts a second. That tells him the table and the worker are not the limit. It does not tell him how long production takes, because the sandbox bank answers at once and real partner banks rate-limit. The executor’s production rate is about 3.5 payouts a second (the figure the on-call chapter uses), so 9,400 payouts take about 2,700 seconds, 45 minutes. With a 60-second poll the last payout of the heavy minute goes out about 46 minutes after 06:00, at about 06:46. Staff are promised pay by 07:00, which leaves about 14 minutes of margin. So the doc asks the product manager for payouts to agree a goal of “paid by 07:00, started within 60 seconds of due”, and not a ten-minute run time that the staging figure alone would have suggested. The numbers here are illustrative. In your doc, mark each figure as measured, taken from a source, or assumed, and say where a measurement was taken, because a staging rate can be several times the production one. A spike for a single feature takes an afternoon; the staff chapter’s point about measuring and not asserting applies at this size too.
Get it read and get it decided
The review process, with approver panels, comment windows and conditional answers, belongs to the staff chapter. At one feature’s size it shrinks to five habits.
- One named approver. Olaoluwa’s yes starts the work. Everyone else is a reviewer. If you cannot name the person who decides, ask your tech lead before you write.
- Walk the neighbours through it first, 30 minutes each. Magnus, the Reconciliation and Ledger engineer, needs a scheduled-versus-executed field in the daily file, and learning that in a document he has already discussed is a different experience from learning it in a pull request. The Bank Connectors lead has the holiday calendar and the Customer Console lead has the screen.
- Put a window and a date in the header. Three working days to comment, then the date the approver decides.
- Ask for a conditional yes. Tanya Reilly’s account of Squarespace’s process describes approvers answering “yes” or “not yet” with a condition attached, which tells you what to do and lets you start.
- Write down what was decided, and change the doc if the build changes the design, so the next reader finds the design that was built.
Where practitioners disagree
Doc or spike first. Some engineers prototype before writing, because a spike finds facts a doc cannot. Others write first, because the prototype becomes the design. A practical middle is a spike with a deadline whose result goes into the doc, as Adigun’s did.
How long. Ubl suggests that a doc for a large project falls around ten to twenty pages and that a short one can be shorter still. Many teams hold one-feature docs to one to three pages. The test is whether each section answers a question a reviewer would ask, not the page count.
Where it lives. Next to the code, reviewed as a pull request, or in a shared document where product and support can comment. The first gives you a versioned history, the second gives you readers who do not use git. Use whichever your team already reads.
Living or finished. Keep editing it through the build, or freeze it and record changes in a short architecture decision record, the one-or-two-page form Michael Nygard proposed. Either works if the next reader can tell what was built.
AI drafting. An assistant will produce a tidy doc quickly. Check the usual faults: invented numbers, a rival design described so weakly that no one would pick it, and a design section that is an implementation manual. The technique of working with agents has its own chapter, working with AI coding agents.
Where one-feature docs go wrong
The failures that the staff chapter lists, such as writing after the code, the straw-man alternative and the ambush, apply here unchanged. Three are more likely at this size.
An implementation manual. Class names and no choice. If nothing in it could have gone another way, delete the doc and improve the pull request.
No number and no owner. “Probably fine at scale” and an open question with no name against it. A rate taken from staging and presented as the production rate belongs here too.
Never updated. The design changed in week two and the doc did not. The doc now misleads the person who inherits it.
Day to day
A one-feature doc runs on a short loop. Suppose it takes two days of writing and a week of review.
Day 1, morning. Write the ask, the goals and non-goals, and the hard constraint in a sentence. List the numbers you need and where each will come from. Book the 30-minute walk-throughs now, because your neighbours’ diaries decide your date.
Day 1, afternoon, and day 2. Run the spike or the query that replaces your biggest guess. Draft the design and the trace, then the alternatives. Write the alternative you like least first, and have a colleague tell you if it sounds like its supporters.
Day 3. Walk each affected person through it, 30 minutes each. Change the doc after each conversation.
Days 3 to 5. Circulate with a three-working-day window. Check comments morning and afternoon, reply within a day, and mark which are blocking.
Day 6, decision. The approver says yes, yes if, or not yet. Record it in the log the same day, start the build and put the doc link in the first pull request.
Every week of the build. Spend ten minutes keeping the doc true. Change the status line, the open questions and anything the build has overturned.
Every week, as a reviewer. Read the design docs in flight on the neighbouring teams, about thirty minutes, and comment where your team’s system is touched.
After launch. Come back to the doc once the first month of real use is in. Which numbers were wrong, and which risk did you miss? That is the cheapest calibration you will get. How you size the work that follows is in breaking down and estimating work, also later in this track, and how a manager plans around it is in delivery and planning.
Under 30 people there is no template and probably no review process. The doc is a page in the repository or a ticket, the approver is the most senior engineer or the CTO, and the review is a 30-minute conversation. The neighbours you walk through it are the support person and the founder. The risk is skipping it because everyone is in the room: three months later nobody remembers why the table was chosen, and the one person who knew has left. Keep it to one page and put it next to the code.
With 30 to 300 people your neighbours are other teams, and the rule for when to write a doc is probably unwritten. Ask your tech lead where the line is, and use a short template with a named approver and a decision date. The common failure is a heavy template copied from a larger company, so that a two-day design waits two weeks. A second failure is the opposite: every team decides alone and two teams build the same timer. Link your doc from the channel where the neighbours already look.
At 300 and above a process exists: a review forum, a security check, perhaps a change board with mandatory sections. Write the short version first, then fill the template from it, so the thinking is yours and the form is the organisation’s. Your neighbours are several teams and the approver may not sit with you, so the walk-throughs take most of the time. The risk is writing for the forum and not for the engineer who inherits the system, which produces a doc that passes review and explains nothing.
Template
# Design: <feature>
Author: <name> · Status: draft | in review | decided
Approver: <one name> · Reviewers: <teams and people, walked through it on <dates>>
Comment window closes: <date> · Decision by: <date>
## The ask
<The decision you need, from whom, by when. Then two sentences on the proposal.>
## Context
<Why now. Numbers, each marked measured / sourced / assumed.>
## Hardest constraint
<One sentence.>
| Step or day | What happens | What protects it |
|---|---|---|
## Goals and non-goals
Goals: <outcomes>
Non-goals: <thing a reviewer will assume is in> — <where it goes instead>
## Design
<Data, flow, what each team supplies. Half a page.>
## Alternatives
### Do nothing or the existing way
### <Option B, argued as its supporters would>
<When it wins. Why that does not apply here.>
## Trade-offs and trigger
<What this gives up. The number or event at which we revisit.>
## Rollout, rollback, on-call
<Flag, order of customers, how to switch off, what pages whom.>
## Open questions
| Question | Owner | By |
|---|---|---|
## Decision log
| Date | Decision | By | Conditions |
|---|---|---|---| WORKED EXAMPLE
Ferrowave, Payouts Core. Adigun wrote this for Olaoluwa. Figures are illustrative.
Design: scheduled payout batches (scheduler and executor). Author Adigun. Approver Olaoluwa. Reviewers: Magnus (Reconciliation and Ledger), the Bank Connectors lead and the Customer Console lead, each walked through it on 23 November. Comment window closes Thursday 26 November; decision by Friday 27 November.
The ask. Please decide between a polled table and a durable scheduler for scheduled batches, and agree the key rule below. I propose the polled table, 5 to 8 working days.
Context. 41 of 210 customers asked in two quarters (support tickets). I assume 31 pay on the 25th and 10 on the last working day, so the heavy minute is about 31 batches, 9,400 payouts, due 06:00 West Africa Time (assumed). A spike in staging against the sandbox bank, 31 batches of about 300 with four workers, took 400 seconds, about 23 payouts a second (measured). Production is paced by the partner banks at about 3.5 a second (sourced: the executor’s current rate), so the heavy minute takes about 45 minutes. Even 210 customers with four batches each is 840 rows (assumed).
Hardest constraint. Keys are kept 7 days and schedules run 30 days ahead, so a key alone protects 7 of 30 days and a retried batch must not pay twice. Day 9 retry of the create call: the gateway has forgotten K, so the schedule row, which holds K until 90 days after the run, returns the original. Day 30, 06:04 retry of the run: the executor sends key sched-<id>, first used that morning, so it is replayed. A replay on day 37: the row says done, so nothing is sent.
Non-goals. Cancellation and holiday roll-over: the table has a cancelled state, and the rules for entering it are a second doc. Recurring schedules.
Design. One table, one row per schedule: customer, K and a hash of the body, the batch, run time in UTC, status. A worker polls each minute and claims due rows with a conditional update, so two workers are safe. Reconciliation and Ledger reads the row for the scheduled-versus-executed line.
Alternatives. Do nothing: customers keep calling the API on the day, and 41 have asked for better. Durable scheduler: exact timing and room to grow, but 10 working days, a second store that must match the table, and one more component for a four-person rota. Hold payouts from day 0: rejected, since the keys would be 30 days old on release.
Trade-offs and trigger. A batch may start up to 60 seconds late, so the heavy minute finishes about 46 minutes after 06:00, inside the 07:00 promise to staff; I propose “paid by 07:00” as the goal. Revisit above 50,000 pending schedules or if a second team needs timers.
Rollout and on-call. Flag per customer, five customers first; the flag also switches scheduling off. One new alert: oldest due unclaimed batch older than 5 minutes.
Open questions. Is funding checked at schedule time or run time? The product manager for payouts, 27 November. The calendar endpoint’s date: the Bank Connectors lead, 27 November.
Decision log. Empty until 27 November.
Now you
You are Adigun. Olaoluwa has approved the scheduler and asks for the second doc: cancellation and holiday roll-over. Facts. A customer may cancel until 30 minutes before the run time. The worker polls every 60 seconds and claims due rows with a conditional update, so a claim and a cancel on the same row cannot both win. A requested date on a weekend or public holiday rolls to the next business day. Of the 41 customers who asked, 31 pay on the 25th. This quarter the 25th lands on a Sunday. Kamsiyochukwu, a Customer Console engineer, wants the screen to show an expected run date and a cancel button that never accepts a cancel it cannot honour. The Bank Connectors lead says the calendar endpoint will list known holidays, and that a holiday is sometimes declared with only three days’ notice. Write the doc. It must compare at least three times to decide the run date (at creation, nightly, on the day), trace a holiday declared late through your choice, and say who tells a customer whose payroll moves a day.
Self-check
Adigun is writing the design doc for Ferrowave's scheduled payouts. Keys are kept 7 days and customers may schedule up to 30 days ahead. Two designs are on the table: a table polled every minute by a cron worker, 5 to 8 working days, or a durable scheduler with timers on the queue, about 10 working days. 41 of 210 customers asked, about 31 batches fall due in the same minute on the 25th, the target is the January payroll run, and Payouts Core's on-call rota is four people. Olaoluwa asks which design the doc should recommend, and how it should handle the key.
- POST Design Docs at Google Malte Ubl, 2020
The common model for a design doc: free-form structure, the lifecycle of a doc, and the test for when one is overhead. Read it before choosing your template, and keep yours shorter than its large-project advice.
- POST Implementing Stripe-like Idempotency Keys in Postgres Brandur Leach, 2017
A worked design for recovering a request's state after a partial failure with an idempotency key and a database transaction. Read it to see the key table behind this chapter's schedule row; the Ruby is incidental.
- POST Documenting Architecture Decisions Michael Nygard, 2011
The origin of the short decision record kept next to the code. Use it for the record your design doc leaves behind once the build changes the design.
- POST The Power of 'Yes, if': Iterating on our RFC Process Tanya Reilly, 2019
A principal engineer on why approvers answering yes or not yet, with conditions, lets authors keep moving. Read it before your first review so you can ask for a conditional yes.
- POST Scaling Engineering Teams via RFCs: Writing Things Down Gergely Orosz, 2018
How Uber's written-plan process grew with the company, and why sharing plans in writing builds accountability. Read it to see where a one-feature doc sits in a larger process.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.