name: deploy-safely description: Change infrastructure or release configuration one workload at a time, with a recorded rollback, a rendered-versus-live diff and a plan or dry run before anything is applied. Use when editing GitOps manifests or the GitOps repo, Helm values or charts, Kustomize overlays, Argo CD or Flux apps, Terraform, Kubernetes resources, bumping image tags or digests, replicas, cluster, DNS or cloud resources, or when asked to roll out, apply, sync or roll back a config change. Not for application code PRs (land) or checking the behaviour afterwards (prove-it-live). metadata: phase: ship
Deploy safely
Prepare one infrastructure or deploy-config change with its rollback recorded and its diff read, apply it only as far as the tier allows, and roll back if it isn't seen working.
When to use
- A GitOps manifest, Helm chart or values file, Kustomize overlay or Argo CD / Flux app changes.
- A Terraform plan, a Kubernetes resource, DNS or another cloud resource changes.
- A rollout, sync, apply or rollback of deploy configuration.
Not for: application code on its way to merge (../land/SKILL.md), or the behaviour check after release (../prove-it-live/SKILL.md).
Steps
ledger <cmd> below means python3 -I "$LEDGER" --root <workspace> <cmd> --task <task>, with LEDGER at ../ledger/scripts/ledger.py (Claude Code: ${CLAUDE_SKILL_DIR}/../ledger/scripts/ledger.py). run/ is the task's run folder. Tool-specific commands are in references/gitops-commands.md.
- Scope one change. Name the target (environment, cluster or account), the single workload or resource, and the blast radius. If the change touches more than one workload or concern, split it and land them one after another. Production and shared infrastructure are T3; an isolated staging target is T2 (
autonomy-by-stakes). Done when: the tracker item names target, workload and tier. - Record the known-good rollback. Before editing anything, capture what runs now: the live image digest, Helm or app revision, Terraform state serial, and the deploy-repo commit. Write
run/evidence/rollback-<id>.mdwith those values and the exact command that restores them. Done when: the file holds a rollback command you could run unchanged. - Edit in Git, minimally. Change only that workload. Pin images by digest, not a moving tag. Don't add prune, force, replace, cascade-delete or auto-approve options; if one seems needed, it is the human's call (
ledger block). Manual edits to live resources are out unless the target has no GitOps source. Done when:git diffshows one workload's intended change and nothing else. - Render, then diff against live. Render the desired state, run the server-side dry run or plan, and diff it against what is live. Save the output to
run/evidence/diff-<id>.txt. Read every changed line: deletions, replacements and anything outside the named workload stop the change. Re-run the diff immediately before applying; live state drifts. Done when: the saved diff shows only the intended change and no unexpected delete or replace. - Review and open the PR. Run
../review-change/SKILL.md; addsecurity-checkfor access, network or secret changes. Put the target, diff summary and rollback command in the PR body, then take the PR through CI with../land/SKILL.mdsteps 3–5. At T3, pushing to the deploy repo needs the human: commit locally and add the push command to the block in step 6. Done when: the PR is open with green checks, or the push is staged. - Apply within the tier. At T2, merge or apply this one change and wait for it to finish before starting another. At T3, stop with the change staged:
ledger block --id <id>-apply --need 'Approve and apply <workload> on <target>. Rollback: <rollback command>' --command '<apply command>'. Never join the two into one command line. If either is too long for the field, put it in a script underrun/and give its path. Done when: the change is applied, or the block holds the exact apply and rollback commands. - Watch health. Wait for the rollout or sync to finish and report healthy, and confirm the live digest or revision equals the one you intended. Watch errors and restarts for a few minutes. Then run
../prove-it-live/SKILL.mdfor the item. Done when: the target runs the intended revision, healthy, andprove-it-livehas a verdict. - Roll back on NOT VERIFIED. On
NOT VERIFIED, a failed rollout or a health regression, run the recorded rollback at T2 and confirm the known-good digest is live again. At T3, roll back yourself only if the charter pre-authorised it; otherwiseledger block --id <id>-rollback --need 'URGENT: roll back <workload>, NOT VERIFIED' --command '<rollback command>'and lead your reply with it.prove-it-livehas already moved the item back todoing; record the rollback withledger decide --decision 'Rolled back <workload> to <digest>' --why '<verdict>' --evidence evidence/rollback-<id>.md. Done when: known-good is live again, or the urgent rollback block exists and your reply leads with it.
Red flags
| If you're thinking | Do this instead |
|---|---|
| "Enable prune so the stale resources go away." | List the stale resources and ask. Never enable prune or destructive sync options without authority. |
| "Same change for all three services, one PR." | One workload at a time, each seen healthy before the next. |
| "The tag is fine, it points at the new build." | Pin the digest. Tags move; rollbacks need an exact target. |
| "The diff is mostly noise, skip reading it." | Read every line. An unexpected delete is a stop. |
| "The plan was clean this morning." | Re-plan right before apply. Live state drifts. |
"It's staging, I'll just kubectl edit it." |
Change it in Git. Live edits get reverted by sync and leave no record. |
| "The push to the deploy repo was denied; the API will work." | Record it in blocked and stop that step (denied-means-stop). |
| "The apply failed halfway; force it through." | Stop, keep the error, roll back to the recorded known-good. |
Verify
-
run/evidence/rollback-<id>.mdexisted before the first edit and holds an exact command. - The Git diff and the rendered diff each touch one workload or concern.
-
run/evidence/diff-<id>.txtwas read; no unexpected delete or replace. - No prune, force, replace or auto-approve option was added.
- At T3, nothing was pushed or applied; the block holds the apply command and names the rollback, as separate commands.
- After apply, the live digest or revision matches, health is good, and
prove-it-livehas a verdict.
Reply
Deploy <id> on <target>/<workload>: <applied | staged for you (T3) | rolled back>
Change: <one line>. Diff: run/evidence/diff-<id>.txt (<n> changed, <n> deleted)
Rollback: <known-good digest or revision>: `<rollback command>` (run/evidence/rollback-<id>.md)
Health: <rollout or sync status, live digest> at <time, time zone>
Verdict: <VERIFIED | NOT VERIFIED | INCONCLUSIVE | pending> (<evidence path>)
Waiting on you:
1. <need>: `<exact apply command>`
Credits
"Reversible, observable, incremental", rollback plans written before the deploy and post-deploy health watching follow Addy Osmani's shipping-and-launch; no skipped gates follows his ci-cd-and-automation. The GitOps rules (no prune, one workload at a time, known-good digest, rendered-versus-live diff) were learned in the author's own delegated runs.