Terraform/OpenTofu — module design and versioning, remote state with locking, environments via workspaces or directories, plan review, drift detection, `moved` and `import` blocks, policy as code, provider pinning, secrets handling. Use for infrastructure as code (Terraform, OpenTofu, IaC, module, state, plan, drift).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Terraform?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vectora-os-terraform)
---
name: terraform
description: Terraform/OpenTofu — module design and versioning, remote state with locking, environments via workspaces or directories, plan review, drift detection, `moved` and `import` blocks, policy as code, provider pinning, secrets handling. Use for infrastructure as code (Terraform, OpenTofu, IaC, module, state, plan, drift).
metadata:
category: infrastructure
---
# Terraform
## Purpose
Manage infrastructure as reviewable, modular, reproducible code.
**Use when:** any infrastructure change.
**Not for:** manual console changes.
## Inputs
- Infrastructure design, current state.
## Outputs
- Modules, plan output, drift report.
## Read first
- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "terraform"` for prior decisions, patterns and anti-patterns.
## Steps
1. **Modules.** Small composable modules with inputs validated and outputs documented.
Done when modules are versioned.
2. **State.** Remote state, locking, one state per environment and component.
Done when blast radius bounded.
3. **Plan.** Plan in CI on PR; review for destroys and replacements.
Done when plan attached to PR.
4. **Drift.** Scheduled drift detection; import or fix.
Done when drift is zero or explained.
## Best practices
- Pin provider versions.
- Refactor with `moved` blocks to avoid recreation.
## Common mistakes
- Secrets in state without encryption.
- One giant state file.
## Example
VPC refactor to a module with `moved` blocks; plan shows 0 to add, 0 to destroy.
## Reusable prompt
```text
Apply the Terraform skill (.agents/skills/terraform/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Structure or review the Terraform: modules, state layout, plan review and drift handling.
Return: Modules, plan output, drift report..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```