sop-writing
Core Philosophy
A Standard Operating Procedure (SOP) is not a theoretical essay or an aspirational policy document. An SOP is an executable algorithmic runbook for human or agentic operators. A great SOP is designed so that a qualified operator under extreme stress at 3:00 AM can execute the process with zero ambiguity, zero guesswork, and zero catastrophic errors. Every step must have deterministic inputs, numbered physical actions, observable acceptance criteria, and explicit escalation paths.
4-Step Standard Operating Procedure (SOP) Architecture
Step 1: Scope, Governance & Pre-Flight Prerequisites
- Metadata & Ownership Header:
- SOP ID, Version (SemVer), Effective Date, Review Cadence (Annual/Bi-annual), Accountable Process Owner.
- Strict Purpose & Scope Boundaries:
- Exactly what this procedure covers, and what it does not cover.
- Prerequisites & Access Permissions:
- List required credentials, VPN access, software packages, and environment variables before the first execution step.
Step 2: The Deterministic Numbered Step Sequence
- Imperative, Unambiguous Action Verbs:
- Begin every step with an active verb: Click, Run, Verify, Copy, Export, Check.
- Never write passive guidelines: "Ensure that logs are looked at."
- Write: "1. Open Datadog dashboard
Prod-Ingestion. 2. Inspect graph p99 Latency. 3. Verify value is below 200ms."
- Copy-Paste Command Hygiene:
- Provide exact CLI commands or code snippets in fenced blocks. Never make operators guess flag names or parameters.
Step 3: Observable Verification & Acceptance Gates
- The "How Do I Know It Worked?" Check:
- Every major step must specify its expected output:
- "Expected Output: Terminal displays
Deployment Complete: 12/12 pods healthy."
- Decision Trees & Branching Logic:
- Format conditional logic clearly:
- If status == 200: Proceed to Step 4.
- If status == 500: Jump to Troubleshooting Section 5.1.
Step 4: Failure Handling, Rollback & Escalation Paths
- The Rollback Runbook:
- If the procedure fails mid-stream, provide exact rollback commands to restore the system to a safe baseline state.
- Escalation SLA & Contact Matrix:
- Who to page, on what channel, with what severity, if the procedure cannot be completed within 15 minutes.
Deliverable Format: Production Standard Operating Procedure (SOP-TEMPLATE.md)
# Standard Operating Procedure: Production Hotfix Deployment
*SOP ID: SOP-ENG-042 | Version: v2.1.0 | Owner: Platform Engineering Lead*
*Effective Date: [YYYY-MM-DD] | Review Cadence: Quarterly*
## 1. Purpose & Scope
This procedure governs the deployment of emergency hotfixes to production clusters outside the standard weekly CI/CD release cycle.
## 2. Prerequisites & Access Requirements
- Production AWS IAM Role `arn:aws:iam::123456789012:role/EmergencyDeployer`
- GitHub CLI (`gh`) authenticated with repository write access
- AWS CLI v2 and `kubectl` configured locally
## 3. Step-by-Step Execution Sequence
### Step 1: Branch Isolation & Verification
1. Checkout hotfix branch from `main`:
```bash
git checkout main && git pull origin main
git checkout -b hotfix/SEC-[IssueNum]
- Run full test suite locally:
npm run test:ci
- Acceptance Check: Exit code 0; all test suites pass.
Step 2: Build & Tag Container Image
- Trigger automated hotfix build pipeline:
gh workflow run hotfix-build.yml -f branch=hotfix/SEC-[IssueNum]
- Expected Output: GitHub Actions emits image digest
sha256:....
Step 3: Production Rollout & Canary Verification
- Apply rollout to Canary pod pool (10% traffic):
kubectl set image deployment/api-gateway api=ecr.internal/api:[Digest] -n production
- Monitor error rates for 5 minutes:
- Check Grafana dashboard
https://grafana.internal/d/canary-health.
- Acceptance Gate: 5xx error rate must remain < 0.01%.
4. Rollback & Contingency Plan
If Canary error rate exceeds 0.05%:
- Roll back deployment immediately:
kubectl rollout undo deployment/api-gateway -n production
- Notify Incident Commander on Slack
#incident-war-room.
5. Escalation Contacts
- Primary On-Call SRE: PagerDuty schedule
sre-tier-1
- Engineering VP: Phone: [Number] (Page if outage exceeds 15 minutes)
---
## Worked Example: Database Restoration SOP
- **Context**: Recovery runbook for encrypted PostgreSQL database snapshot restoration.
- **Impact**: Step-by-step SOP allowed a junior engineer on night rotation to restore an accidentally dropped customer table in 11 minutes with zero data corruption.
---
## Verification Checklist
- [ ] Every procedural step starts with an active imperative verb.
- [ ] Commands and code snippets are 100% copy-pasteable with exact syntax.
- [ ] Expected observable output is specified for every critical step.
- [ ] Explicit rollback procedures are documented for failed executions.
- [ ] Escalation contact matrix includes named roles and paging channels.
---
## Anti-Patterns
- **Ambiguous Instructions**: Writing "Configure the network properly" instead of providing the exact IP tables or YAML config.
- **Missing Rollback Runbook**: Explaining how to push a change without explaining how to revert it if it breaks.
- **Untested Runbooks**: Writing an emergency disaster recovery SOP that has never been dry-run in a staging environment.
1---2name: sop-writing3description: Write procedures anyone can follow: numbered steps, owners, inputs, outputs, escalation and executable templates. Use when authoring Standard Operating Procedures, runbooks, or checklists.4---56# sop-writing78## Core Philosophy9A Standard Operating Procedure (SOP) is not a theoretical essay or an aspirational policy document. An SOP is an executable algorithmic runbook for human or agentic operators. A great SOP is designed so that a qualified operator under extreme stress at 3:00 AM can execute the process with zero ambiguity, zero guesswork, and zero catastrophic errors. Every step must have deterministic inputs, numbered physical actions, observable acceptance criteria, and explicit escalation paths.1011---1213## 4-Step Standard Operating Procedure (SOP) Architecture1415### Step 1: Scope, Governance & Pre-Flight Prerequisites161. **Metadata & Ownership Header**:17 - SOP ID, Version (SemVer), Effective Date, Review Cadence (Annual/Bi-annual), Accountable Process Owner.182. **Strict Purpose & Scope Boundaries**:19 - Exactly what this procedure covers, and what it does *not* cover.203. **Prerequisites & Access Permissions**:21 - List required credentials, VPN access, software packages, and environment variables *before* the first execution step.2223### Step 2: The Deterministic Numbered Step Sequence241. **Imperative, Unambiguous Action Verbs**:25 - Begin every step with an active verb: *Click, Run, Verify, Copy, Export, Check*.26 - Never write passive guidelines: "Ensure that logs are looked at."27 - Write: *"1. Open Datadog dashboard `Prod-Ingestion`. 2. Inspect graph `p99 Latency`. 3. Verify value is below 200ms."*282. **Copy-Paste Command Hygiene**:29 - Provide exact CLI commands or code snippets in fenced blocks. Never make operators guess flag names or parameters.3031### Step 3: Observable Verification & Acceptance Gates321. **The "How Do I Know It Worked?" Check**:33 - Every major step must specify its expected output:34 - *"Expected Output: Terminal displays `Deployment Complete: 12/12 pods healthy`."*352. **Decision Trees & Branching Logic**:36 - Format conditional logic clearly:37 - *If status == 200*: Proceed to Step 4.38 - *If status == 500*: Jump to Troubleshooting Section 5.1.3940### Step 4: Failure Handling, Rollback & Escalation Paths411. **The Rollback Runbook**:42 - If the procedure fails mid-stream, provide exact rollback commands to restore the system to a safe baseline state.432. **Escalation SLA & Contact Matrix**:44 - Who to page, on what channel, with what severity, if the procedure cannot be completed within 15 minutes.4546---4748## Deliverable Format: Production Standard Operating Procedure (`SOP-TEMPLATE.md`)4950```markdown51# Standard Operating Procedure: Production Hotfix Deployment52*SOP ID: SOP-ENG-042 | Version: v2.1.0 | Owner: Platform Engineering Lead*53*Effective Date: [YYYY-MM-DD] | Review Cadence: Quarterly*5455## 1. Purpose & Scope56This procedure governs the deployment of emergency hotfixes to production clusters outside the standard weekly CI/CD release cycle.5758## 2. Prerequisites & Access Requirements59- Production AWS IAM Role `arn:aws:iam::123456789012:role/EmergencyDeployer`60- GitHub CLI (`gh`) authenticated with repository write access61- AWS CLI v2 and `kubectl` configured locally6263## 3. Step-by-Step Execution Sequence6465### Step 1: Branch Isolation & Verification661. Checkout hotfix branch from `main`:67 ```bash68 git checkout main && git pull origin main69 git checkout -b hotfix/SEC-[IssueNum]70 ```712. Run full test suite locally:72 ```bash73 npm run test:ci74 ```75 - *Acceptance Check*: Exit code 0; all test suites pass.7677### Step 2: Build & Tag Container Image781. Trigger automated hotfix build pipeline:79 ```bash80 gh workflow run hotfix-build.yml -f branch=hotfix/SEC-[IssueNum]81 ```82 - *Expected Output*: GitHub Actions emits image digest `sha256:...`.8384### Step 3: Production Rollout & Canary Verification851. Apply rollout to Canary pod pool (10% traffic):86 ```bash87 kubectl set image deployment/api-gateway api=ecr.internal/api:[Digest] -n production88 ```892. Monitor error rates for 5 minutes:90 - Check Grafana dashboard `https://grafana.internal/d/canary-health`.91 - *Acceptance Gate*: 5xx error rate must remain < 0.01%.9293## 4. Rollback & Contingency Plan94If Canary error rate exceeds 0.05%:951. Roll back deployment immediately:96 ```bash97 kubectl rollout undo deployment/api-gateway -n production98 ```992. Notify Incident Commander on Slack `#incident-war-room`.100101## 5. Escalation Contacts102- **Primary On-Call SRE**: PagerDuty schedule `sre-tier-1`103- **Engineering VP**: Phone: [Number] (Page if outage exceeds 15 minutes)104```105106---107108## Worked Example: Database Restoration SOP109110- **Context**: Recovery runbook for encrypted PostgreSQL database snapshot restoration.111- **Impact**: Step-by-step SOP allowed a junior engineer on night rotation to restore an accidentally dropped customer table in 11 minutes with zero data corruption.112113---114115## Verification Checklist116117- [ ] Every procedural step starts with an active imperative verb.118- [ ] Commands and code snippets are 100% copy-pasteable with exact syntax.119- [ ] Expected observable output is specified for every critical step.120- [ ] Explicit rollback procedures are documented for failed executions.121- [ ] Escalation contact matrix includes named roles and paging channels.122123---124125## Anti-Patterns126127- **Ambiguous Instructions**: Writing "Configure the network properly" instead of providing the exact IP tables or YAML config.128- **Missing Rollback Runbook**: Explaining how to push a change without explaining how to revert it if it breaks.129- **Untested Runbooks**: Writing an emergency disaster recovery SOP that has never been dry-run in a staging environment.