Infrastructure as code was already code, and AI coding tools treat it that way. Claude Code, Cursor, GitHub Copilot, and Windsurf will write a Terraform module from a description, convert a Jenkinsfile to GitHub Actions, add a Helm values override, and explain why a pod is stuck in CrashLoopBackOff. Chat assistants decode a wall of kubectl output and turn an incident channel into a postmortem draft.
The value is uneven in a useful way. Boilerplate, migrations between tools, and one-off scripts get dramatically faster. Decisions about failure domains, cost, and what to observe do not, and generated infrastructure tends toward whatever was most common in training data, which is not always secure or cheap. Datadog, PagerDuty, and Grafana are adding assistants of their own; check what your plan includes.
The stakes are higher than in application code because the feedback loop is production. A wrong default in a security group, a plan that destroys and recreates a database, a pipeline step that echoes a secret into logs, or an agent that runs 'terraform apply' because a README told it to are all real outcomes. Plan output, least privilege, and reading every diff are non-negotiable.
Quick wins this week
- Paste 'kubectl describe pod' output plus the last 50 log lines and ask for ranked causes and the exact read-only command to confirm each, before you start guessing at resource limits.
- Give the assistant a Terraform plan and ask for a plain-English summary of what will be created, changed, and destroyed, destroys listed first.
- Have Claude Code or Cursor write the Bash you keep rewriting (log rotation, certificate checks, cleanup) with strict mode, a dry-run flag, and comments, then read it before it runs anywhere shared.
- Turn an incident channel export into a postmortem draft with timeline, contributing factors, and action items, then remove the blame and the invented causes the model inserted.
What AI can do for devops engineers, task by task
Infrastructure as code with an agent
Describe the resource, the environment, the provider version, and the constraints (tagging policy, no public ingress, encryption at rest, approved module registry) and ask for the code plus the plan you expect. Run terraform plan yourself and read it; the agent's idea of 'done' is code that validates, not infrastructure that is safe. Pin provider versions; models lag current schemas.
CI/CD pipelines and migrations
Paste the existing pipeline and ask for the equivalent in the target system with a table mapping each old step to a new one and noting anything without an equivalent. Check secrets handling, caching, and the workflow token's permissions; generated Actions often request write access to everything. Run both pipelines in parallel on a branch before switching.
Kubernetes and container debugging
Give the pod describe output, recent events, the deployment manifest, and the logs, and ask for ranked causes, the confirming command for each, and the smallest change that would fix it. Redact registry credentials and internal hostnames first. Apply fixes to a namespace you can afford to break before anything shared.
Incident response and postmortems
During the incident, paste log and metric excerpts into a chat for a second set of eyes on what changed. Afterward, export the channel and ask for a blameless postmortem: timeline, detection gap, contributing factors, what went well, action items with owners. Read for invented causes; the model prefers a clean narrative to your messy reality.
Runbooks, on-call docs, and architecture docs
Paste the scripts, alert definitions, and tribal knowledge from Slack and ask for a runbook per alert: what it means, first checks, safe mitigations, escalation, and how to verify recovery. Generate architecture docs from the code and check them against reality; docs that describe last year's topology are worse than none.
Security and cost review of infrastructure code
Give the assistant a Terraform module, a Kubernetes manifest, or a Dockerfile and ask for a review against a checklist: least-privilege IAM, open security groups, unpinned images, missing resource limits, oversized instances, logging gaps. Treat findings as a first pass; it misses context and flags things you did on purpose. Pair it with a real scanner such as Checkov or Trivy.
Prompts for devops engineers
Replace the bracketed placeholders, paste into any chat assistant, and iterate on the result.
Task brief for infrastructure changes with an agent
You are a senior platform engineer working in this repository. Change requested: [DESCRIBE THE INFRASTRUCTURE CHANGE]. Environment: [CLOUD PROVIDER, IAC TOOL AND VERSION, ENVIRONMENT NAME]. Policies: [TAGGING, ENCRYPTION, NETWORK, NAMING RULES]. Constraints: no new providers, use modules from [MODULE SOURCE], do not touch [PROTECTED RESOURCES]. First, list the files you will change and the resources that will be created, modified, or destroyed, then stop for my approval. After I approve, make the change, run [PLAN COMMAND], paste the plan summary with destroys first, and never run apply. Finish with a PR description that includes rollback steps.
Tip: Never give the agent credentials that can apply to production; plan-only permissions are enough.
Diagnose a failing Kubernetes workload
You are an SRE with deep Kubernetes experience. Workload: [DEPLOYMENT NAME AND PURPOSE]. Symptom: [CRASHLOOP, PENDING, OOMKILLED, OR DESCRIBE THE BEHAVIOR]. Output of kubectl describe, redacted: [PASTE]. Recent events: [PASTE EVENTS]. Last 50 log lines: [PASTE LOGS]. Manifest excerpt: [PASTE THE RELEVANT SPEC]. Recent changes: [DEPLOYS, NODE CHANGES, CONFIG]. Rank the likely causes, give the exact read-only command that confirms each, and describe the smallest change that would fix the top cause. Do not suggest deleting namespaces, volumes, or nodes. Ask for anything missing before you rank.
Tip: Paste real output; the model's guesses get much worse from a paraphrase.
Summarize a Terraform plan for review
You are reviewing a Terraform plan before it runs against [ENVIRONMENT NAME]. Summarize the plan below in this order: resources to be destroyed (with the likely reason), resources to be replaced (and the attribute forcing replacement), resources modified with a diff of the attributes that matter (security, networking, IAM, size, cost), resources created. Then list anything a careful reviewer would question, including drift that suggests manual changes, and whether any change could cause downtime. Be literal; do not assume intent. Plan output: [PASTE THE PLAN OUTPUT]
Tip: A 'must be replaced' on a database or a load balancer should stop the pipeline every time.
Write a blameless postmortem from an incident channel
You are facilitating a blameless postmortem for [SERVICE NAME]. Using only the channel export and notes below, produce: a one-paragraph summary, a timeline with timestamps (detection, escalation, mitigation, resolution), customer impact stated factually, contributing factors (not a single root cause unless the evidence supports it), what went well, where we got lucky, and action items with a suggested owner role and priority. Do not name individuals as causes; describe system and process conditions. Mark any gap in the evidence as an open question. Export: [PASTE THE CHANNEL EXPORT AND NOTES]
Tip: Read the contributing factors for anything the model inferred that no one said.
Review infrastructure code for security and cost
You are a cloud security and cost reviewer. Review the code below for: IAM permissions broader than needed, security groups or firewall rules open to 0.0.0.0/0, unencrypted storage or transit, unpinned images or provider versions, missing resource requests and limits, logging and backup gaps, and sizes that look oversized for [WORKLOAD DESCRIPTION]. For each finding: file and line, severity, why it matters, a fix. Say explicitly when a category is clean, and note anything that may be intentional so I can confirm. Cloud and tooling: [PROVIDER AND TOOL] Code: [PASTE THE CODE]
Tip: Run it alongside Checkov or Trivy; the model catches different things than scanners do.
Want a prompt for something else? Use the Prompt Builder.
Skills to build
Specifying constraints before generation
Why: Generated infrastructure defaults to the most common pattern in training data, which is often public, unencrypted, and oversized.
How: Keep a policy block (tagging, encryption, network, IAM, naming, provider versions) in your repo instructions file (CLAUDE.md, .cursor/rules, or copilot-instructions.md) and reference it in every task.
Reading plans and diffs for blast radius
Why: The plan is the last line of defense between a plausible change and a destroyed database, and agents produce plans faster than you can read them carelessly.
How: Read destroys and replacements first, every time; require plan output in every PR; gate applies on human approval in the pipeline.
Secrets hygiene in AI workflows
Why: Agents read whole repos and environments, and a token in a .env, a tfvars file, or shell history becomes a token in a vendor log.
How: Exclude secret paths with ignore files, run gitleaks in pre-commit, give agents plan-only credentials, and rotate anything that was ever pasted.
Least-privilege agents and injection awareness
Why: An agent with a shell and cloud credentials that reads READMEs, issues, and web pages can be told what to do by whoever wrote them.
How: Run agents in sandboxes with read-only or plan-only access, review every command before it executes, give MCP servers the narrowest scope, and treat fetched content as untrusted.
Observability literacy
Why: AI can explain what a graph shows but cannot tell you what you failed to measure, and most incidents are detection gaps.
How: Use the assistant to draft SLOs, alert rules, and dashboards from your service's failure modes, then walk through what each alert would catch and miss.
Tools worth knowing
Claude Code
Anthropic's agentic coding tool that works in your terminal and IDE, on your real codebase
GitHub Copilot
AI pair programmer inside VS Code, JetBrains, and GitHub itself, with a free tier
Cursor
A VS Code fork rebuilt around AI: autocomplete, chat, and agents that edit your project
Windsurf
AI code editor whose Cascade agent reads your codebase and makes multi-file changes
Claude
A careful writing and analysis assistant that shines on long documents.
ChatGPT
The general-purpose AI assistant most of your coworkers already use.
Cautions for devops engineers
Coding tools read the files around your cursor and agents read the whole tree, so .env files, tfvars, kubeconfigs, and CI variables are one careless task away from a vendor log. Exclude secret paths, never paste credentials or internal IP ranges and hostnames into a chat, use no-training plans, and rotate any credential that reached a prompt.
Generated Terraform, Helm, and Bash validates, passes lint, and can still open a port to the internet, replace a database, or rm -rf a path built from an empty variable. Read every diff, require plan output in the PR, keep applies behind human approval, and run scripts with a dry-run mode in a lab before they touch anything shared.
An agent that reads a README, a GitHub issue, a package's install docs, or a web page will follow instructions planted there, including running commands and sending data. Give agents least privilege (plan-only cloud credentials, sandboxed shells, scoped MCP servers), review commands before they run, and never let an autonomous agent apply to production.
Generated code can reproduce licensed snippets, and agents add community modules and container images without checking license or maintenance status. Turn on duplicate-detection filters where your tool offers them, check the license and source of every module and image added, pin versions, and scan images with Trivy or an equivalent before use.
Your 30-day plan
- Week 1: Pick the coding tool your organization allows, set no-training or enterprise terms, add ignore files for secrets and state, write a repo instructions file with your policies, and give the agent plan-only credentials.
- Week 2: Use it only for read-only work (explaining plans, debugging pod output, drafting runbooks) while you learn how it fails.
- Week 3: Give the agent one small IaC or pipeline task per day with the plan-then-approve brief, and time your review against writing it yourself.
- Week 3: Add gitleaks, Checkov, and image scanning to CI, and make plan output a required PR artifact.
- Week 4: Draft your next postmortem and two runbooks with the assistant, then write the team's rules: what agents may do, what needs approval, and how AI-assisted changes are labeled.
Frequently asked questions
Will AI replace DevOps engineers?
Is it safe to let an AI agent run terraform apply?
Which AI coding tool is best for infrastructure work?
How do I stop AI tools from reading my secrets and kubeconfig?
Terms used on this page
Related roles
- AI for Software DevelopersCoding assistants write, refactor, test, and explain code, and agentic tools run the whole loop. Treat every generated line as a pull request from a fast, overconfident junior: useful, never merged unread.
- AI for Cybersecurity AnalystsAssistants explain alerts, write the KQL or SPL you need, and draft the incident report while the details are fresh. They also invent CVEs and follow instructions hidden in the logs they read, so verification is the job.
- AI for IT Support SpecialistsChat assistants explain error codes, draft the PowerShell you would otherwise search for, and write the ticket reply in the user's language. They also confidently suggest commands that can wipe a machine, so read before you run.
- AI for EngineersAI is a fast junior for mechanical, civil, electrical, and industrial engineers: it drafts calcs, reports, scripts, and checklists, and must be checked on every number. Nothing it produces is a deliverable until an engineer has verified it.