The 3 a.m. page is a ritual most engineers know too well: a Kubernetes pod is CrashLooping, the CI pipeline turned red on a Friday deploy, and the Dockerfile that worked yesterday now pulls a 2 GB image because someone forgot --no-install-recommends. ChatGPT won't replace your judgment, but it can be the second pair of eyes that turns a two-hour panic into a ten-minute fix.
Below are ten prompts I actually use for everyday infrastructure work. Each one is a task, a copy-paste prompt, and an example of what comes back. They are grounded in real tooling — Docker's official reference, GitHub Actions docs, the Kubernetes API — so you can verify every command against the upstream docs (docs.docker.com, kubernetes.io/docs, docs.github.com/actions).
1. The Dockerfile diet: shrink the image before it ships
Task: turn a bloated node:latest image into a multi-stage build.
Prompt:
You are a Docker expert. Rewrite this Dockerfile as a multi-stage build
using node:20-alpine. Keep only production deps in the final stage,
run as a non-root user, and explain each layer's purpose.
<Dockerfile here>
Example result: the model splits deps (install with npm ci --omit=dev), build, and a slim runtime stage, adds USER node, and notes that COPY --chown avoids a later chown layer. Verify with docker image ls — a typical Node app drops from ~1.1 GB to under 200 MB.
2. Debugging a red pipeline from logs alone
Task: diagnose a GitHub Actions failure without clicking through the UI.
Prompt:
Here are the last 150 lines of a failed GitHub Actions job. Identify the
root cause, quote the exact failing line, and give me a minimal fix
plus a one-line command to reproduce it locally.
<logs>
Example result: it spots error: failed to solve: process "/bin/sh -c npm ci" did not complete successfully caused by a missing package-lock.json, and suggests npm install --package-lock-only before committing. The fix is real and reproducible with docker build ..
3. Turning a manual deploy into a CI/CD workflow
Task: generate a GitHub Actions pipeline from a shell script.
Prompt:
Convert this deploy script into a GitHub Actions workflow. Use
actions/checkout@v4 and actions/setup-node@v4 with Node 20, cache npm,
run tests on PRs only, and deploy on push to main. Add a concurrency
group so two deploys never overlap.
<script>
Example result: a YAML with on: {pull_request: {}, push: {branches: [main]}}, concurrency: {group: deploy-${{ github.ref }}, cancel-in-progress: true}, and a needs: test gate — all valid per GitHub's workflow syntax reference.
4. The Kubernetes pod whisperer: reading kubectl describe
Task: explain why a pod is stuck.
Prompt:
This is output from `kubectl describe pod`. Classify the failure
(CrashLoopBackOff, ImagePullBackOff, OOMKilled, Pending), explain the
cause, and give me the next three kubectl commands to run.
<describe output>
Example result: for OOMKilled with restartCount: 7, it explains the container hit its memory limits, then suggests kubectl top pod <name>, kubectl get pod <name> -o yaml | grep -A5 resources, and raising resources.limits.memory — all real commands from the kubectl reference.
5. Writing a sane docker-compose.yml for local dev
Task: stand up app + Postgres + Redis locally.
Prompt:
Write a docker-compose.yml (Compose spec, no `version:` key) for a Node
app, Postgres 16, and Redis 7. Add healthchecks, a named volume for
Postgres data, and depends_on with condition: service_healthy.
Example result: a Compose file using healthcheck: {test: ["CMD-SHELL", "pg_isready -U postgres"], interval: 5s} and depends_on: {db: {condition: service_healthy}} — matching the current Compose specification.
6. Terraform drift and safety review
Task: catch destructive changes before apply.
Prompt:
Review this `terraform plan` output. Flag any resource marked for
destroy or replace, explain the blast radius, and suggest how to avoid
downtime (e.g., create_before_destroy).
<plan output>
Example result: it highlights -/+ aws_db_instance.main (forced replacement) and recommends lifecycle { create_before_destroy = true } plus a maintenance window — a genuine Terraform meta-argument.
7. Nginx reverse proxy with TLS in one shot
Task: put a service behind HTTPS.
Prompt:
Write an nginx server block that reverse-proxies to http://app:3000,
redirects HTTP to HTTPS, sets HSTS, and includes WebSocket upgrade
headers. Use a Let's Encrypt cert path.
Example result: a config with proxy_set_header Upgrade $http_upgrade; and proxy_set_header Connection "upgrade";, add_header Strict-Transport-Security "max-age=31536000" always; — standard directives from the nginx docs.
8. Monitoring and alerting that doesn't cry wolf
Task: draft Prometheus alert rules.
Prompt:
Write Prometheus alerting rules for: pod restarting >3 times in 10m,
node CPU >85% for 15m, and 5xx rate >2% over 5m. Use for: durations
and add a runbook_url annotation to each.
Example result: valid YAML with expr: rate(http_requests_total{status=~"5.."}[5m]) / rate(http_requests_total[5m]) > 0.02 and for: 5m — syntactically correct PromQL from the official alerting rules guide.
9. Kubernetes manifest review before kubectl apply
Task: lint a Deployment for production readiness.
Prompt:
Review this Deployment YAML. Check for: missing resource requests/limits,
no liveness/readiness probes, `latest` image tag, no securityContext.
Return a corrected manifest and list every change.
<yaml>
Example result: it adds resources.requests.cpu: 100m, a readinessProbe on /healthz, pins image: app:1.4.2, and sets securityContext: {runAsNonRoot: true} — all fields from the Kubernetes Pod spec.
10. The postmortem that actually gets read
Task: turn an incident timeline into a blameless postmortem.
Prompt:
Turn this incident timeline into a blameless postmortem: summary,
impact, timeline, root cause, and 3 action items with owners.
<timeline>
Example result: a structured doc where the root cause is separated from contributing factors, and action items are concrete ("add a readiness probe", "pin base image digest") rather than vague "improve monitoring".
| Prompt | When to reach for it |
|---|---|
| Dockerfile diet | Image too large / slow pulls |
| Pipeline logs | CI red, no obvious cause |
| CI/CD generator | Manual deploy → automation |
| Pod whisperer | CrashLoop / OOM / Pending |
| Compose file | Local dev environment |
| Terraform review | Before apply |
| Nginx + TLS | Exposing a service |
| Prometheus rules | Alert fatigue |
| Manifest review | Pre-deploy lint |
| Postmortem | After an incident |
None of these prompts are magic — they are structured questions that force the model to reason against real documentation. Always verify generated commands and manifests against the upstream docs before running them in production, and never paste secrets into a prompt. Used that way, ChatGPT becomes the calm colleague who has read every man page and never needs coffee at 3 a.m.
Comments