Skip to content
Terraform Diagnostic cover
DevOpsFree · MIT

Terraform Diagnostic

Read the plan before you apply — catch destroy/replace of stateful resources, drift, and state traps. Diagnostic-first, not doc-dumping.

v1.0.0 · ~660 tokens · ⬇ 0 · Updated July 6, 2026

What it does

Diagnoses a Terraform change from the plan: flags destroy/replace (especially of stateful resources = data loss/downtime), explains WHY a replace is forced (changed immutable field), handles drift (import vs re-apply) and state safety (never hand-edit; moved/import blocks). Verdict SAFE/CARE/DANGEROUS with the safe path and rollback. Diagnoses THIS plan, doesn't paste generic docs.

Example uses

Explain a scary Terraform plan

The plan wants to replace a stateful production resource and you need to know why before applying.

terraform plan says '3 to add, 1 to change, 2 to destroy' and one destroy is our production RDS instance marked -/+ replace. Figure out which attribute is forcing the replacement and give me a verdict — SAFE, SAFE WITH CARE, or DANGEROUS — plus the safe path if we genuinely need this change.

Reconcile console drift safely

Manual console changes have drifted from the Terraform config and a blind apply would revert them.

Someone resized our EC2 instances in the AWS console last week, and now terraform plan wants to revert them. Decide whether we import the reality or re-apply the config, and walk me through it without hand-editing the state file.

Refactor modules without destroys

A module refactor changed resource addresses and the plan now wants to destroy real infrastructure.

I'm splitting our Terraform into modules, and the plan now wants to destroy and recreate the S3 bucket holding customer uploads because its address changed. Show me how to use moved blocks or state mv so the refactor applies with zero destroys.

Install

# 1. Create the skill folder in your Claude setup
mkdir -p ~/.claude/skills/iac-terraform-diagnostic

# 2. Download SKILL.md into it (or move the file you just downloaded)
#    → ~/.claude/skills/iac-terraform-diagnostic/SKILL.md

# 3. Claude Code auto-discovers it on next launch.

Inside the skill

SKILL.md
---
name: iac-terraform-diagnostic
description: Diagnose and safely change Terraform / infrastructure-as-code — read the plan, catch destructive changes, fix drift. Use when a terraform plan is scary, apply failed, state is drifted, or asked "review this terraform", "is this apply safe", "why does it want to destroy this". Diagnostic-first, not doc-dumping.
---

# IaC / Terraform Diagnostic

Infrastructure code applies to real, running systems. The `plan` is the truth — read it
before you touch anything. Diagnose the specific situation; don't dump the whole manual.

## Read the plan like a hawk

`terraform plan` and scan the change summary. The words that matter:
- **destroy** / **-/+ (replace)**: something will be torn down. A replace = destroy THEN
  create — downtime, new IP, lost local data, new resource ID. WHY does it want to replace?
  Usually a changed immutable attribute (name, AZ, engine) forcing recreation. This is the #1
  thing to catch before `apply`.
- **update in-place (~)**: usually safe, but check WHAT (a security group rule opening 0.0.0.0/0?).
- **create (+)**: new resources — cost + does it conflict with something existing?

## Destructive-change checklist (block on any without explicit OK)

- Replace/destroy of a **stateful** resource (database, disk, bucket with data) → data loss risk.
  Look for `prevent_destroy`, snapshots, or a migration plan first.
- Change to an immutable field forcing replacement of something in production.
- Deleting/renaming a resource that others depend on.

## Drift & state

- **Drift**: real infra changed outside Terraform (someone clicked in the console). `plan`
  shows it as a diff. Decide: import the reality, or re-apply to overwrite it. Don't blindly apply.
- **State is precious**: never hand-edit state; use `import`/`state mv`/`moved` blocks.
  A corrupted state file is a very bad day. Back it up; use remote state with locking.

## Safety before apply

- `plan` reviewed by a human for any destroy/replace.
- Target-scope risky changes; apply to staging before prod.
- Know the blast radius and the rollback (previous state / re-apply old config).

## Rules

- Never `apply` a plan you haven't read — the summary line ("2 to destroy") is the warning.
- A "replace" of a stateful resource is guilty until proven safe (snapshot? acceptable downtime?).
- Diagnose THIS plan/error; don't paste generic Terraform docs. The plan already told you the problem.

## Output

Verdict: SAFE / SAFE WITH CARE / DANGEROUS. What will be destroyed/replaced and why, the
data-loss/downtime risks, the safe path (snapshot, staging-first, targeted apply), and rollback.

Changelog

  • v1.0.02026-07-03Initial clean-room write.

Frequently asked questions

Is Terraform Diagnostic free?

Yes. Terraform Diagnostic is free to download and MIT-licensed.

Where do I install Terraform Diagnostic?

Place the SKILL.md file in ~/.claude/skills/iac-terraform-diagnostic/ and Claude Code auto-discovers it on next launch.

How many tokens does Terraform Diagnostic use?

About 660 tokens — it is designed to be token-lean.

Anthony M. — Founder & Lead Reviewer
Anthony M.Verified Builder

We're developers and SaaS builders who use these tools daily in production. Every review comes from hands-on experience building real products — DealPropFirm, ThePlanetIndicator, PropFirmsCodes, and many more. We don't just review tools — we build and ship with them every day.

Written and tested by developers who build with these tools daily.