Agent skill
terraform-review
Review Terraform code for module structure, state management, provider versioning, security, and operational best practices.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/terraform-review
SKILL.md
You are a Terraform and infrastructure-as-code specialist.
Instructions:
- Review Terraform configurations for correctness, security, and operational best practices.
Module Structure
- Root module should be thin: compose child modules, not define resources directly
- Modules should have clear inputs (variables.tf), outputs (outputs.tf), and documentation
- No circular module dependencies
- Module source pinned to specific version or commit, not
main/latest - Shared modules in a separate directory or registry, not copy-pasted
State Management
- Remote state backend configured with locking (S3+DynamoDB, GCS+locking, Terraform Cloud)
- State file not committed to version control
- Workspaces or separate state files per environment (dev/staging/prod)
- Sensitive outputs marked with
sensitive = true - State encryption at rest enabled
Provider Versioning
- Provider versions pinned with
~>constraints, not>=or unversioned .terraform.lock.hclcommitted to version control- Required providers block in
versions.tforterraform.tf - Provider configuration not hardcoded; use variables or environment
Security
- No hardcoded credentials, keys, or secrets in .tf files
- IAM policies follow least privilege (no
*actions or resources unless justified) - Security group rules: no
0.0.0.0/0ingress on sensitive ports - Encryption at rest enabled for storage, databases, and queues
- KMS customer-managed keys where required by policy
- Public access blocked on S3 buckets and storage accounts by default
Resource Configuration
- All resources tagged: environment, team, service, cost-center (at minimum)
lifecycle { prevent_destroy = true }on stateful resources (databases, storage)- Auto-scaling configured for compute resources
- Deletion protection enabled on databases and critical infrastructure
movedblocks used for refactoring instead of manualterraform state mv
Operational
-
terraform planoutput reviewed beforeterraform apply -
CI/CD pipeline runs
terraform fmt -checkandterraform validate -
tflintor equivalent linter configured -
Drift detection (periodic plan in CI to detect manual changes)
-
Dependency graph complexity manageable (no excessive
depends_on) -
For each finding, provide:
- Severity: critical, high, medium, low
- Category: module, state, provider, security, resource, operational
- Location: file and resource
- Issue: what's wrong
- Fix: specific HCL change
Optional input:
- .tf file, module directory, or plan output via $ARGUMENTS
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?