plan-review
Read a terraform plan (binary or JSON) and surface destructive actions, drift, and unsafe diffs before apply.
- License 许可
- MIT
- 最近更新
- 2026-10-29
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- plan-review
- description
- Read a terraform plan (binary or JSON) and surface destructive actions, drift, and unsafe diffs before apply.
02 资源文件 2
- 参考文档references/terraform-tools.md2.1 KB
- 脚本scripts/plan-summary.py7.1 KB
03 SKILL.md 正文
plan-review
A second pair of eyes on a
terraform planoutput. Output is a categorized review: destructive actions, drift, replacements, additions, and a go/no-go recommendation.
Mode: deterministic — same inputs, same output. Follow the steps and the output shape exactly; compute with the named script or tool, never by estimate; add nothing the shape does not ask for.
When to use
- A PR includes a generated plan artifact (
tfplan.binaryortfplan.json) and a reviewer wants a fast read. - Pre-apply, before promoting a plan to prod.
- After a long-lived branch rebases, to catch drift that crept in.
Inputs
- Plan file (required) — either
tfplan.binary(runterraform show -json tfplan.binary > tfplan.jsonfirst) ortfplan.jsondirectly. - Workspace / environment label (required) — review tone is stricter for
prod. - Approved change scope (optional) — what the PR claims to change. Anything outside is flagged.
Procedure
-
Convert if needed. If a binary plan is supplied, run
terraform show -json <plan>(ortofu show -json, or the binary named in the plugin'sterraformBinarysetting) to produce JSON. Do not parse the binary format directly. The JSON contains sensitive values in plaintext (before_sensitive/after_sensitiveonly mark them): never echo those values in your review, and flag atfplan.jsonuploaded as a public CI artifact or committed to the repo. -
Run the bundled summary — never classify a plan by reading the JSON by eye. It applies the rules in steps 3–6 mechanically, never prints a value, and states the minimum gate:
python3 "${POLYMATH_PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}/skills/plan-review/scripts/plan-summary.py" tfplan.json \ --scope 'module.refunds.*' # one --scope per address glob the PR is approved to changePaste its block verbatim, then add only what it cannot know (steps 3–6 explain each section). Exit 2 = not a plan JSON.
-
Read each classification (the script's
change.actionsmapping):["no-op"]— unchanged; ignore.["read"]— data source read; note only if it's deferred to apply time.["forget"]— removed from state without destroying (aremovedblock); confirm that's intended.["create"]— new resources; flag if outside approved scope.["update"]— in-place change; show before → after for sensitive fields.["delete", "create"]or["create", "delete"]— replacement; almost always destructive (state loss). Readaction_reasonandreplace_pathsto see which attribute forced it — often a one-line config fix avoids the replace.["delete"]— destruction; only safe with explicit approval.
-
Destructive patterns the script calls out by resource type — add the human gate for each:
aws_db_instance,aws_rds_cluster,google_sql_database_instance,azurerm_mssql_database— replacement triggers backup-required gate.aws_s3_bucket,google_storage_bucket,azurerm_storage_account— delete triggers data-loss gate (requireforce_destroy = falseaudit).aws_iam_*,google_project_iam_*,azurerm_role_assignment— privilege changes deserve their own reviewer; wildcard actions/resources ("*") and new cross-account trust get a dedicated callout.*_security_group,*_firewall*— surface opening (0.0.0.0/0 ingress) gets a dedicated callout.
-
Drift. Read the plan JSON's top-level
resource_driftarray — changes Terraform detected during refresh that happened outside Terraform. Report them separately from intended changes; an update inresource_changesthat merely reverts drift is not part of the PR's intent either. -
Sensitive-field check (judgment — the script can't see CI logs). Confirm sensitive attributes are marked (
after_sensitive) and that the CI log shows(sensitive value)rather than the value; flag any secret that appears unmasked in plan output or in a non-sensitive attribute (e.g. a password in a tag or user_data). -
Provider version pinning. The script lists providers without a version constraint — they float and re-plan unpredictably.
-
Recommend one of
apply-ok,apply-with-approval,needs-rework,block. Start from the script's minimum gate; raise it only for a named reason (an out-of-scope create/update, a replacement a one-line config change avoids, an unmasked secret, a missing backup for a stateful replace). Never lower it.
Output
plan-review
Workspace: prod
Plan file: tfplan.json
Plan summary
create 4 · update 2 · replace 1 · delete 1 · forget 0 · deferred read 0
(terraform's own line: 5 to add, 2 to change, 2 to destroy)
Destructive actions:
- aws_db_instance.refund_primary REPLACE forced by: engine_version (replace_because_cannot_update)
- aws_s3_bucket.legacy_uploads DELETE
Stateful resources at risk:
- aws_db_instance.refund_primary (aws_db_instance) REPLACE — data-loss gate: snapshot/backup + restore path required
- aws_s3_bucket.legacy_uploads (aws_s3_bucket) DELETE — data-loss gate: snapshot/backup + restore path required
IAM / privilege changes (own reviewer):
none
Internet exposure:
none
Outside approved scope:
- aws_s3_bucket.legacy_uploads delete
Drift (changed outside Terraform — not this PR's intent):
- aws_security_group.web update
Providers without a version constraint: none
Minimum gate: block (destructive change outside the approved scope)
Reviewer notes
- refund_primary: engine upgrade 14 → 15 forces replacement; use an in-place major-version
upgrade (allow_major_version_upgrade) instead, or confirm skip_final_snapshot = false + restore runbook.
- Sensitive values: masked in the CI plan output; tfplan.json is not uploaded as an artifact.
Recommendation: block
Reason: legacy_uploads delete is outside PR scope — split it into a dedicated migration PR.
Quality bar
- Every destructive action explicitly named (resource type + address + risk + gate).
- Drift separated from intentional change.
- Sensitive field handling verified.
- A single explicit recommendation, not "looks fine".
Anti-patterns to avoid
- Approving a plan by file size or count ("only 6 changes, should be fine"). Volume is not risk.
- Treating a replacement as an update. Replacement = delete + create, with state loss.
- Skipping the drift section because it "doesn't change anything in this PR". Drift is the leading indicator of out-of-band changes that bypass review.
- Reviewing a binary plan by reading it directly. Always go through
terraform show -jsonfirst. - Quoting a sensitive value from the plan JSON in the review.
04 同仓库更多 Skills
runbook
Write or refresh an operational runbook for an alert/symptom; structured as TL;DR + Pre-checks + Steps + Verification + Rollback + Escalation.
rfc
Draft a lightweight design RFC to docs/rfcs/<slug>.md; Summary, Motivation, Detailed design, Drawbacks, Alternatives, Unresolved questions. A proposal to debate, not a recorded decision (adr).
editorial-pass
Review and tighten prose in a Markdown artifact for a target tone (terse, formal, friendly) without dropping information; preserve quotations and load-bearing constraints.
architecture-review-facilitation
Run an architecture review as a process — entry criteria, reviewer checklist, decision log, and follow-up actions — pairing the design artifact with a red-team pass.
architecture-doc
Write a C4-style architecture document; System Context + Containers (+ Components when interesting) with mermaid diagrams. Describes structure, not a decision (adr) or proposal (rfc).
adr
Write an Architecture Decision Record (Michael Nygard format) to docs/adrs/NNNN-<slug>.md; frontmatter validated by the ADR artifact schema. Records a made decision, not a proposal to debate (rfc).