hashicorp avatar

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-code

Installs 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:

  1. Start with provider configuration and version constraints
  2. Create data sources before dependent resources
  3. Build resources in dependency order
  4. Add outputs for key resource attributes
  5. Use variables for all configurable values

File Organization

FilePurpose
terraform.tfTerraform and provider version requirements
providers.tfProvider configurations
main.tfPrimary resources and data sources
variables.tfInput variable declarations (alphabetical)
outputs.tfOutput value declarations (alphabetical)
locals.tfLocal value declarations

Example Structure

# terraform.tf
terraform {
  required_version = ">= 1.14"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 6.0"
    }
  }
}

Sponsors

Details

Repository
github.com/hashicorp/agent-skills
Categories
DevOps & CI/CD, Documentation, Code Review & Quality, AI & Agent Building, Cloud & Infrastructure

More from hashicorp/agent-skills

All 16
1parallel-web avatarparallel-monitorparallel-web/parallel-agent-skillsContinuously track the web for changes on a recurring cadence. Use when the user asks to 'monitor', 'track changes to', 'watch', or 'alert me when' something on12.7Kskills.sh installs
2wshobson avatarincident-runbook-templateswshobson/agentsCreate structured incident response runbooks with step-by-step procedures, escalation paths, and recovery actions. Use this skill when building a service outage11.4Kskills.sh installs
3vercel-labs avatarvercel-sandboxvercel-labs/agent-browser11.3Kskills.sh installs
4google avataragent-platform-deploygoogle/skillsDeploy open models or custom weights from Model Garden to Agent Platform endpoints, check the status of an in-progress deployment operation, or clean up resourc9.8Kskills.sh installs
5github avatardevops-rollout-plangithub/awesome-copilotGenerate comprehensive rollout plans with preflight checks, step-by-step deployment, verification signals, rollback procedures, and communication plans for infr9.7Kskills.sh installs
6github avatarterraform-azurerm-set-diff-analyzergithub/awesome-copilotAnalyze Terraform plan JSON output for AzureRM Provider to distinguish between false-positive diffs (order-only changes in Set-type attributes) and actual resou8.9Kskills.sh installs