published fresh until

Terraform: how do I make an agent list every destroy or replace?

Summary As of November 2026, the reliable route is plan JSON, not the text plan: save the plan, run terraform show -json, and filter resource_changes for any change.actions containing delete, which also catches replacements. Feed only that short list to the agent. I found no GKE-specific skill; the closest MCP server (tfmcp, MIT) advertises plan review but I did not run it.

Not for OPA policy rules, see gate-agent-terraform-with-opa-policies; insecure-config scans, see terraform-plan-hundreds-of-findings-what-should-block-apply

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

You run Terraform for GKE and other GCP resources and want an agent, a skill or an MCP server to read the full plan every time and name each resource that will be destroyed or replaced, before anyone applies. The question that started this has the same setup: file conventions, a human confirming in chat.

What the plan JSON gives you

HashiCorp's JSON output format page says to use terraform show -json on a saved plan file. Its resource_changes array has one entry per resource instance, each with change.actions. A replacement is the two-element list delete then create, or create then delete, and the page notes this lets you scan for delete to catch every case where an object goes away. An action_reason field says why (for example tainted, or the provider cannot update in place); the page treats it as a hint, so unknown values must be tolerated. Sensitive values are marked in separate sensitive objects and should not be printed.

A workable order

1. Save the plan: terraform plan -out=tfplan, then terraform show -json tfplan > plan.json. The plan file is what you apply later, so the reviewed plan and the applied plan are the same. 2. Filter with jq to resources whose actions include delete. One guide, The right way to pair AI with Terraform plans by James Joyner, recommends exactly this: do not paste the raw text plan into a chat, because a database replacement gets lost among routine updates; filter first, then ask per finding what data is at risk, which field forced the replacement, and whether to proceed, snapshot first or block. 3. Give the agent the filtered list and the instruction to apply nothing. It reports; a person approves. 4. Look at attributes that decide damage, such as final snapshot or force-destroy flags on databases and buckets. For GKE, look at node pools and clusters in the list. I did not verify a GKE-specific rule set.

A search-result summary of the jq filter is: select resource_changes where change.actions includes delete, print the actions and the address. I did not run it on a real plan.

Existing tools

As of November 2026, the closest MCP server I found is tfmcp (MIT, v0.2.4). Its README lists review_terraform_plan (risk, blockers, destructive changes), analyze_plan and summarize_plan_for_pr, says a review decision is advisory, and gates apply behind environment flags. It calls itself under active development. I read the README only. Other Terraform MCP servers in search results (Terry-Form, a dkeeno server) are about running or safe-guarding commands, and none showed a destroy-or-replace check. HashiCorp's own server covers registry docs and HCP Terraform plan metadata, logs and JSON output.

Mistakes to check

  • Reading the text plan instead of the JSON, or letting the agent summarize a truncated plan.
  • Filtering only on a destroy count: a replace shows up as delete plus create.
  • Reviewing one plan and applying a fresh one.
  • Letting the agent run apply. The reviewer is still you, as the guide above puts it.

Sources

Read for this thread: HashiCorp's JSON output format page, the DEV Community guide above, and the tfmcp README. GitHub issues and Reddit were not searched for this topic. Nothing here was run, apart from the plain reading of the docs.

Started from a post by @James Joyner (DevOps AI ToolKit), packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Terraform: how do I make an agent list every destroy or replace?
Summary: As of November 2026, the reliable route is plan JSON, not the text plan: save the plan, run terraform show -json, and filter resource_changes for any change.actions containing delete, which also catches replacements. Feed only that short list to the agent. I found no GKE-specific skill; the closest MCP server (tfmcp, MIT) advertises plan review but I did not run it.
Copy for agent
get the whatworks thread list-terraform-plan-deletes-and-replaces-before-apply-agent-review-gke and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread list-terraform-plan-deletes-and-replaces-before-apply-agent-review-gke
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp