# Making changes in production

> Every change reaches production the same way: as code, reviewed, tested where it can't touch production, and one step from a rollback.

Source: https://christwentyfour.com/strategy/changes-in-production

## The job

Get a change from a merge request to production without surprising anyone. [Reliability and change management](https://christwentyfour.com/strategy/reliability) says how many changes the error budget allows. This document says how each one gets there.

## What I value

These are the values the rest of the document optimizes for. When two of them pull apart, the left column wins.

| Worth more | Worth less |
| --- | --- |
| A change someone else reviewed | A change made fast from a console |
| A failure in QA | The same failure in production |
| A pipeline that goes red when the deploy fails | A pipeline that always looks green |
| A human decision on anything you can't undo in 5 minutes | An agent's speed |
| An action item that changes the system | A reminder to be more careful |

## One path, four environments

Every change takes the same path. Each step proves one more thing before the next one runs.

1. **dev** It builds and the unit tests pass.
2. **QA** It works with its neighbors. No network path to production.
3. **sandbox** It deploys and runs like production, on test data.
4. **prod** Smoke tests pass. Rollback is one job away.

QA is isolated from production on purpose. A test there can't reach a real customer, a real database, or a real payment, so you can run anything in it.

Skipping a step is allowed when production is broken. Then it is an emergency change: it gets recorded as one, and reviewed after the fact.

Rule: write the path down for each service: each environment, what it proves, who can deploy to it, and how to roll back.

## Changes are reviewed code

Infrastructure and application changes both go through a merge request. For infrastructure, the plan is the review. The pipeline runs the plan, posts it on the merge request, and a human reads it before anything applies. State lives in one managed place, so two people can't apply over each other.

The merge request is also the record. It says what changed, who approved it, and when. That is what an auditor asks for, and it is what you need at 3am to find the last change.

Rule: no change reaches production outside a merge request.

## Pipelines fail when the deploy fails

A pipeline that reports success while the new version never started is worse than no pipeline. You trust it, and you find out from a customer.

The deploy job waits until the service is running the new version. If it isn't, the job fails. Then smoke tests run against the environment: the health check reports the expected version, one read and one write succeed, and the dependencies answer. Any failure stops the pipeline before the next environment.

Rule: green means the new version is running and answering.

## Agents draft, a human approves

I use agents to prepare changes: read the state, run the plan, write the merge request, and draft the ticket. They don't approve their own work.

Everything waiting on a decision goes into one approval queue, sorted by risk. I work it once a day instead of being interrupted. An approval names the exact change, and it doesn't carry over to the next one.

The line for unattended work is the same one the reliability document uses. If a change can be undone in 5 minutes, the pipeline can ship it. If it can't, like a schema migration or a deleted resource, a human approves it first.

## When a change breaks something, fix the system

I run blameless postmortems. They ask what allowed the failure, and they use roles instead of names. Each action item has an owner and a ticket, and it changes the system: a new check in the pipeline, a guardrail, a test in QA.

## Diagnosis: what kind of change is this?

Answer these before you start. Each answer points to a runbook.

| If the change is | Run |
| --- | --- |
| Infrastructure: network, IAM, accounts, databases | [Terraform changes via merge request](https://christwentyfour.com/sre/terraform-changes-via-merge-request) |
| An application release | [Containers: blue/green, and rollback you have tested](https://christwentyfour.com/runbooks/containers#deploys) |
| Inside a compliance scope | [Change control in regulated environments](https://christwentyfour.com/sre/change-control-in-regulated-environments) |
| Proposed by an agent | [Human-in-the-loop approval patterns](https://christwentyfour.com/sre/human-in-the-loop-approvals) |
| A new service with no path yet | [Onboarding a new service](https://christwentyfour.com/sre/onboarding-a-new-service) |
| A repo without a protected branch or required review | [Repo governance and branch protection](https://christwentyfour.com/sre/repo-governance-and-branch-protection) |
| Already broken in production | [Incident triage](https://christwentyfour.com/sre/incident-triage), then roll back the last change |
| Done, and it caused an incident | [Postmortems](https://christwentyfour.com/sre/postmortems) |

Then two more questions. Can you undo it in 5 minutes? If not, it needs a named approver. Has it passed QA and sandbox? If not, it is an emergency change, and you record it as one.

## Takeaways

These are the guiding principles for production changes. They follow from the values above.

1. Every production change is code in a merge request. For infrastructure, a human reads the plan before it applies.
2. One path for every change: dev, QA, sandbox, production. Skipping a step is an emergency change.
3. Test where a mistake can't reach production. QA has no network path to it.
4. A failed deploy fails the pipeline. Green means the new version is running and the smoke tests pass.
5. If you can undo it in 5 minutes, the pipeline ships it. If not, a human approves that exact change.
6. Agents draft. A human approves. An approval never carries over.
7. Postmortem action items change the system, not a person.
8. Done is never just "it works". It can be changed safely, it's observable, it's documented, and the trade-off is recorded.

## What you can produce

With the values and the path above, you or your agent should be able to make these for your own services:

1. A path document for a service: each environment, what it proves, who can deploy to it, and the rollback.
2. A merge request template: what changes, the plan output, the blast radius, and the rollback.
3. A deploy stage that fails when the new version doesn't start, followed by smoke tests that check the version, one read, one write, and the dependencies.
4. A change policy: which changes are standard and ship on the pipeline, which need a named approver, and what counts as an emergency.
5. An approval queue for your agents: one file, sorted by risk, worked once a day.
6. A postmortem from an incident timeline, with action items that each change the system.

## Tools

Everything above is in one repo you can clone: [how-i-work](https://github.com/rooschristopher/how-i-work). [llms.txt](https://christwentyfour.com/llms.txt) has the exact steps to copy it.

| For | Use |
| --- | --- |
| Writing the path for a service | [templates/path-document.md](https://github.com/rooschristopher/how-i-work/blob/main/templates/path-document.md) |
| Every merge request | [templates/merge-request.md](https://github.com/rooschristopher/how-i-work/blob/main/templates/merge-request.md) |
| Smoke tests after every deploy | [templates/smoke-tests.md](https://github.com/rooschristopher/how-i-work/blob/main/templates/smoke-tests.md) |
| A deploy pipeline that checks the files landed and the site answers | [templates/ci/github-actions-static-site-s3-cloudfront.yml](https://github.com/rooschristopher/how-i-work/blob/main/templates/ci/github-actions-static-site-s3-cloudfront.yml) |
| Changes inside a compliance scope | [templates/release-change-ticket.txt](https://github.com/rooschristopher/how-i-work/blob/main/templates/release-change-ticket.txt) |
| Agents that draft and a human who approves | [templates/approval-queue.md](https://github.com/rooschristopher/how-i-work/blob/main/templates/approval-queue.md) |
| Watching every app after a change | [dashboards/http-checks/](https://github.com/rooschristopher/how-i-work/tree/main/dashboards/http-checks) |
| Reviewed infrastructure | [infra-modules/](https://github.com/rooschristopher/how-i-work/tree/main/infra-modules) |
| Postmortems | [templates/postmortem.md](https://github.com/rooschristopher/how-i-work/blob/main/templates/postmortem.md) |
