Deployment Strategies skill for Codex
Ship to 5% first, roll back in a minute. Codex picks a release strategy from the service's risk, traffic and rollback needs, then implements it: rolling updates that never drop capacity, blue-green switches at the load balancer, Argo Rollouts canaries gated by Prometheus success-rate queries, and flag-based dark launches. Gates and rollback triggers are written before deploying, schemas follow expand and contract, and production changes wait for your approval.
curl -fsSL codexskills.dev/install.sh \ | sh -s -- deployment-strategies Installs to ~/.agents/skills/deployment-strategies/ for every project on this machine.
curl -fsSL codexskills.dev/cli.mjs -o codex-skills.mjsnode codex-skills.mjs install deployment-strategies The CLI also searches, updates and removes skills. Run it with no arguments to pick from a list. Needs Node 20.12+.
curl -fsSL codexskills.dev/install.sh \ | sh -s -- --project deployment-strategies Installs to .agents/skills/deployment-strategies/ in the current repository. Commit it and everyone who runs Codex there gets it.
curl -fsSLO codexskills.dev/downloads/deployment-strategies.zipunzip -o deployment-strategies.zip -d ~/.agents/skills/ The archive holds the skill folder with its generated agents/openai.yaml. Unzip into .agents/skills/ to scope it to a repo.
& ([scriptblock]::Create((irm codexskills.dev/install.ps1))) deployment-strategies PowerShell 5.1 or 7. Installs to %USERPROFILE%\.agents\skills\. Add -Project for the current repo.
104-line POSIX script. No sudo, no telemetry. Read install.sh
Use it in Codex
Start a prompt with $deployment-strategies, or pick it from /skills.
You can also just describe the task: Codex reads the description below and loads the playbook when your request matches.
What Codex reads before loading it
Chooses and implements release strategies - Kubernetes rolling updates with maxSurge and maxUnavailable, blue-green switches, metric-gated canaries with Argo Rollouts or Flagger, load balancer weighted routing, and feature-flag dark launches - with readiness probes, expand-and-contract database migrations, automated rollback triggers and explicit go/no-go thresholds. Use when designing how a service ships to production, a deploy caused downtime, a team wants canaries or instant rollback, or a schema change must ship without breaking running versions.
Use it when
- A deploy caused downtime or errors during rollout
- A high-traffic service needs progressive delivery with metric gates
- Rollback is slow or requires a rebuild
- A schema change must coexist with the running version
Use something else when
- You only need the flag system and its code paths: use feature-flags
- The problem is migration SQL safety under load: use zero-downtime-migrations
How to check the result
A deliberately broken version in staging is halted or rolled back automatically with no user-facing errors, and the rollback time is measured and recorded.
The mistake it prevents
Running a canary on a low-traffic service where each step sees too few requests for the error-rate gate to mean anything.
A safe deploy lets old and new versions run side by side, exposes the new version to a small, measurable slice of traffic first, decides promotion from metrics with thresholds written down beforehand, and rolls back in under a minute without a new build. The strategy is chosen from the service’s risk and infrastructure, not from fashion.
Inspect first
- Read
AGENTS.md, the deploy pipeline and manifests (k8s/, Helm charts, ECS task definitions, Terraform for load balancers). - Answer these before choosing:
- Can two versions run at once? (DB schema, message formats, session state, caches)
- What is the rollback today, and how long does it take?
- Which metrics show user harm within minutes? (5xx rate, p99 latency, error logs, business events like checkouts per minute)
- How much traffic? Canary statistics need enough requests per step.
- Check health endpoints and readiness probes. Without a readiness signal, no strategy is safe.
Choose
| Situation | Strategy |
|---|---|
| Stateless service, good tests, low risk | Rolling update |
| Need instant full rollback, can afford 2x capacity briefly | Blue-green |
| High traffic, user-facing, metrics available | Canary with automated analysis |
| Risky behaviour change in otherwise safe code | Feature flag, deploy dark, release gradually |
| Low traffic (under ~1 req/s) | Blue-green or flag; canary statistics will be noise |
| Stateful singleton, schema-locked app | Maintenance window or recreate, announced in advance |
Deploying code and releasing behaviour are separate decisions; flags let you do the second without the first.
Rolling update (Kubernetes default)
spec:
replicas: 6
minReadySeconds: 10
progressDeadlineSeconds: 600
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 0 # never drop below desired capacity
template:
spec:
terminationGracePeriodSeconds: 45
containers:
- name: api
readinessProbe:
httpGet: { path: /healthz/ready, port: 8080 }
periodSeconds: 5
failureThreshold: 3
lifecycle:
preStop:
exec: { command: ["sleep", "10"] } # let endpoints drain before SIGTERM handling
- Readiness must check what the pod needs to serve (config loaded, DB pool up), not downstream services that would make every pod unready at once.
- The app must handle SIGTERM: stop accepting, finish in-flight requests, exit within the grace period.
- Pair with a PodDisruptionBudget so node drains do not stack with a rollout.
- Rollback:
kubectl rollout undo deployment/apiandkubectl rollout statusto watch.
Blue-green
- Two full environments; the router (Service selector, load balancer target group, DNS weight) points at one. Deploy to idle, smoke test it directly, switch, keep the old one warm for the rollback window (typically 30 to 60 minutes), then scale it down.
- Kubernetes: two Deployments labelled
version: blue|green; switch the Service selector. - AWS: CodeDeploy blue/green for ECS, or ALB listener rules with weighted target groups.
- DNS-based switches are slow and uneven because resolvers cache; prefer load-balancer switches.
- Background workers and cron must only run in the live colour, or jobs run twice.
Canary with automated analysis
Argo Rollouts example:
apiVersion: argoproj.io/v1alpha1
kind: Rollout
spec:
strategy:
canary:
canaryService: api-canary
stableService: api-stable
trafficRouting:
nginx: { stableIngress: api }
analysis:
templates: [{ templateName: success-rate }]
startingStep: 1
steps:
- setWeight: 5
- pause: { duration: 10m }
- setWeight: 25
- pause: { duration: 10m }
- setWeight: 50
- pause: { duration: 10m }
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata: { name: success-rate }
spec:
metrics:
- name: success-rate
interval: 1m
failureLimit: 2
successCondition: result[0] >= 0.995
provider:
prometheus:
address: http://prometheus.monitoring:9090
query: |
sum(rate(http_requests_total{service="api-canary",code!~"5.."}[2m]))
/
sum(rate(http_requests_total{service="api-canary"}[2m]))
- Write the gates before the deploy: for example, canary 5xx rate no more than 0.5 percentage points above stable, p99 latency no more than 20% above stable, zero new crash loops. Compare canary to stable over the same window rather than to a fixed number when traffic varies by time of day.
- Each step needs enough requests to detect the regression you care about; at 5% of 50 req/s, 10 minutes is 1,500 requests, enough to see a 1% error rate, not 0.1%.
- Flagger offers the same loop with a
Canaryresource for Istio, Linkerd, NGINX or Gateway API. - Sticky sessions or per-user hashing keep a user on one version; otherwise users bounce between UIs.
Feature-flag releases
- Ship code dark behind a flag defaulted off, enable for staff, then 1%, 10%, 50%, 100%.
- Use percentage rollout keyed on a stable user or account ID, not random per request.
- Every flag gets an owner and a removal date; stale flags become untested branches.
- Hand flag implementation details to
feature-flags.
Database changes: expand and contract
Two versions run at once during every non-recreate deploy, so the schema must serve both.
- Expand: add nullable column or new table; deploy code that writes both old and new.
- Backfill in batches.
- Switch reads to the new shape; deploy.
- Contract: stop writing the old shape, then drop it in a later release.
Never rename or drop a column in the same release that stops using it. Detailed patterns
live in zero-downtime-migrations.
Rollback rules
- Rollback must redeploy a previous artifact, never rebuild from an older commit.
- Define triggers in the runbook: any gate failure, error budget burn over 10x for 5 minutes, or on-call judgement. Rollback first, investigate after.
- Rolling back code does not roll back data. If the new version wrote data the old one cannot read, the expand-and-contract steps above were skipped.
Confirmation
Production deploys, traffic shifts, promotions and aborts change what users see. Prepare
the manifests and commands, show them, and wait for the user’s explicit go-ahead before
running kubectl apply, kubectl argo rollouts promote, or any pipeline deploy against
production.
Verification
- Staging rollout with a deliberately failing version (bad readiness or injected 500s) stops or auto-rolls back without user-facing errors
- Load test during a rollout shows no dropped requests (check for 502/503 at the edge)
- Rollback timed end to end and recorded
- Gates and thresholds written in the runbook
Output template
## Deployment plan: <service>
Strategy: canary (5 -> 25 -> 50 -> 100%, 10 min steps)
Gates: 5xx delta <= 0.5 pp vs stable; p99 <= 1.2x stable; no restarts
Rollback: `kubectl argo rollouts abort api` (auto on 2 failed analyses), measured 40 s
Schema: expand-only this release; contract scheduled for vX.Y+1
Prerequisites: readiness probe on /healthz/ready, preStop sleep, PDB minAvailable 4 What the zip contains
SKILL.md plus the interface file below. Nothing runs on install.
agents/openai.yaml
Gives the Codex app a display name, a one-line description and a starter prompt for this skill.
interface:
display_name: "Deployment Strategies"
short_description: "Ship to 5% first, roll back in a minute"
default_prompt: "$deployment-strategies Our deploys cause a few seconds of 502s, make Kubernetes rollouts zero-downtime" About this skill
Written and maintained by the Codex Skills editors to the same editorial standard as every skill here: a selective description, a real workflow, known pitfalls and a way to verify the work. First published , last updated . MIT licensed. Something wrong or out of date? Tell us.