Writing design docs and ADRs

Learn to write Android design docs and Architecture Decision Records (ADRs) in Michael Nygard's format: Title, Status, Context, Decision and Consequences. About 25 minutes.

Why it matters

  • Without a written record, a new engineer on an Android project cannot tell why the team chose Jetpack Compose for new screens, or why Hilt was picked over Koin. They either re-open the debate or quietly undo the decision.
  • Interviewers at senior and staff level ask how you document architectural choices. Naming Architecture Decision Records (ADRs), design docs and the Context, Decision, Consequences structure separates you from candidates who say 'we talked about it in a meeting.'
  • ADRs make estimation and technical-decision conversations (other lessons in this module) faster: the next planning session links the ADR instead of repeating the argument.
  • A short ADR folder in the repo is one of the most useful things a new hire can read. It answers 'why is it built this way?' without a meeting.

The simple explanation

  • A building permit file: every structural change is logged with the reason and the sign-off.
  • You do not rewrite an old permit when you add a room; you file a new permit and mark the old one as replaced.
  • Repainting a room needs a short note; changing the foundation needs a full engineering report.
  • The file lives with the building's own records, not in an office no one visits.

What is an ADR? An Architecture Decision Record is a short, numbered Markdown file in the repo that records one significant decision: the situation, what the team decided, and what follows from it. Michael Nygard described the format in a 2011 blog post, "Documenting Architecture Decisions". In an Android project you might write one when you adopt Jetpack Compose for new screens, pick Hilt for dependency injection, or choose type-safe Navigation Compose routes.

Nygard's ADR has five parts:

SectionWhat it holds
TitleA short noun phrase with the number, such as "ADR 7: Compose for new screens"
StatusProposed, Accepted, Deprecated, or Superseded (with a link to the replacement)
ContextThe forces at play (technical, product, team), stated neutrally
DecisionThe response to those forces, in full sentences starting "We will..."
ConsequencesEverything that follows, positive, negative and neutral

Nygard's template has no separate Options section; the alternatives usually show up in Context. Many teams add an "Options considered" section (the MADR template calls it "Considered Options"), which is a useful extension, not part of the original format.

What is a design doc? A design doc is longer and written before building something large: goals and non-goals, the proposed design, alternatives considered, rollout, testing and risks. Use one for multi-module or hard-to-reverse work, such as moving a whole app from XML to Compose or changing the offline sync strategy. An ADR is often the short record that a design doc's final decision leaves behind.

