terraform-plan-review
Skill9 starsChanged 5 months agoApache-2.0View on GitHub
Reviews Terraform/OpenTofu plans and modules with a safety-first, diagnose-first lens — blast radius of destroys/replaces, identity churn, drift, state risks, secret exposure — before any apply. Triggers when reviewing a terraform plan diff, authoring modules, or gating an apply in CI.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- WalletConnect/skillstheir own version, first seen Feb 3, 2026
- lgbarn/devops-skillstheir own version, first seen Jan 23, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- lgbarn/devops-skills★ 15same name
- WalletConnect/skills★ 14same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository147 other files it gives its agents.
- second-brain/AGENTS.mdAGENTS.md
- second-brain/CLAUDE.mdCLAUDE.md
- agent-tool-mcp-builderSkill
- api-design-reviewSkill
- async-concurrency-correctnessSkill
- audit-accessibility-wcagSkill
- audit-license-complianceSkill
- audit-technical-seoSkill
- auth-jwt-sessionSkill
- author-codemodSkill
- brainstorm-designSkill
- build-audit-loggingSkill
- build-cdc-streaming-pipelineSkill
- build-cli-toolSkill
- build-data-tableSkill
- build-etl-pipelineSkill
- build-form-validationSkill
- build-native-mobile-uiSkill
- build-office-docsSkill
- build-offline-first-syncSkill
- build-react-componentSkill
- build-realtime-channelSkill
- build-spreadsheetSkill
- build-vector-searchSkill
- caching-strategySkill
- cicd-pipeline-authorSkill
- cloud-cost-optimizeSkill
- code-commentsSkill
- code-reviewSkill
- compose-local-dev-stackSkill
- configure-bundler-buildSkill
- configure-dns-tlsSkill
- configure-reverse-proxy-lbSkill
- configure-security-headers-cspSkill
- contract-testingSkill
- datetime-timezone-correctnessSkill
- db-migration-safetySkill
- debug-ci-pipeline-failureSkill
- debug-flaky-testsSkill
- debug-frontend-browserSkill
- debug-root-causeSkill
- defend-llm-prompt-injectionSkill
- deliver-webhooksSkill
- dependency-upgradeSkill
- deploy-releaseSkill
- design-api-paginationSkill
- design-authorization-modelSkill
- design-backup-dr-recoverySkill
- design-event-sourcing-cqrsSkill
- design-multi-tenancySkill
- design-protobuf-grpc-serviceSkill
- design-relational-schemaSkill
- design-search-index-infraSkill
- design-state-machineSkill
- design-token-systemSkill
- diff-table-paritySkill
- distributed-locks-leasesSkill
- dockerfile-optimizeSkill
- encrypt-sensitive-dataSkill
- error-messageSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
Use this skill BEFORE any terraform apply / tofu apply, and whenever you:
- Distinctive: line 20
Generate a deterministic, machine-readable plan: Never review live console scroll.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When to Use
Use this skill BEFORE any terraform apply / tofu apply, and whenever you:
- Review a plan diff (the
~/-/-/+lines, orterraform show -jsonoutput). - Author or refactor a module (variables,
for_each/count, outputs). - Gate an apply in CI/CD (PR check, plan-as-artifact, OPA/Sentinel policy).
Core stance: diagnose first, never auto-approve. A plan that only adds (+) is low-risk; one with - (destroy) or -/+ (replace) on stateful resources can be irreversible data loss. Your job is to surface blast radius and force a conscious go/no-go — not to rubber-stamp green output. Treat the plan as the source of truth, ground every claim in provider docs, and never invent resource behavior.
The commands below apply identically to OpenTofu — swap terraform for tofu.
Steps
- Generate a deterministic, machine-readable plan. Never review live console scroll. Run:
Reviewing a saved plan file and thenterraform plan -out=tfplan.bin -lock-timeout=120s terraform show -json tfplan.bin > tfplan.jsonapply tfplan.binguarantees what you reviewed is exactly what runs (no TOCTOU drift between plan and apply). - Bucket every change by action. Parse
tfplan.json→.resource_changes[].change.actions:["create"]→ low risk.["update"]→ in-place, usually safe; check WHICH attributes (step 4).["delete","create"](shown as-/+) → replace = destroy then recreate. High risk.["create","delete"]→ replace withcreate_before_destroy(less downtime, but check capacity/quota).["delete"]→ destroy. Highest risk. Flag every single one. Quick triage:
jq -r '.resource_changes[] | select(.change.actions != ["no-op"]) | "\(.change.actions | join(",")) \(.address)"' tfplan.json | sort | uniq -c - Flag blast radius — these block go by default:
- Any destroy/replace of stateful resources: databases, disks/volumes, buckets/blob storage, stateful sets, persistent caches. Replacing these = data loss unless a snapshot/backup exists. Demand a backup or
prevent_destroybefore approving. - Forced replace from immutable attribute changes — look at
change.replace_pathsin the JSON; it names the exact attribute forcing recreation (e.g. changing an availability zone, name, or engine version). Confirm the change is intended, not an accidental edit. count→for_eachmigrations or reorderedcountlists → index churn: removing element 0 of acountlist shifts every later index, destroying/recreating unrelated resources.for_eachwith stable string keys avoids this. If you see a wide swath of replaces from one small edit, this is almost always the cause.-targetused to scope the apply → silently skips dependency graph; flag as partial apply that can leave state inconsistent. Allowed only as a deliberate break-glass, noted in the PR.null_resource/terraform_datawithtriggerschurning → re-runs provisioners; check the provisioner isn't destructive.
- Any destroy/replace of stateful resources: databases, disks/volumes, buckets/blob storage, stateful sets, persistent caches. Replacing these = data loss unless a snapshot/backup exists. Demand a backup or
Walk the failure-mode table (diagnose, don't assume):
Failure mode What to grep / inspect Why it bites Identity / IAM churn replaces or deletes on roles, policies, bindings, service accounts, key pairs Recreating identity revokes live access → cascading outages; new keys break dependents mid-apply Secret exposure sensitivevalues surfacing in outputs,local_file/template_filewriting secrets to disk, secrets in plainvariabledefaults or committed.tfvars, plan JSON containing raw credentialsPlaintext secrets land in state, logs, CI artifacts, or git — state is NOT encrypted by default Blast radius count of destroy+replace vs intended scope; one-line edit → many resources changing A typo in a shared local/module input can ripple across an entire environmentCI drift terraform plan -detailed-exitcodereturns 2 (changes) on a "no-change" branch; resources changed outside TerraformState no longer matches reality; next apply may revert manual fixes or fail mid-run State corruption / lock missing or stale state lock, two pipelines applying same state, local state instead of remote backend, no versioning on the state bucket Concurrent applies corrupt state; lost state = orphaned real infra you can no longer manage - Inspect module structure & state hygiene (when authoring or auditing):
- Variables typed and validated (
type,validationblocks); no untypedanyon security-relevant inputs. - Outputs don't leak secrets; mark with
sensitive = truewhere needed (note: this only redacts CLI output, NOT state). - Remote state with locking + encryption + versioning is mandatory for shared environments — local
terraform.tfstatein a team repo is a finding. Confirmbackendconfig locks (DynamoDB table / native lock / blob lease) and the state store has versioning so you can roll back. - Workspace / environment isolation: prod and non-prod must not share one state file or one backend key. Verify per-env state separation.
- Pin provider and module versions (
required_providerswith~>constraints, moduleversion/ref). Unpinnedlatest= non-reproducible plans.
- Variables typed and validated (
- Ground every resource-behavior claim in provider docs (anti-hallucination). Before asserting "this attribute forces replacement" or "this is safe in-place," confirm against the actual provider documentation for that resource/version. Do not infer behavior from the resource name. If you cannot verify, say so and mark the finding as uncertain rather than guessing.
- Run static security/policy scans and read the findings:
Triage real issues (public exposure, unencrypted storage, permissive IAM, open security groups) vs. accepted/false-positive rules. Don't dump raw scanner output — summarize what actually matters for this change.tfsec . --soft-fail # or: trivy config . checkov -d . --compact - Emit a go / no-go verdict. Structure: counts by action → list every destroy/replace with its
replace_pathscause → secret/IAM findings → scan findings → explicit GO or NO-GO with the single most dangerous line called out, and the exact remediation (snapshot first / addprevent_destroy/ switch tofor_each/ pull secret into a vault). Never end with just "looks fine."
Common Errors
- Reviewing live
planoutput, then running a freshapply. State or remote data can change in between → you apply something you never reviewed. Always-outa plan file and apply that exact file. - Trusting green/“no changes” without
-detailed-exitcode. Plainplanexits 0 even when there are changes. Use-detailed-exitcode:0= no changes,1= error,2= changes present. CI gates must check for2. - Missing replaces because you only read
+/-summary lines. A-/+(replace) on a database reads almost like a normal update at a glance but destroys data. Parseactionsfrom JSON, don't eyeball the colored summary. - Assuming
sensitive = trueprotects the secret. It only redacts CLI/log output. The value is still stored in plaintext in state and may appear in plan JSON artifacts. The fix is to not put the secret in Terraform-managed values at all — reference a secrets manager. - Editing a
count-based list and triggering mass recreation. Inserting/removing a middle element shifts all later indices → cascade of destroy/replace. Migrate tofor_eachwith stable keys; expect the migration plan itself to churn (usemoved {}blocks to avoid destroy on refactor). - Approving a
-targetapply as if it were a full plan.-targetbypasses parts of the dependency graph and can leave state half-applied. It is break-glass only. - Refactoring modules/renaming resources without
moved {}blocks. Renaming an address makes Terraform plan destroy-old + create-new instead of a no-op rename. Addmoved {}(orimport/state mv) so refactors stay free of real destroys. - Local state in a shared repo / no lock. Two applies race and corrupt state. Require a remote backend with locking, versioning, and encryption before approving.
Verify
A review is complete only when ALL of these hold:
- Action buckets counted from
tfplan.json(create / update / replace / destroy) — not eyeballed from console color. - Every destroy and replace is listed with its
replace_pathsroot cause and an explicit data-loss assessment. - Stateful destroys/replaces have a verified backup/snapshot OR
prevent_destroy, OR the verdict is NO-GO. - Plan JSON, outputs, and
.tfvarschecked for plaintext secrets; remote state confirmed encrypted + versioned + locked. terraform plan -detailed-exitcodeinterpreted correctly in any CI gate (treats exit2as "changes present").tfsec/checkov(or equivalent) run; findings triaged, not ignored.- Every resource-behavior claim grounded in provider docs; uncertain points flagged, not asserted.
- Output ends with an explicit GO / NO-GO plus the top risk line and its remediation.
- The reviewed artifact is the same plan file that gets applied (
apply tfplan.bin), so there's no gap between review and execution.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

