npx skills add ...
npx skills add alirezarezvani/claude-skills --skill terraform-patterns
Terraform infrastructure-as-code agent skill and plugin for Claude Code, Codex, Gemini CLI, Cursor, OpenClaw. Covers module design patterns, state management strategies, provider configuration, security hardening, policy-as-code with Sentinel/OPA, and CI/CD plan/apply workflows. Use when: user wants to design Terraform modules, manage state backends, review Terraform security, implement multi-region deployments, or follow IaC best practices.
npx skills add alirezarezvani/claude-skills --skill terraform-patterns
Predictable infrastructure. Secure state. Modules that compose. No drift.
Opinionated Terraform workflow that turns sprawling HCL into well-structured, secure, production-grade infrastructure code. Covers module design, state management, provider patterns, security hardening, and CI/CD integration.
Not a Terraform tutorial — a set of concrete decisions about how to write infrastructure code that doesn't break at 3 AM.
| Command | What it does |
|---|---|
/terraform:review | Analyze Terraform code for anti-patterns, security issues, and structure problems |
/terraform:module | Design or refactor a Terraform module with proper inputs, outputs, and composition |
/terraform:security | Audit Terraform code for security vulnerabilities, secrets exposure, and IAM misconfigurations |
Recognize these patterns from the user:
.tf files, HCL, Terraform modules, state management, provider configuration, infrastructure-as-codeIf the user has .tf files or wants to provision infrastructure with Terraform → this skill applies.
/terraform:review — Terraform Code ReviewAnalyze current state
.tf files in the target directoryApply review checklist
Generate report
Run security scan
/terraform:module — Module DesignIdentify module scope
Apply module design checklist
Generate module scaffold
/terraform:security — Security AuditCode-level audit
| Check | Severity | Fix |
|---|---|---|
Hardcoded secrets in .tf files | Critical | Use variables with sensitive = true or vault |
IAM policy with * actions | Critical | Scope to specific actions and resources |
| Security group with 0.0.0.0/0 on port 22/3389 | Critical | Restrict to known CIDR blocks or use SSM/bastion |
| S3 bucket without encryption | High | Add server_side_encryption_configuration block |
| S3 bucket with public access | High | Add aws_s3_bucket_public_access_block |
| RDS without encryption | High | Set storage_encrypted = true |
| RDS publicly accessible | High | Set publicly_accessible = false |
| CloudTrail not enabled | Medium | Add aws_cloudtrail resource |
Missing prevent_destroy on stateful resources | Medium | Add lifecycle { prevent_destroy = true } |
Variables without sensitive = true for secrets | Medium | Add sensitive = true to secret variables |
State security audit
| Check | Severity | Fix |
|---|---|---|
| Local state file | Critical | Migrate to remote backend with encryption |
| Remote state without encryption | High | Enable encryption on backend (SSE-S3, KMS) |
| No state locking | High | Enable DynamoDB for S3, native for TF Cloud |
| State accessible to all team members | Medium | Restrict via IAM policies or TF Cloud teams |
Generate security report
scripts/tf_module_analyzer.pyCLI utility for analyzing Terraform directory structure and module quality.
Features:
Usage:
scripts/tf_security_scanner.pyCLI utility for scanning .tf files for common security issues.
Features:
Usage:
Best for: Single application, < 20 resources, one team owns everything.
Best for: Multiple environments, shared infrastructure patterns, team collaboration.
Best for: Large-scale, many environments, DRY configuration, team-level isolation.
Flag these without being asked:
version = "~> X.0" to prevent breaking upgrades.sensitive = true, or integrate Vault/SSM."Action": "*" → Scope to specific actions. No wildcard actions in production.prevent_destroy on databases/storage → Add lifecycle block to prevent accidental deletion.When a single root module must provision across AWS, Azure, and GCP simultaneously.
OpenTofu is an open-source fork of Terraform maintained by the Linux Foundation under the MPL 2.0 license.
| Terraform (1.6+) | OpenTofu | |
|---|---|---|
| License | BSL 1.1 (source-available) | MPL 2.0 (open-source) |
| Commercial use | Restricted for competing products | Unrestricted |
| Community governance | HashiCorp | Linux Foundation |
OpenTofu tracks Terraform 1.6.x features. Key additions unique to OpenTofu:
tofu init -encryption)Infracost estimates cloud costs from Terraform code before resources are provisioned.
Bring manually-created resources under Terraform management.
terraform plan immediately and resolve every diff.terraform state mv to rename or reorganize. Use terraform state rm to remove without destroying. Always back up state before manipulation: terraform state pull > backup.tfstate.Terragrunt is a thin wrapper around Terraform that provides DRY configuration for multi-environment setups.