/polymath-iac:terraform-statefrom polymath-iac
Design Terraform state — remote backend, locking, state isolation/segmentation, drift detection, and safe import/move/rm operations without destroying live infra.
Ships in polymath-iac. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
State is the most dangerous file in your infra: lose it, share it unlocked, or split it wrong and you reapply or destroy production. Design isolation and locking before scaling usage.
Mode: analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked [TBD] or [VERIFY], never filled in.
polymath-iac:terraform-state.Not this when: you are authoring a reusable module (terraform-module) or reviewing a specific plan (polymath-cloud:plan-review). This is about state topology and operations.
use_lockfile locking — DynamoDB locking is deprecated since Terraform 1.10 — GCS, azurerm, or HCP Terraform) with encryption and versioning; never local state for shared infra. Locking is non-negotiable for teams.terraform plan -refresh-only (or plain plan) to detect out-of-band changes; alert and reconcile. Decide the policy: codify the change or revert it — don't let drift accumulate.plan and get code-reviewed: import {} to adopt existing resources, moved {} for renames/module moves (so Terraform doesn't destroy+recreate), removed {} to stop managing without destroying. Fall back to CLI state mv / state rm only when a block can't express it — and back up state (terraform state pull > backup.tfstate) first.State design: payments infrastructure (AWS, 3 envs)
Backend: S3 bucket per env (tfstate-payments-{dev,stage,prod}), SSE-KMS, versioning on, use_lockfile = true
Layout (one state per env × layer):
envs/prod/network/ VPC, subnets, NAT apply: platform team, 2 approvers
envs/prod/data/ RDS, ElastiCache, S3 buckets apply: platform team, 2 approvers, prevent_destroy on stores
envs/prod/app/ ECS services, ALB rules, SQS apply: payments team
(dev and stage mirror the tree with their own buckets and credentials)
Drift: nightly `terraform plan -refresh-only` per state → alert on any diff; policy: codify within 2 business days or revert
Surgery: import {} / moved {} / removed {} blocks in a reviewed PR; CLI state mv/rm only after `terraform state pull > backup.tfstate`
Access: prod state readable by the CI role and 3 named admins (state contains secrets); no human write outside CI
Recovery: restore from S3 object version; runbook docs/runbooks/terraform-state-restore.md, tested quarterly
moved/import/removed blocks (CLI state surgery only with a backup), never destroy+recreate of live infra.What SKILL.md sets; muted values are Claude Code's defaults
3 skills in this plugin
/policy-as-codeDesign policy-as-code guardrails (OPA/Rego, Sentinel, Checkov/Trivy) — enforce tagging, security, and cost rules in CI/plan with severity gates and exemptions./terraform-moduleAuthor a reusable Terraform module — input variables with validation, typed outputs, sane defaults, versioning, provider constraints, and composition boundaries.Other plugins' skills for the same job
npx claudepluginhub mohammadbafkar/polymath --plugin polymath-iac