# How we ship: from issue to production

Published: 18 August 2026
Category: Technology

Our projects are run by very small teams with a lot of output. There's an open source CMS, a few iPhone apps with APIs behind them, an operations platform made up of several Workers, and a few websites, including this one. Much of the code is now written with Claude Code, often with several sessions running at once, each on its own branch.

That changes what a delivery process is for. When code arrives faster than anyone can hold it in their head, a convention in a wiki doesn't do much. The rules that survive are the ones a machine enforces, for people and agents alike.

This is the process we've settled on. Every service we deploy follows the same shape:

1. An issue describes the work.
2. A short-lived branch and a pull request carry the change.
3. One CI gate decides whether it can merge.
4. Merging to `main` deploys staging.
5. A person promotes that exact commit to production.
6. The release closes the issues it shipped.

## Anything with a status is an issue

Docs hold designs, decisions and runbooks. Anything that can be open, blocked or done is a GitHub issue, with labels generated from a script so they're identical everywhere.

The rule that surprises people is that we never use closing keywords. Commits and pull requests say this instead:

```text
Refs #128
```

`Fixes #128` closes the issue the moment the change lands on `main`, which is before it has been verified on staging and well before a customer has it. With `Refs`, an issue moves through `on-staging` and `verified`, and the production release closes it. An issue marked closed means the fix is actually live.

Deferred work gets a `deferred` label and a `Revisit: YYYY-MM-DD` line. A scheduled workflow puts it back into triage on that date, so "later" doesn't quietly become "never".

## Guard rails start on the laptop

