Terraform
Writes, debugs, and refactors Terraform — HCL and modules, plan and apply failures, state surgery, drift, and provider pinning. Use when writing or reviewing…
от clawic★ 23 звезды на GitHub
Установить Terraform в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
User preferences and memory live in ~/Clawic/data/terraform/ (see setup.md on first use, memory-template.md for the file format). If you have data at an old location (~/terraform/ or ~/clawic/terraform/), move it to ~/Clawic/data/terraform/, and say in one line that you moved it and from where.
When To Use
- Writing or reviewing HCL: resource design, count vs for_each, module boundaries, variable types and validation
- Debugging plan/apply failures, permanent diffs, cycles, unknown-at-plan errors, stuck locks, drift
- Refactoring live infrastructure: renames, module extraction, imports, splitting or merging state
- Pinning providers, upgrading the CLI or a provider major version, moving between Terraform and OpenTofu
- Designing backends, environment layout, and CI plan/apply gates with policy, tests, and drift detection
- Recovering after damage: lost or corrupted state, wrong
state rm, unintended destroy, interrupted apply - Not for choosing which cloud resources to build (→
aws,gcp,azure) or configuring what runs inside them (→ansible)
Quick Reference
| Situation | Play |
|---|---|
| Renamed a resource or module in code | moved block (>=1.1); apply everywhere, delete the block in a later PR → refactoring.md |
| Cloud object exists but is not in state | import block (>=1.5) + plan -generate-config-out=gen.tf; rewrite the draft, merge at zero diff → refactoring.md |
| Stop managing something without destroying it | removed block with destroy = false (>=1.7); state rm only as one-off surgery → refactoring.md |
| Permanent diff on every plan | Find the writer (autoscaler, console, another pipeline, provider normalization) before reaching for ignore_changes → debug.md |
| "Invalid for_each argument" / "Invalid count argument" | Key on values known at plan time, never on resource attributes → expressions.md |
| A variable value is ignored, or an old value keeps winning | Precedence: -var/-var-file > *.auto.tfvars > terraform.tfvars > TF_VAR_ > the declared default → expressions.md |
| "Error: Cycle: ..." | Break the mutual reference into a standalone rule/attachment resource → debug.md |
| "Provider produced inconsistent final plan" | Provider bug: upgrade the provider, then pin and report → debug.md |
| "Saved plan is stale" | State moved between plan and apply; re-plan, re-review, re-apply → ci.md |
| Stuck state lock | Prove the holder is dead, then force-unlock <LOCK_ID> → recovery.md |
| State lost, corrupted, or pushed wrong | Bucket object versions are the only undo; rebuild by import if there are none → recovery.md |
| "Inconsistent dependency lock file" or a checksum error on install | The lock lacks that provider or that platform → providers.md |
| Two regions, two accounts, one config | Provider alias + explicit providers map into modules → providers.md |
| Plan takes minutes | -refresh=false while iterating, then split state by blast radius → performance.md |
| Throttling or "Rate exceeded" during apply | Lower -parallelism (default 10) → performance.md |
| Moving to a remote backend or between backends | Pull a backup, then init -migrate-state → state.md |
| Secret landed in state, a plan file, or a log | Rotate first; state is plaintext and old versions keep it → secrets.md |
| Provider major upgrade (v4 → v5) | Upgrade guide, one canary stack, explained diff per environment → upgrades.md |
| Module design, versioning, or nesting question | Exact pins for third-party, ~> for internal, two levels max → modules.md |
| Resource must never be destroyed, must rotate with another, or keeps diffing on one attribute | lifecycle meta-arguments and what each one costs → lifecycle.md |
A destroy fails or a teardown leaves debris |
Deletion protection, retained objects, reverse-order dependencies → lifecycle.md |
| Wiring plan-on-PR and apply-on-merge | OIDC role, saved plan artifact, one concurrency group per state → ci.md |
| Need tests or policy gates | .tftest.hcl (>=1.6), plan-JSON assertions, policy engine → testing.md |
| Need the exact command under pressure | → commands.md |
| Anything else | Smallest possible change; plan -out=tfplan; read the destroy count and every "forces replacement" line before applying |
Depth on demand: debug.md plan/apply symptom→cause chains · state.md backends, locking, layout · refactoring.md moved/import/removed · modules.md design and versioning · expressions.md HCL loops, types, functions · lifecycle.md replacement, protection, ignored drift · providers.md pinning, lock file, aliases · secrets.md sensitive values and state exposure · ci.md pipelines, OIDC, drift detection · testing.md validate, terraform test, policy · upgrades.md CLI and provider majors, OpenTofu · performance.md slow plans and big states · recovery.md after the damage · commands.md incident toolkit.
Core Rules
- **The saved plan is th
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- _meta.json
- ci.md
- commands.md
- debug.md
- expressions.md
- lifecycle.md
- memory-template.md
- modules.md
- performance.md
- providers.md
- recovery.md
- refactoring.md
- secrets.md
- setup.md
- state.md
- testing.md
- upgrades.md
FAQ
Что делает скилл Terraform?
Writes, debugs, and refactors Terraform — HCL and modules, plan and apply failures, state surgery, drift, and provider pinning. Use when writing or reviewing HCL, when terraform plan or apply errors out, when a plan shows a permanent diff, an unexplained destroy, or "forces replacement", when renaming, importing, or moving resources between modules and states, when a state lock is stuck or state is lost or corrupted, when for_each fails because a value is not known until apply, when pinning providers or surviving a major version upgrade, or when wiring plan-on-PR, apply-on-merge, drift detection, and policy gates. Covers OpenTofu, tfstate, backends, workspaces, and infrastructure-as-code review. Not for choosing which cloud services to build — see aws, gcp, or azure.
Как установить скилл Terraform?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Terraform запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…