Key rules (Nygard's post plus common practice):

  • Number sequentially (0001, 0002, …) and never reuse a number.
  • Keep each ADR to one or two pages and one decision.
  • When a decision is reversed, keep the old ADR and change its status to Superseded with a link to the new one. Do not rewrite its Context or Decision.
  • Store ADRs in the repo (Nygard used doc/arch/adr-NNN.md; docs/adr/ is a common choice) and link the ADR from the PR that implements it.

Notes

  • Nygard's ADR sections are Title, Status, Context, Decision and Consequences. An "Options considered" section is a popular addition, for example in the MADR template.
  • One decision per ADR, numbered sequentially and never renumbered. Bundling several decisions makes each one hard to find and supersede.
  • Old ADRs stay in the folder. When a decision changes, write a new ADR and set the old one's status to "Superseded by ADR-0009". Only the status line of the old file changes.
  • Status values: Proposed (still under discussion), Accepted, Deprecated, Superseded. A Proposed ADR in a PR is a good way to collect review comments on a decision.
  • Write the Decision in active voice: "We will build new screens in Jetpack Compose and host them in existing Fragments with ComposeView."
  • Consequences list the good and the bad: "New screens get Compose previews and less boilerplate; we accept two UI toolkits in the codebase during the migration."
  • Design docs are for large, multi-module or hard-to-reverse changes. ADRs record single decisions. A design doc often ends by producing one or more ADRs.
  • Store ADRs in the repo, next to the code they describe, so they show up in code search and code review. Link them from the PR that implements the decision.
  • Common Android ADR topics: Compose vs. Views for new UI, Hilt vs. Koin vs. manual DI, navigation approach, Room vs. another database, module boundaries, minimum SDK changes.
  • In interviews, name the format, give a concrete Android example, and explain how superseding keeps the history readable.

Code example

This bash script scaffolds a new ADR in docs/adr/ using Nygard's sections. It finds the highest existing number, adds one, and builds a file name from the title.

#!/usr/bin/env bash
# Scaffold a new ADR in docs/adr/
# Usage: ./new-adr.sh "Use Compose for new screens"
 
set -euo pipefail
 
TITLE="${1:?Usage: $0 \"Decision title\"}"
ADR_DIR="docs/adr"
mkdir -p "$ADR_DIR"
 
# Next number = highest existing NNNN prefix + 1 (numbers are never reused)
LAST=0
for f in "$ADR_DIR"/[0-9][0-9][0-9][0-9]-*.md; do
    [ -e "$f" ] || continue                # the glob matched nothing
    n=$(basename "$f" | cut -c1-4)
    n=$((10#$n))
    if [ "$n" -gt "$LAST" ]; then LAST=$n; fi
done
NEXT=$(printf "%04d" $((LAST + 1)))
SLUG=$(printf '%s' "$TITLE" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//')
FILE="$ADR_DIR/${NEXT}-${SLUG}.md"
 
cat > "$FILE" <<EOF
# ${NEXT}. ${TITLE}
 
Date: $(date +%Y-%m-%d)
 
## Status
 
Proposed
 
## Context
 
What forces are at play? Technical, product, team and deadline constraints, stated neutrally.
 
## Decision
 
We will ...
 
## Consequences
 
- Easier: ...
- Harder: ...
- Revisit if: ...
EOF
 
echo "Created $FILE"
  • The script works with both GNU and BSD (macOS) tools: it uses basename, cut and sed -E, not GNU-only grep -P.
  • Two engineers on different branches can still pick the same number. The clash shows up as a merge conflict or in review; renumber the later one before merging.
  • New ADRs start as Proposed. Merging the PR that contains them is a natural point to change the status to Accepted.
  • The "Revisit if" line in Consequences records when the decision should be looked at again, for example "revisit if the Compose BOM upgrade blocks a release."

Run the idea in plain Kotlin

An ADR log in memory: it checks that each record has every Nygard section filled in, and supersedes an old decision by adding a new record and changing only the old record's status.

data class Adr(
  val number: Int,
  val title: String,
  val status: String,
  val context: String,
  val decision: String,
  val consequences: List<String>
)

fun id(n: Int): String = "ADR-" + n.toString().padStart(4, '0')

fun missingSections(adr: Adr): List<String> {
  val missing = mutableListOf<String>()
  if (adr.title.isBlank()) missing.add("Title")
  if (adr.status.isBlank()) missing.add("Status")
  if (adr.context.isBlank()) missing.add("Context")
  if (!adr.decision.startsWith("We will")) missing.add("Decision (start with 'We will')")
  if (adr.consequences.isEmpty()) missing.add("Consequences")
  return missing
}

fun supersede(log: List<Adr>, oldNumber: Int, replacement: Adr): List<Adr> {
  require(log.none { it.number == replacement.number }) { "ADR numbers are never reused" }
  val updated = log.map { adr ->
      if (adr.number == oldNumber) adr.copy(status = "Superseded by " + id(replacement.number)) else adr
  }
  return updated + replacement
}

fun main() {
  val adr1 = Adr(
      number = 1,
      title = "Build new screens in Jetpack Compose",
      status = "Accepted",
      context = "Existing screens use Fragments and XML; the team wants previews and less boilerplate.",
      decision = "We will build new screens in Compose and host them in Fragments with ComposeView.",
      consequences = listOf("Easier: previews, state hoisting", "Harder: two UI toolkits during migration")
  )
  val draft = Adr(2, "Use Koin for DI", "Proposed", "", "Koin looks simpler", emptyList())

  var log = listOf(adr1, draft)
  for (adr in log) {
      val missing = missingSections(adr)
      println(id(adr.number) + " complete=" + missing.isEmpty() + (if (missing.isEmpty()) "" else " missing=" + missing))
  }

  val adr3 = Adr(
      number = 3,
      title = "Move navigation to Navigation Compose",
      status = "Accepted",
      context = "Most screens are now Compose; Fragment hosting adds a layer to every screen.",
      decision = "We will use Navigation Compose with type-safe routes for all screens.",
      consequences = listOf("Easier: one navigation graph", "Harder: deep links must be re-tested")
  )
  log = supersede(log, oldNumber = 1, replacement = adr3)

  println("Index:")
  for (adr in log) println("  " + id(adr.number) + " [" + adr.status + "] " + adr.title)
}

Expected output:

ADR-0001 complete=true
ADR-0002 complete=false missing=[Context, Decision (start with 'We will'), Consequences]
Index:
  ADR-0001 [Superseded by ADR-0003] Build new screens in Jetpack Compose
  ADR-0002 [Proposed] Use Koin for DI
  ADR-0003 [Accepted] Move navigation to Navigation Compose

In production

The Compose migration a new engineer started to undo
  • A team decided to build new screens in Jetpack Compose and host them in existing Fragments, but the reasoning lived only in a meeting.
  • A year later a new engineer saw Fragments mixing XML and ComposeView and opened a PR to convert a Compose screen back to XML "for consistency".
  • Review caught it, but only after a few days of work, and nobody could explain the original constraints without digging through chat history.
The fix
  • A senior wrote ADR-0001 after the fact: Context (Fragment-based navigation, wish for previews and less view boilerplate), Decision ("We will build new screens in Compose and host them with ComposeView"), Consequences (two toolkits during the migration).
  • The PR template gained an optional "Related ADR" line, and the onboarding checklist now links docs/adr/.
  • When the team later moved to Navigation Compose, they wrote ADR-0005 and changed ADR-0001's status to "Superseded by ADR-0005".
The navigation debate that came back every planning session
  • A team argued in several planning sessions about Navigation Compose versus a custom router.
  • Each time, people repeated the same points because nothing was written down about what had been tried and why it was rejected.
  • Feature work on new screens waited because nobody wanted to start without a settled decision.
The fix
  • One engineer wrote a Proposed ADR with the context, the two candidate approaches and their consequences, and opened it as a PR so everyone could comment in one place.
  • The team accepted it in review; later sessions linked the ADR instead of re-arguing.
  • When a new constraint appeared (deep links from a partner app), they wrote a new ADR that superseded the first rather than editing it.

Common mistakes

  • Writing a long design doc for a small, reversible change. Heavy process stops people writing anything. A one-page ADR or a clear PR description is enough for local, easy-to-undo choices; keep design docs for large or hard-to-reverse work.
  • Rewriting an old ADR in place. You lose the reasoning that was true at the time. Write a new ADR and mark the old one "Superseded by ADR-000N"; only its status line changes.
  • Skipping Consequences. Without the accepted downsides written down, the next engineer cannot tell whether the decision still holds. List what gets easier and what gets harder.
  • Storing ADRs where nobody looks. A wiki page that is not linked from code or PRs is soon forgotten. Keep ADRs in the repo and link them from the implementing PR.
  • One ADR covering five decisions. Bundling makes each decision hard to find, reference and supersede. One decision, one file, one number.
  • Recording only the winner. If the context does not mention what else was considered and why it lost, someone will propose the rejected option again. Mention the alternatives in Context or an "Options considered" section.

Interview questions

Answer out loud first. Then reveal the answer and compare it at each depth.

“How do you document architectural decisions in a team?”

“What is the difference between a design doc and an ADR?”

“How do you handle a disagreement about a technical choice, like Compose versus Views for a new feature?”

“How do you keep design docs and ADRs from becoming stale?”

Quiz

Which set of sections matches Michael Nygard's original ADR format?

An accepted ADR is no longer valid because the team changed its approach. What should happen?

Which ADR section records the downsides the team accepted?

When is a full design doc, rather than only a short ADR, the right format?

0 of 4 answered

Mini task

Write your first ADR (15 minutes)

  1. Pick a decision your team made in the last six months. Examples: 'build new screens in Jetpack Compose,' 'adopt Hilt for DI,' 'use Room as the single source of truth for the feed.'

  2. Create the file. In your Android repo, run the script from this lesson, or create docs/adr/0001-<slug>.md by hand.

  3. Fill in Nygard's sections:

    • Status: Proposed (or Accepted if it is already in place).
    • Context: three to five sentences on the forces: technical constraints, product needs, team skills, deadlines.
    • Decision: one or two sentences starting with "We will".
    • Consequences: what gets easier, what gets harder, and one "revisit if" condition.
  4. Mention the alternatives you rejected and why, in Context or an "Options considered" section.

  5. Link it. Add a line to the PR description that implements (or implemented) the decision: ADR: docs/adr/0001-build-new-screens-in-compose.md.

Done when: the ADR fits on one or two pages, every section is filled in, the Decision starts with "We will", and a teammate who reads it cold can explain the decision back to you without asking questions.

Next: Estimation and technical decisions