Every repo uses [lefthook](https://github.com/evilmartians/lefthook) for the same small set of hooks: Biome and gitleaks on staged files, commitlint on the message, and a pre-push check that refuses `main`.

```sh
#!/bin/sh
# Refuse any push that updates or deletes refs/heads/main.
while read -r local_ref _local_sha remote_ref _remote_sha; do
  if [ "$remote_ref" = "refs/heads/main" ]; then
    echo "pre-push: refusing to push directly to main. Open a pull request instead."
    exit 1
  fi
done
```

It's eight lines and can be bypassed with `--no-verify`, so it isn't a security boundary. Its job is to make the wrong path fail loudly for anyone, or anything, that wandered onto it by accident.

Pull requests are squash merged, and the PR title becomes the commit subject. CI lints that title with the same commitlint config, which keeps the history of `main` readable as a list of changes.

## One gate

Each repo has different checks. A simple site has a few jobs, and a project with an Apple app and several services has eleven. They all funnel into a single job called `gate`:

```yaml
gate:
  if: always()
  needs: [check, guards, lint, deploy-staging]
  steps:
    - name: every needed job passed or was skipped
      env:
        RESULTS: ${{ toJSON(needs.*.result) }}
      run: |
        case "$RESULTS" in
          *failure*|*cancelled*) echo "::error::a required job failed or was cancelled"; exit 1 ;;
        esac
```

Automation only ever has to wait on one status. Jobs can be added, split or skipped by path without touching branch rules or the dependency bot's config.

The `lint` job covers more than formatting. It also checks the workflows themselves with actionlint and zizmor and scans for secrets with gitleaks. The `guards` job holds rules specific to how a project can go wrong, like the migration check below.

## Staging deploys itself

A merge to `main` runs the same checks again, applies database migrations to staging, deploys, and runs a smoke test. Every deploy is tagged with its commit, so we can always ask an environment what it's running and get a real answer.

We don't cancel in-progress runs on `main`. With several agent sessions merging in quick succession, cancelling the older run can mean no commit ever finishes deploying.

## Production is a deliberate act

Production ships from a manual `promote` workflow. You give it a commit and type the first seven characters of that commit to confirm. Then it refuses to continue unless staging has already proven that exact commit:

```sh
node scripts/deploy/release-notes.mjs confirm "$sha" "$INPUT_CONFIRM"
git merge-base --is-ancestor "$sha" origin/main \
  || { echo "::error::$sha is not an ancestor of origin/main"; exit 1; }
# ...find the ci run for this commit...
node scripts/deploy/release-notes.mjs job-ok ci-jobs.json "deploy staging" \
  || { echo "::error::ci run $run_id did not deploy $sha to staging"; exit 1; }
```

If those pass, it records a rollback point, migrates, deploys and runs the smoke test. Only after that does it create the `release-YYYY.MM.DD-N` tag and GitHub Release. That ordering exists because we once had releases on record whose deploys had failed. A release now means the thing is actually running.

The typed SHA is a speed bump and we're honest about that. Someone with enough access could get around it. For a team our size, what we need is for production to require a conscious decision about a specific commit, and for that decision to leave a record.

All deploys go through CI, with no exceptions for convenience. Laptop deploys were how we used to lose track of which commit was live, so we deleted the `deploy:*` package scripts altogether. The instruction to agents is blunt:

> **Deploy through CI, never from a laptop.** Do not run `wrangler deploy` (except `--dry-run`); there is no `deploy:*` pnpm script.

## Refuse the wrong environment

The scariest deployment bug is a staging build pointed at production data, or the reverse. Our Workers declare each environment in full, and the deploy script inspects the built config and stops if anything disagrees:

```javascript
const staging = env === "staging";
const ends = (s) => String(s).endsWith("-staging");
if (c.name !== expected) bad.push(`name ${c.name} != ${expected}`);
if (c.vars?.WORKER_ENV !== env) bad.push(`WORKER_ENV ${c.vars?.WORKER_ENV} != ${env}`);
for (const [k, n] of names) if (ends(n) !== staging) bad.push(`${k} ${n}`);
```

In staging, every database and bucket name must end in `-staging`. In production, none may. A naming convention becomes a check that takes a few lines and rules out an entire class of accident.

## Make rollback boring

A code rollback is only safe if the previous version still works against the current database. So migrations are expand-only, and CI enforces it:

- A committed migration is immutable.
- A new `NOT NULL` column must have a default.
- A drop or rename needs a header naming the release since which the old thing has been unused.

```sql
-- contract: users.legacy_name unused since release-2026.07.14-2
ALTER TABLE users DROP COLUMN legacy_name;
```

The check confirms that release exists and is an ancestor of the current commit. Destructive changes are still possible, but you have to show your working.

With that in place, `rollback` is a workflow that points the Worker back at the version recorded in the release notes. A failed smoke test during a promote triggers it automatically, unless the release changed a Durable Object class, because Cloudflare won't roll back across one of those. In that case the way back is a reversing commit. Rollback is code only. Data recovery is a separate, manual step from a bookmark in the same release notes, and we would rather that be a conscious choice.

## Treat dependencies as untrusted

Package registry compromises tend to be noticed quickly, so the cheapest defence is to not be first. Every project refuses packages less than three days old and blocks install scripts by default:

```yaml
allowBuilds:
  esbuild: false
  lefthook: true
  sharp: false
  workerd: false

# Three days, in minutes.
minimumReleaseAge: 4320
```

Renovate uses the same window. Minor and patch updates merge themselves once `gate` is green, major versions wait for a person, and security fixes can skip the cooldown through a visible, commented exception. GitHub Actions are pinned to full commit SHAs, and the tools CI downloads are pinned and checksummed.

## Where agents fit

None of this was designed exclusively for AI, but agents are what made it necessary. A few things have worked well:

- **One instruction file per repo.** `AGENTS.md` holds the commands, the gates and the easy-to-break rules. `CLAUDE.md` is a symlink to it.
- **Skills for reference detail.** Long procedures move out of the main file and load only when they're relevant.
- **Exit codes over promises.** Agents are told that typecheck, lint, test and build must all exit zero. "It should work" doesn't count.
- **Prohibitions backed by code.** Telling an agent not to deploy is useful. Removing the deploy script is better.
- **Evals for anything that calls a model.** Prompt and model changes run against a baseline, with a spending cap on each run, the same way code runs against tests.

When an agent gets something wrong, the most durable fix is usually a check in the repo. It protects every future session, which a sentence asking the next one to be more careful can't do.

## Keep what fits

The process isn't identical everywhere, and it shouldn't be. Folio is a library, so it has no staging or promote and releases by version tag instead. Apple apps go through Xcode Cloud and TestFlight. Our larger platform deploys several Workers in a defined order and has a separate watcher to tell us when something's wrong. This site takes the same pattern and leaves out whatever it has no use for.

If you want to adopt some of this, I'd start in this order:

1. Deploy only from CI, and tag every deploy with its commit.
2. Put all your checks behind one gate.
3. Add a staging environment that deploys on merge.
4. Promote a specific, already-proven commit to production.
5. Make migrations expand-only, so rollback is safe.
6. Add the dependency cooldown. It's two lines and there's no reason to wait.

None of these ideas is new. What's changed is the cost of skipping them. When the volume of change goes up, the process is what lets you keep saying yes to it, and still know exactly what's running in production.
