Skip to content
Sniptide

Architecture decision record template

An architecture decision record captures one significant technical decision, the context that forced it and its consequences, in a short file kept next to the code. Copy the example below into docs/adr, number it after your last record, and replace the context, decision and consequences with yours.

Updated

Files

docs/adr/0007-use-postgres-for-background-jobs.mdRaw
# 7. Use Postgres for background jobs

- Status: Accepted
- Date: 2026-11-30
- Deciders: Platform team
- Supersedes: [3. Use Redis for background jobs](0003-use-redis-for-background-jobs.md)

## Context

The app sends emails, generates exports and calls webhooks in background jobs. Since ADR 3, jobs
run on a Redis queue. Two problems keep coming up:

- A job and the database write that created it are not atomic. When Redis is unavailable after a
  commit, the job is lost, which happened three times last quarter.
- Redis is the only reason we run a second stateful service. It needs its own backups, monitoring
  and upgrades.

We process about 40,000 jobs a day, with peaks of 30 a second. Postgres handles our current load
at under 20% CPU.

## Decision

We will run background jobs from a `jobs` table in Postgres, using `SELECT ... FOR UPDATE SKIP
LOCKED` to claim work. Jobs are inserted in the same transaction as the change that creates them.
We will use an existing library for the queue instead of writing our own.

## Consequences

- A job exists if and only if its transaction committed. Lost jobs stop.
- We remove Redis from production, its backups and its alerts.
- Polling adds load to Postgres. We will alert when job claims take longer than 50 ms at the 95th
  percentile, and revisit this decision if they do.
- The workers need a migration path: both queues run side by side for two weeks, then the Redis
  queue is drained and removed.

## Alternatives considered

- **Keep Redis and add an outbox table.** Fixes lost jobs, but keeps both services and adds a relay
  process.
- **A managed queue such as SQS.** Removes operations work, but jobs still aren't transactional and
  local development needs an emulator.

Save with your agent

Run this command to add Sniptide to Claude Code in the current project. Open /mcp in Claude Code and sign in to Sniptide. Once the server shows as connected, use the prompt below to save a private copy in your library.

Terminal
claude mcp add --scope local --transport http sniptide https://app.sniptide.com/api/mcp
Prompt
Read https://sniptide.com/templates/adr-template.json and use create_snippet to save its files as a private Sniptide snippet titled "Architecture decision record template". Keep the file names and contents from the JSON.

When to write one

Write an ADR when a decision is expensive to reverse or will confuse someone in a year: a database, a framework, an API style, a hosting choice or a security model. The record answers the question a new teammate asks first, "why is it built like this?", without finding the person who decided.

One decision per file. Records are numbered and never deleted. When a decision changes, write a new record that supersedes the old one, and set the old one's status to Superseded by with a link. The history stays readable from start to finish.

What each section does

Section
What it settles
How to write it
Title
The decision itself.
A short imperative phrase: "Use Postgres for background jobs", not "Job queue discussion".
Status and metadata
Whether the decision holds, when it was made and by whom.
Proposed, Accepted, Deprecated or Superseded by N. Link the record it supersedes.
Context
The forces at play: the problem, constraints and numbers.
Facts a reader can check, such as load, cost and incidents. Leave the decision out of this section.
Decision
What you will do.
One paragraph, starting "We will".
Consequences
What becomes easier, what becomes harder and what you will watch.
Include the bad consequences. A record without them reads as a sales pitch.
Alternatives considered
Options you rejected and why.
One line each, so nobody proposes them again without new information.

This layout follows Michael Nygard's original format, with alternatives added because they are the part readers search for most.

Keep them with the code

Store records in docs/adr/ and change them through pull requests, so a decision gets the same review as code. Name each file with a four-digit number and the title in kebab-case. Link the record from the code it explains when the reason isn't obvious from the code, such as a comment above the queue setup.

Coding agents read the folder too. A line in AGENTS.md such as "Read docs/adr/ before changing infrastructure" stops an agent from undoing a decision it doesn't know about.

Variant: a lightweight record

For smaller decisions, a short form is enough:

docs/adr/0008-use-zod-for-validation.md
# 8. Use Zod for request validation

Accepted, 2026-11-30.

We will validate every request body with Zod schemas in `lib/validation`, because the schemas also
give us TypeScript types and we already use Zod in the frontend. Hand-written checks are removed as
the routes are touched.
All templates
  • Design doc
    SpecsSoftware design document template

    A software design document template in Markdown with goals, non-goals, proposed design, alternatives, security, rollout and open questions, on a real feature.

  • PRD
    SpecsPRD template for AI coding agents

    A PRD template written so a coding agent can build from it, with numbered requirements, scope limits, technical notes and checkable acceptance criteria.

  • Agent filesAGENTS.md template

    An AGENTS.md template and example with setup, checks, code style, testing and PR rules, plus a monorepo layout. Copy it into your repo.

Pick where your library lives.

Use sniptide.com

Save your first pattern in the app, then connect Claude Code, Cursor or Codex with one sign-in in the browser.

Run it on your own server

One image and a database give you the app, the API and the MCP endpoint. Sniptide is open source under AGPL-3.0.

$docker compose up -d