[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74GC191F4VA66VHPRZWX6D5":3,"skill-same:01M74GC191F4VA66VHPRZWX6D5":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M74GC191F4VA66VHPRZWX6D5","terraform-state",null,"Design Terraform state — remote backend, locking, state isolation\u002Fsegmentation, drift detection, and safe import\u002Fmove\u002Frm operations without destroying live infra.","MohammadBafkar\u002Fpolymath","MohammadBafkar","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F34940462?v=4","01M74G540TQFZWK6KVAPKFVGNR","Mohammad Bafkar","01M74G541HG19QP9V5DQCJVKYE",0,"MIT","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-iac\u002Fskills\u002Fterraform-state\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: terraform-state\ndescription: Design Terraform state — remote backend, locking, state isolation\u002Fsegmentation, drift detection, and safe import\u002Fmove\u002Frm operations without destroying live infra.\n---\n\n# terraform-state\n\n> 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.\n\n**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.\n\n## When to use\n\n- Setting up or restructuring Terraform state, backends, or workspaces.\n- Concurrent applies clobber each other, blast radius is too large, or drift goes unnoticed.\n- A workflow invokes `polymath-iac:terraform-state`.\n\nNot 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.\n\n## Inputs\n\n- Team size, environments, and the current state layout (monolithic? per-env?).\n- The cloud\u002Fbackend available (S3 with native lockfile locking, GCS, azurerm, HCP Terraform, …).\n- State files hold secrets in plaintext: read structure and addresses, never quote values.\n\n## Procedure\n\n1. **Remote backend + locking**: store state remotely (S3 with native `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.\n2. **Isolate state by blast radius**: separate state per environment (dev\u002Fstage\u002Fprod) and per independently-changing layer (network vs data vs app). A single giant state means every apply risks everything and serializes the team.\n3. **Workspaces vs directories**: prefer separate root configs\u002Fdirs (or a tool like Terragrunt) for strong env isolation; CLI workspaces only for lightweight, low-risk variation — they share a backend and are easy to misfire.\n4. **Drift detection**: scheduled `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.\n5. **Safe state surgery** — prefer the config-driven blocks, which show up in `plan` and get code-reviewed: `import {}` to adopt existing resources, `moved {}` for renames\u002Fmodule moves (so Terraform doesn't destroy+recreate), `removed {}` to stop managing without destroying. Fall back to CLI `state mv` \u002F `state rm` only when a block can't express it — and back up state (`terraform state pull > backup.tfstate`) first.\n6. **Secrets in state**: assume state contains secrets — restrict backend access (least privilege), encrypt, and avoid outputs that leak them.\n7. **Recovery**: state versioning\u002Fbackups + a documented restore; protect against concurrent corruption.\n\n## Output\n\n```text\nState design: payments infrastructure (AWS, 3 envs)\n\nBackend:  S3 bucket per env (tfstate-payments-{dev,stage,prod}), SSE-KMS, versioning on, use_lockfile = true\nLayout (one state per env × layer):\n  envs\u002Fprod\u002Fnetwork\u002F   VPC, subnets, NAT            apply: platform team, 2 approvers\n  envs\u002Fprod\u002Fdata\u002F      RDS, ElastiCache, S3 buckets  apply: platform team, 2 approvers, prevent_destroy on stores\n  envs\u002Fprod\u002Fapp\u002F       ECS services, ALB rules, SQS  apply: payments team\n  (dev and stage mirror the tree with their own buckets and credentials)\nDrift:    nightly `terraform plan -refresh-only` per state → alert on any diff; policy: codify within 2 business days or revert\nSurgery:  import {} \u002F moved {} \u002F removed {} blocks in a reviewed PR; CLI state mv\u002Frm only after `terraform state pull > backup.tfstate`\nAccess:   prod state readable by the CI role and 3 named admins (state contains secrets); no human write outside CI\nRecovery: restore from S3 object version; runbook docs\u002Frunbooks\u002Fterraform-state-restore.md, tested quarterly\n```\n\n## Quality bar\n\n- Remote, encrypted, versioned backend with locking — no shared local state.\n- State is segmented by environment and blast radius, not one monolith.\n- Drift is detected on a cadence with a written reconcile policy.\n- Refactors use `moved`\u002F`import`\u002F`removed` blocks (CLI state surgery only with a backup), never destroy+recreate of live infra.\n","# terraform-state\n\n> 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.\n\n**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.\n\n## When to use\n\n- Setting up or restructuring Terraform state, backends, or workspaces.\n- Concurrent applies clobber each other, blast radius is too large, or drift goes unnoticed.\n- A workflow invokes `polymath-iac:terraform-state`.\n\nNot 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.\n\n## Inputs\n\n- Team size, environments, and the current state layout (monolithic? per-env?).\n- The cloud\u002Fbackend available (S3 with native lockfile locking, GCS, azurerm, HCP Terraform, …).\n- State files hold secrets in plaintext: read structure and addresses, never quote values.\n\n## Procedure\n\n1. **Remote backend + locking**: store state remotely (S3 with native `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.\n2. **Isolate state by blast radius**: separate state per environment (dev\u002Fstage\u002Fprod) and per independently-changing layer (network vs data vs app). A single giant state means every apply risks everything and serializes the team.\n3. **Workspaces vs directories**: prefer separate root configs\u002Fdirs (or a tool like Terragrunt) for strong env isolation; CLI workspaces only for lightweight, low-risk variation — they share a backend and are easy to misfire.\n4. **Drift detection**: scheduled `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.\n5. **Safe state surgery** — prefer the config-driven blocks, which show up in `plan` and get code-reviewed: `import {}` to adopt existing resources, `moved {}` for renames\u002Fmodule moves (so Terraform doesn't destroy+recreate), `removed {}` to stop managing without destroying. Fall back to CLI `state mv` \u002F `state rm` only when a block can't express it — and back up state (`terraform state pull > backup.tfstate`) first.\n6. **Secrets in state**: assume state contains secrets — restrict backend access (least privilege), encrypt, and avoid outputs that leak them.\n7. **Recovery**: state versioning\u002Fbackups + a documented restore; protect against concurrent corruption.\n\n## Output\n\n```text\nState design: payments infrastructure (AWS, 3 envs)\n\nBackend:  S3 bucket per env (tfstate-payments-{dev,stage,prod}), SSE-KMS, versioning on, use_lockfile = true\nLayout (one state per env × layer):\n  envs\u002Fprod\u002Fnetwork\u002F   VPC, subnets, NAT            apply: platform team, 2 approvers\n  envs\u002Fprod\u002Fdata\u002F      RDS, ElastiCache, S3 buckets  apply: platform team, 2 approvers, prevent_destroy on stores\n  envs\u002Fprod\u002Fapp\u002F       ECS services, ALB rules, SQS  apply: payments team\n  (dev and stage mirror the tree with their own buckets and credentials)\nDrift:    nightly `terraform plan -refresh-only` per state → alert on any diff; policy: codify within 2 business days or revert\nSurgery:  import {} \u002F moved {} \u002F removed {} blocks in a reviewed PR; CLI state mv\u002Frm only after `terraform state pull > backup.tfstate`\nAccess:   prod state readable by the CI role and 3 named admins (state contains secrets); no human write outside CI\nRecovery: restore from S3 object version; runbook docs\u002Frunbooks\u002Fterraform-state-restore.md, tested quarterly\n```\n\n## Quality bar\n\n- Remote, encrypted, versioned backend with locking — no shared local state.\n- State is segmented by environment and blast radius, not one monolith.\n- Drift is detected on a cadence with a written reconcile policy.\n- Refactors use `moved`\u002F`import`\u002F`removed` blocks (CLI state surgery only with a backup), never destroy+recreate of live infra.\n",{"name":5,"description":7},"main","23f6e21841a39580c9da2b5ec941f39dda17cd86","plugins\u002Fpolymath-iac\u002Fskills\u002Fterraform-state","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath","https:\u002F\u002Fgithub.com\u002FMohammadBafkar","2026-10-29 18:34:59",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add MohammadBafkar\u002Fpolymath --skill terraform-state",{"tool":36,"command":37},"bunx","bunx skills add MohammadBafkar\u002Fpolymath --skill terraform-state",{"tool":39,"command":40},"pnpm","pnpm dlx skills add MohammadBafkar\u002Fpolymath --skill terraform-state","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-iac\u002Fskills\u002Fterraform-state\u002FSKILL.md",true,[44],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"routing.yaml","REFERENCE","参考文档",438,"https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-iac\u002Fskills\u002Fterraform-state\u002Frouting.yaml",[51,58,65,72,79,86],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M74GN87EBRHM9N87M7AP1HDD","runbook","Write or refresh an operational runbook for an alert\u002Fsymptom; structured as TL;DR + Pre-checks + Steps + Verification + Rollback + Escalation.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Frunbook\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M74GN5GPKEC1JEKP2DFQNEQJ","rfc","Draft a lightweight design RFC to docs\u002Frfcs\u002F\u003Cslug>.md; Summary, Motivation, Detailed design, Drawbacks, Alternatives, Unresolved questions. A proposal to debate, not a recorded decision (adr).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Frfc\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M74GN2F4CWPMV4X09TG4E304","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.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Feditorial-pass\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M74GMZWGYMZ37C4DYGT6P23G","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.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Farchitecture-review-facilitation\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M74GMXVX0YX3ETDXS527XDGM","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).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Farchitecture-doc\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M74GMVG1WSMCK066S3KE6V5K","adr","Write an Architecture Decision Record (Michael Nygard format) to docs\u002Fadrs\u002FNNNN-\u003Cslug>.md; frontmatter validated by the ADR artifact schema. Records a made decision, not a proposal to debate (rfc).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Fadr\u002FSKILL.md",[],[]]