terraform-expert
Skill5 starsChanged 3 months agoMITView on GitHub
Use when working with .tf/.tofu/.tfvars files, HCL, terraform or tofu CLI commands, providers, modules, remote state/backends, tfstate, or plan/apply pipelines. Writes and refactors Terraform 1.9+/OpenTofu configurations, designs reusable modules, performs safe state surgery, and wires CI plan/apply workflows. Invoke for authoring resources or modules, migrating backends or state, converting count to for_each, importing existing infrastructure, handling secrets in IaC, or setting up PR-plan/merge-apply pipelines.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- iamdemetris/lude-kittheir own version, first seen Jul 17, 2026
- boreal1/agentstheir own version, first seen Apr 25, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- boreal1/agents★ 0same name
- iamdemetris/lude-kit★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- docker-expertSkill
- engineering-rulesSkill
- fastapi-expertSkill
- fastify-expertSkill
- flutter-expertSkill
- go-expertSkill
- jetpack-compose-expertSkill
- mobile-qa-expertSkill
- nestjs-expertSkill
- playwright-expertSkill
- react-expertSkill
- react-native-expertSkill
- remix-expertSkill
- swiftui-expertSkill
- vue-expertSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
Keep secrets out of state and plaintext (sensitive/ephemeral values, external stores)
- Very specific: line 29
Analyze: - read versions.tf/terraform blocks (required_version, provider constraints), the backend config, existing module structure, and …
- Very specific: line 30
Implement: - write HCL matching the project's layout.
- Very specific: line 31
Verify format: - run terraform fmt -check -recursive (or tofu fmt).
- Very specific: line 32
Verify configuration: - run terraform validate (after terraform init -backend=false if init hasn't run).
- Very specific: line 33
Lint: - run tflint --recursive (init rulesets with tflint --init if needed).
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Terraform Expert
Turns Claude into a senior platform engineer who ships Terraform 1.9+/OpenTofu-compatible HCL with safe state management, contract-driven modules, and plan-gated delivery.
When to Use This Skill
- Author or refactor resources, data sources, and variables in
.tffiles - Design reusable modules with typed variable/output contracts and version pinning
- Configure or migrate remote state backends (S3 with native lockfile, HTTP, cloud)
- Rename/move/import resources without destroying them (
moved,import,removedblocks) - Convert
counttofor_eachor restructure collections without replacement - Keep secrets out of state and plaintext (sensitive/ephemeral values, external stores)
- Set up CI: fmt/validate/tflint gates, plan-on-PR, apply-on-merge, drift detection
Core Workflow
- Analyze - read
versions.tf/terraformblocks (required_version, provider constraints), the backend config, existing module structure, and naming/tagging conventions. Runterraform providersandterraform state list(read-only) to understand what exists. Determine whether the project uses Terraform or OpenTofu (tofuCLI,.tofufiles) and match it. - Implement - write HCL matching the project's layout. Prefer
for_eachkeyed on stable strings, pin provider versions with~>constraints, express refactors asmoved/import/removedblocks instead of CLI state commands, and mark secret inputssensitive = true(never literal secrets in.tfor.tfvars). - Verify format - run
terraform fmt -check -recursive(ortofu fmt); if it reports files, runterraform fmt -recursive, fix all reported issues, and re-run until clean. - Verify configuration - run
terraform validate(afterterraform init -backend=falseif init hasn't run); fix all reported errors and re-run until clean. - Lint - run
tflint --recursive(init rulesets withtflint --initif needed); fix all reported issues and re-run until clean. Do not blanket-disable rules to silence findings. - Plan - mandatory gate before any apply - run
terraform plan -out=tfplanand read the full plan output. Confirm everycreate/updateis intended, and treat any destroy or replace (-/+, "must be replaced", "forced replacement") line as a stop: apply is blocked until a human explicitly reviews and approves those lines. If the plan shows unintended destroys/replacements, fix the config (usually amovedblock,lifecycleargument, or restoredfor_eachkey) and re-plan until the plan contains only intended actions. - Apply and prove it works - only after the plan gate passes, run
terraform apply tfplan(the saved plan, never a fresh auto-approved plan). Then verify reality: check outputs, query the created infrastructure, and runterraform planagain - a clean follow-up plan ("No changes") proves convergence; if it still shows diffs, fix the drift or config and re-run until clean.
Reference Guide
Load detailed guidance only when the task needs it:
| Topic | Reference | Load When |
| Remote backends, state locking, state surgery | references/state-and-backends.md | Configuring/migrating a backend, S3 + lockfile setup, renaming/moving/importing/forgetting resources, workspaces, state file questions |
| Module design, variable/output contracts, versioning | references/modules.md | Creating or refactoring a module, typed variables with validation, optional() defaults, module sources and version pinning, provider passing |
| for_each vs count, lifecycle meta-arguments | references/foreach-lifecycle.md | Any resource collection, converting count to for_each, unwanted destroy/replace in plans, create_before_destroy, prevent_destroy, ignore_changes, replace_triggered_by |
| Secrets, sensitive values, security posture | references/secrets-and-security.md | Any credential/API key/password in config, secrets appearing in state or plan output, ephemeral values, write-only arguments, external secret stores |
| CI pipelines, plan review, drift detection | references/ci-workflows.md | Setting up plan-on-PR/apply-on-merge, GitHub Actions or GitLab CI for Terraform, OIDC cloud auth, scheduled drift detection, plan artifacts |
Key Patterns
Config-driven state surgery - never terraform state mv by hand:
moved {
from = aws_instance.app
to = aws_instance.app["primary"] # count -> for_each rename, no destroy
}
import {
to = aws_s3_bucket.logs
id = "acme-prod-logs" # adopt existing infra via plan/apply
}
removed {
from = aws_iam_user.legacy
lifecycle { destroy = false } # forget from state, keep the real resource
}for_each keyed on stable strings (indexes shift; keys don't):
variable "subnets" {
type = map(object({ cidr = string, az = string }))
}
resource "aws_subnet" "this" {
for_each = var.subnets # keys: "public-a", "private-a", ...
vpc_id = aws_vpc.main.id
cidr_block = each.value.cidr
availability_zone = each.value.az
}Version pinning - providers get ~>, modules get exact or ~>:
terraform {
required_version = ">= 1.9.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.0"
}
}
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 6.0" # never unpinned registry modules
}Cross-variable validation (Terraform 1.9+):
variable "instance_count" {
type = number
}
variable "azs" {
type = list(string)
validation {
condition = var.instance_count <= length(var.azs)
error_message = "instance_count cannot exceed the number of AZs."
}
}Common Mistakes
- Applying without reviewing the plan -
terraform apply -auto-approvewith no saved plan is how production gets destroyed. Alwaysplan -out=tfplan, human-review every destroy/replace line, thenapply tfplan. - Switching
counttofor_each(or reordering a list) withoutmovedblocks - the plan destroysresource[1]and createsresource["name"]because state addresses changed, not the infrastructure. Write onemovedblock per element before planning. - Editing state with CLI commands (
state mv,state rm,terraform import) - these mutate state immediately with no plan preview and don't survive code review. Usemoved,removed, andimportblocks so the change is visible in the plan and in the PR. - Treating a data source as a dependency-free lookup -
datablocks read existing infrastructure at plan time and fail if it doesn't exist yet; they do not create anything. If this config manages the object, reference the resource directly; never pair a resource with a data source for the same object in one config. - Secrets in
.tfvars, locals, or resource arguments - they land in plaintext state and plan files. Mark variablessensitive = true, prefer ephemeral values/write-only arguments (Terraform 1.10/1.11+), and fetch from a secret store at runtime; never commit them. - Unpinned providers or modules - a missing
versionconstraint means the nextinit -upgradecan pull a breaking major and the plan silently changes. Pin providers~> MAJOR.MINORand commit.terraform.lock.hcl. ignore_changesas a drift band-aid - ignoring an argument hides real configuration divergence forever. Use it only for fields legitimately mutated outside Terraform (e.g., autoscaleddesired_count), and document why.- Assuming DynamoDB is required for S3 state locking - since Terraform 1.10/1.11,
use_lockfile = trueon the S3 backend provides native locking via a lock object; DynamoDB-based locking is legacy.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

