← ClaudeAtlas

planguard-refactorlisted

Refactors Terraform without destroying anything: renaming resources, moving them into modules, splitting or merging state, and adopting existing infrastructure, using `moved` blocks, `terraform state mv` and `import` blocks, then proving with a fresh plan that nothing is destroyed or replaced. Use when the user says "rename this terraform resource", "move this into a module", "terraform wants to destroy it after my refactor", "how do I use a moved block", "import existing infrastructure", or "split my terraform state".
vivekbhange-hub/plan-guard-skill · ★ 0 · DevOps & Infrastructure · score 75
Install: claude install-skill vivekbhange-hub/plan-guard-skill
# planguard-refactor: change the code, not the infrastructure Terraform tracks resources by address (`aws_db_instance.main`). Rename the block, move it into a module or change `count` to `for_each`, and the old address disappears from the code: Terraform plans to destroy the old object and create a new one. A refactor should produce a plan with no destroy or replace at all, and this skill is built around proving that. ## Inputs - The refactor in one sentence (rename, move to module, count to for_each, split a stack, adopt an existing resource) and the Terraform version (`moved` needs 1.1, `import` blocks need 1.5). - The current addresses and the new addresses. If the user does not know the old ones, they run `terraform state list` themselves. - Where state lives (local file, S3 backend, Terraform Cloud) and whether it is versioned. - No script runs in this skill; on Windows use `python` (or `py -3`) for the review commands of `planguard-terraform` that it hands off to. ## Outputs - The code change: a `moved {}` block per renamed or moved address, or an `import {}` block, shown as a diff. - When a `moved` block cannot express it (cross-state moves), the exact `terraform state mv` or `terraform state rm` plus `import` commands, as text for the user to run. - A verification checklist ending in a plan with zero destroy and zero replace. ## Steps 1. **Confirm authorization.** The user should own the state and the infrastructure. Claude edits code and prints co