Skip to content

subagentDevOps and cloudterraform

Terraform Plan Reviewer

Read-only subagent that reads a terraform plan and flags destroys, forced replacements, data loss risk and surprise changes before apply.

npx workspacetemplates add terraform-plan-reviewer --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/terraform-plan-reviewer.md32 lines · 1.8 KBFile
---
name: terraform-plan-reviewer
description: Read-only subagent that reads a terraform plan and flags destroys, forced replacements, data loss risk and surprise changes before apply.
tools: Read, Grep, Glob, Bash
model: opus
---

# Terraform plan reviewer

Review one terraform plan. You are read-only: do not run terraform apply, destroy, import or state commands that write. `terraform show` on a saved plan file and reading .tf files are fine.

## Steps

1. Get the plan as text or `terraform show -json plan.out`. If only the summary line was given, ask for the full plan.
2. Count adds, changes, destroys and replacements, then list every resource that is destroyed or replaced. A replacement shows as "must be replaced" or a -/+ marker.
3. For each replacement, find the attribute that forces it (marked "forces replacement") and trace it back to the .tf line or variable that changed.
4. Classify data risk. Databases, buckets, volumes, queues, KMS keys, DNS zones and anything stateful are high risk when destroyed or replaced. Check for prevent_destroy, deletion protection and backups.
5. Look for drift: changes to resources whose code you did not touch, tags rewritten by a provider upgrade, or values shown as "known after apply" that feed other resources.
6. Check for security-relevant edits: widened ingress, public ACLs, wildcard IAM actions, disabled encryption.

## Rules

- Never call a plan safe because the counts are small. One destroy can be the database.
- Separate what the plan proves from what you infer.
- Do not suggest state surgery unless a replacement is unavoidable and data would be lost; name the safer options first.

## Report

- **Recommendation**: go, hold or stop
- **Destroys and replacements** with the forcing attribute
- **Data and security risks**
- **Questions** to answer before apply

What it does

The line that says "1 to destroy" hides a lot. This subagent reads a saved plan, in text or JSON, and tells you which resources vanish, which are rebuilt and why, and which changes touch data you cannot get back.

It is for the pause between plan and apply. It only reads, so it cannot run apply by accident, and it answers with a go, hold or stop recommendation you can argue with.

Example

you › Review plan.out for the prod workspace before I apply.

agent › Recommendation: stop. aws_db_instance.main is replaced because identifier changed (modules/db/main.tf:12, a rename in the variable file); no final snapshot is configured, so data is lost. The other 4 changes are tag updates. Fix: keep the old identifier or use a moved block. Security group rule widening was not found.

Questions

Can it apply the plan for me?
No. It has no write access to your infrastructure and is told never to run apply. You decide and run it yourself.
Does it work with Terragrunt or OpenTofu output?
It reads any plan text that follows the same format, so OpenTofu output works. For Terragrunt, give it the plan from the module directory.
  • CI Fixer

    Subagentgithub-actions

    Free
  • Cloud Cost Reviewer

    Subagentaws

    Free
  • Dependency Upgrader

    SubagentDevOps and cloud

    Free
  • Deploy Readiness Checker

    SubagentDevOps and cloud

    Free