infra-terraform
Skill0 starsChanged 5 months agoMITView on GitHub
Manage Terraform infrastructure across the init/plan/apply/drift/destroy lifecycle with approval gates. Remote state with locking for shared environments, human-readable plans as the review artifact, apply only against an approved plan, read-only drift detection, and a hard-stop destroy mode. Use when the user asks to write, change, plan, apply, or destroy Terraform / IaC, set up state backends, or check infra drift.
In this repository22 other files it gives its agents.
- ai-directorSkill
- code-implementationSkill
- code-repairSkill
- code-verifySkill
- concept-runSkill
- db-migrationSkill
- deploy-basicSkill
- deploy-filesSkill
- dev-stackSkill
- docsSkill
- feature-specSkill
- plan-foundationSkill
- plan-masterSkill
- plan-repairSkill
- plan-syncSkill
- plan-verifySkill
- process-routerSkill
- project-bootstrapSkill
- project-query-setupSkill
- session-controlSkill
- tauri-developmentSkill
- x-directorSkill
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 6 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
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
- could be automatic: a setting could enforce it
- Very specific: line 24
Plan is the review artifact: Every apply on a shared environment is preceded by a human-reviewed, human-readable plan (terraform plan -out).
- Very specific: line 26
Destroy is a HARD STOP: Never run terraform destroy without explicit human approval in the same message (.cursorrules Core Principle 8).
- Very specific: line 27
No secrets in code: Never commit secrets to .tf, *.tfvars, or state-adjacent files.
- Very specific: line 31
Operator handoff: every response that ends a turn follows the Operator handoff contract — terse output.
- Distinctive: line 70
Before mutating a shared environment:
- Distinctive: line 74
If either is missing → stop with the blocked-report shape:
- Distinctive: line 102
Read-only against infrastructure (refreshes state, changes nothing).
- Distinctive: line 108
Do not apply in this mode.
- Distinctive: line 129
Read-only. No writes to config, state, or infrastructure.
- Very specific: line 132
Run terraform plan -detailed-exitcode: exit 0 = no drift, 2 = drift present (list the diff summary), 1 = error (report, do not remediate).
- Distinctive: line 144
Never run destroy in CI as a default step.
≈ “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
infra-terraform
Manage Terraform infrastructure with state as the source of truth and plan review as the gate before any change to shared environments.
Tool-agnostic (Cursor, Claude Code, opencode, Codex). Cloud-agnostic at the concept level; backend examples target S3 + DynamoDB and Terraform Cloud.
Pairs with: standards/20260819-IAC_CONVENTIONS.md (binding standard), concepts/declarative-infra/ (MOD-08), .cursorrules Core Principle 8.
Canonical path: .ai/skills/infra-terraform/skill.md · Invocation examples, backend templates: reference.md
Hard rules:
- Plan is the review artifact. Every
applyon a shared environment is preceded by a human-reviewed, human-readable plan (terraform plan -out). No reviewed plan, no apply. - Remote state for shared environments. Local state is dev-only. Shared envs use a remote backend with state locking on (S3 + DynamoDB, Terraform Cloud). See
reference.md§ State backends. - Destroy is a HARD STOP. Never run
terraform destroywithout explicit human approval in the same message (.cursorrulesCore Principle 8). Never wire destroy into CI as a default step. - No secrets in code. Never commit secrets to
.tf,*.tfvars, or state-adjacent files. Secrets come from env vars (TF_VAR_*) or a secrets manager. Seereference.md§ Secrets handling. - Pin providers.
required_providerswith version constraints + committed.terraform.lock.hcl. Seereference.md§ Provider version pinning. - Never edit state by hand.
terraform state mv/rmonly with explicit approval and a recorded reason; never edit state files directly. - Drift is checked, not assumed.
status/driftmodes are read-only (terraform plan -detailed-exitcode); report interpretation, never auto-remediate. - Operator handoff: every response that ends a turn follows the Operator handoff contract — terse output; approvals under
**Needs your approval:**citingpath:L<n>; questions numbered under**Needs your answer:**; exactly one**Next step:**command; one line when nothing is needed (Form A). Decisions and questions never mixed; empty sections omitted.
Parse invocation
Normalize the user message to verb + optional target (env, module, workspace).
| User says | Verb | Action |
@infra-terraform init | init | Backend + remote state + locking setup guidance |
@infra-terraform setup | init (alias) | Same as init |
@infra-terraform plan | plan | Produce a human-readable plan (the review artifact) |
@infra-terraform apply | apply | Apply an approved plan (state locking on) |
@infra-terraform status | status | Read-only: state, backend, and drift summary |
@infra-terraform drift | drift | Read-only: terraform plan -detailed-exitcode interpretation |
@infra-terraform destroy | destroy | HARD STOP - same-message human approval required |
Aliases: setup, bootstrap → init. status and drift are both read-only.
Step 0 - Pick a mode
| Mode | Action |
| init | Init protocol - backend, remote state, locking, layout |
| plan | Plan protocol - produce the review artifact |
| apply | Apply protocol - gated on an approved plan |
| status | Status / drift protocol - read-only |
| drift | Status / drift protocol - read-only |
| destroy | Destroy protocol - HARD STOP |
Prerequisite gate (mutating modes)
Applies to: apply, destroy. Skipped for init (it builds the prerequisites) and plan / status / drift (read-only on infra).
Before mutating a shared environment:
- Confirm the backend is remote with locking (check
backendblock orterraform backendconfig). - Confirm provider pins:
required_providers+ committed.terraform.lock.hcl. - If either is missing → stop with the blocked-report shape:
- Required: remote backend with locking + pinned providers (per
standards/20260819-IAC_CONVENTIONS.md) - Detected: local state backend and/or unpinned providers
- Run first:
@infra-terraform init
- Required: remote backend with locking + pinned providers (per
Blocked-report shape
Per SKILL_DEPENDENCIES.md § Blocked report shape - header: ## @infra-terraform <command> - blocked (prerequisite).
Init protocol
Set up backend, state, and layout. Writes .tf config only; never applies.
- Inventory: existing
*.tf, backend config, state files (*.tfstate), workspaces. - Choose backend per
reference.md§ State backends: S3 + DynamoDB locking (AWS), Terraform Cloud, or local (dev-only, never shared). - Choose env strategy per
reference.md§ Workspace vs directory-per-env: default directory-per-env (envs/dev/,envs/staging/,envs/prod/+modules/). - Write the
terraform { backend … required_providers … }blocks; pin providers. - Never run
terraform init -migrate-stateagainst existing state without explicit same-message approval. - Output an init report (actions table + remaining manual steps: create the state bucket/table, set credentials via env).
End the report with the Operator handoff close (Form A or Form B) per SKILL_DEPENDENCIES.md.
Plan protocol
Read-only against infrastructure (refreshes state, changes nothing).
terraform init(if needed) +terraform validate+terraform fmt -check.terraform plan -out=tfplan-<env>and produce the human-readable rendering alongside it.- Present the plan as the review artifact: creates / changes / destroys counts, and every destroy or replace called out explicitly.
- Blast-radius note per MOD-08 (
concepts/declarative-infra/prompt.md): which shared resources does this plan touch? - Do not apply in this mode. Hand the plan to the operator for approval.
End the report with the Operator handoff close (Form B - plan approval is a **Needs your approval:** item) per SKILL_DEPENDENCIES.md.
Apply protocol
Gate: requires a plan reviewed and approved by the human in this session (see reference.md § Plan-approval gate checklist).
- Confirm the approved plan file matches the current config (
terraform planagain must be empty against the approved plan, or re-plan). - Confirm state locking is active.
terraform apply tfplan-<env>(apply the saved plan, not a fresh auto-approve run). Never-auto-approveon shared envs.- Report applied changes + outputs.
End the report with the Operator handoff close (Form A or Form B) per SKILL_DEPENDENCIES.md.
Status / drift protocol
Read-only. No writes to config, state, or infrastructure.
- Report backend type, workspace/dir, provider pins.
- Run
terraform plan -detailed-exitcode: exit0= no drift,2= drift present (list the diff summary),1= error (report, do not remediate). - Interpret drift per
reference.md§ Drift detection cadence; propose@infra-terraform planif remediation is wanted - never auto-fix.
End the report with the Operator handoff close (Form A or Form B) per SKILL_DEPENDENCIES.md.
Destroy protocol
HARD STOP. .cursorrules Core Principle 8 applies.
- Stop and ask for explicit approval in the same message, naming the exact env/workspace and the resources
terraform plan -destroyreports. - Never run destroy in CI as a default step; a CI destroy job requires its own explicit approval each time.
- On approval: run
terraform plan -destroyfirst, show the full destroy list, thenterraform destroy(still with locking on). - Record what was destroyed in the report.
The approval request must be an enumerated **Needs your approval:** item in the Operator handoff close (Form B) per SKILL_DEPENDENCIES.md.
Anti-patterns
- Applying without a reviewed, human-readable plan.
- Local state for shared environments (state file on one laptop = unrecoverable drift).
terraform destroyin CI without explicit per-run approval.- Storing secrets in
.tf/*.tfvarsplaintext or committing state files with sensitive outputs. - Editing state by hand (
*.tfstateedits, unapprovedstate mv/rm). -auto-approveon shared environments.- Unpinned providers or uncommitted
.terraform.lock.hcl. - Burying operator actions or questions in prose instead of the closing handoff block (Operator handoff contract, Form A/B).
Integration with other skills
| Skill | Integration |
concept-run | MOD-08 (declarative-infra) runs before the first apply to shared infra |
plan-foundation | P5 infrastructure decisions reference standards/20260819-IAC_CONVENTIONS.md |
dev-stack | Local containers stay in compose; Terraform owns cloud/shared resources |
Completion checklist (all modes)
| # | Check | Result | Evidence |
| 1 | Mode detected correctly | pass/fail | |
| 2 | Remote backend + locking confirmed (mutating modes) | pass/skip | backend block |
| 3 | Providers pinned, lock file committed | pass/fail | required_providers |
| 4 | Plan reviewed and approved (apply mode) | pass/skip | plan artifact |
| 5 | No secrets in config/tfvars | pass/fail | |
| 6 | Destroy approved in the same message (destroy mode) | pass/skip | |
| 7 | Drift exit code interpreted (status/drift mode) | pass/skip | -detailed-exitcode output |
Close every mode's final output with the Operator handoff close (Form A or Form B) per SKILL_DEPENDENCIES.md; no operator-required action may live only in a checklist row.
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.

