
Terraform Style Guide
This enforces HashiCorp's official Terraform style conventions so you stop arguing about formatting in code reviews. It handles the standard file organization (terraform.tf, providers.tf, main.tf, variables.tf, outputs.tf), ensures two-space indentation with aligned equals signs, and mandates descriptions on every variable and output. The guide prioritizes for_each over count, includes validation rules for variables, and covers version pinning strategies. Use it when generating new Terraform configurations or reviewing existing ones. It's opinionated about security practices and references a separate SECURITY.md, plus includes a pre-commit checklist covering fmt, validate, and basic hygiene checks.
- skills.sh installs
- 13.2K
- GitHub stars
- 924
- last updated
- Aug 21, 2026
Install
$ npx -y skills add hashicorp/agent-skills --skill terraform-style-guide --agent claude-codeInstalls into .claude/skills of the current project.
Files
Terraform Style Guide
Generate and maintain Terraform code following HashiCorp's official style conventions and best practices.
Reference: HashiCorp Terraform Style Guide
Code Generation Strategy
When generating Terraform code:
- Start with provider configuration and version constraints
- Create data sources before dependent resources
- Build resources in dependency order
- Add outputs for key resource attributes
- Use variables for all configurable values
File Organization
| File | Purpose |
|---|---|
terraform.tf | Terraform and provider version requirements |
providers.tf | Provider configurations |
main.tf | Primary resources and data sources |
variables.tf | Input variable declarations (alphabetical) |
outputs.tf | Output value declarations (alphabetical) |
locals.tf | Local value declarations |
Example Structure
# terraform.tf
terraform {
required_version = ">= 1.14"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.0"
}
}
}
Sponsors
Details
More from hashicorp/agent-skills
All 16- Terraform Test9.2K
- Refactor Module6.6K
- Terraform Stacks5.8K
- Terraform Search Import5.1K
- Provider Resources4.2K
- New Terraform Provider4K
- Provider Actions4K
- Run Acceptance Tests3.8K
- Azure Verified Modules3.4K
- Provider Test Patterns3.4K
- Provider Docs3.3K
- Aws Ami Builder3.3K
- Push To Registry3.1K
- Azure Image Builder2.8K
- Windows Builder2.8K