Skip to content

Lesson 4 of 9 · 24m

Procedures That Survive Copy-Paste

Operational steps must encode ordering, verification, permissions, and rollback — because readers will execute fragments under stress.

The most dangerous documentation sentence is "then simply run." Nothing is simple at 2 a.m., and readers will copy individual commands out of sequence no matter how elegant the prose around them is. Good procedures accept that behavior. They make each step checkable, dangerous operations explicit, and recovery part of the main path rather than an afterthought.

A procedure is a state machine

Each step should establish a precondition, perform a bounded action, and verify a new state:

### 3. Enable read-only mode

Precondition: `app.maintenance` is `false` and traffic is healthy.

```bash
curl -X POST https://api.internal.example/v1/runtime/flags   -H "Authorization: Bearer $ADMIN_TOKEN"   -H "Content-Type: application/json"   -d '{"key":"read_only","enabled":true}'
```

Verify:

```bash
curl -s https://api.internal.example/v1/runtime/flags/read_only | jq .enabled
# expected: true
```

Notice what this does not require: faith. The reader knows what should be true before and after. That matters when a step partially succeeds or the terminal scrollback is lost.

Put prerequisites where they are needed

A global prerequisites section is necessary but insufficient. If step 7 is the first step requiring root, say so at step 7. If step 4 destroys sessions, warn there. People enter procedures in the middle from search results and incident notes.

Make placeholders impossible to misread

Use consistent, uppercase placeholders with delimiters:

psql "host=$DATABASE_HOST dbname=$DATABASE_NAME user=$DATABASE_USER sslmode=require"

Never use <password> in one command, $PASS in another, and "your password" in prose. Say exactly where each value comes from and whether it is secret. If a value appears in shell history or logs, warn before the command, not after.

Encode rollback, not just recovery optimism

Rollback instructions belong beside the forward path:

If verification fails, restore the previous configuration:

```bash
cp /etc/myapp/config.toml.bak /etc/myapp/config.toml
systemctl reload myapp
```

Confirm rollback with `systemctl is-active myapp` and one authenticated API request.

"Contact support" is not rollback. Neither is "undo the previous steps." Write the inverse operation while you still understand the forward one.

Prefer idempotent operations where possible

Commands that fail safely when run twice reduce incident stress. Where the system is not idempotent, say exactly what happens on a second run. Migrations, user creation, and certificate issuance often have surprising repeat behavior.

Field notes

  • Numbered steps imply sequence; bullets imply independence. Do not use bullets for ordered actions.
  • Put destructive commands in their own step with a warning directly above them.
  • Verification should use the same interface users depend on, not only internal status — systemctl is-active is not proof the login flow works.
  • A procedure that has never been executed from a clean account is a draft, regardless of who wrote it.

Was this lesson helpful?

Sign in to rate