hashicorp avatar

Terraform Style Guide

Style guide that generates and reviews Terraform HCL following HashiCorp's official conventions and best practices.

CCM score
70 of 100
skills.sh installs
13.8K
GitHub stars
941
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers file organization, formatting, naming, variables, outputs, dynamic resources, version pinning, and provider configuration
  • Includes a standard file layout (terraform.tf, providers.tf, main.tf, variables.tf, outputs.tf, locals.tf) with example HCL for each
  • Enforces for_each over count for multiple resources, and requires type, description, and sensitive markings on variables and outputs
  • Designed for writing, reviewing, or generating Terraform configurations, with a pre-commit checklist using terraform fmt and terraform validate

Install

$ npx -y skills add hashicorp/agent-skills --skill terraform-style-guide -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

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"
    }
  }
}

Details

Repository
github.com/hashicorp/agent-skills
Category
DevOps & Cloud

More from hashicorp/agent-skills

All 16

Similar to Terraform Style Guide

More DevOps & Cloud