terraform-style-guide
Terraform style guide
terraform-style-guide is HashiCorp's agent skill for writing and reviewing Terraform HCL to the official style conventions: file layout, formatting, naming, typed variables, version pinning and a review checklist.
Install Terraform style guide
Install this skill with the skills CLI
npx skills add hashicorp/agent-skills --skill terraform-style-guideOr, for Claude Code, add HashiCorp's plugin marketplace
claude plugin marketplace add hashicorp/agent-skillsThen install the terraform plugin, which holds all 16 Terraform skills
claude plugin install terraform@hashicorpIn Codex, HashiCorp's README says to add the repository's .agents/plugins/marketplace.json as a repository marketplace, then install the terraform plugin.
Or paste this into your coding agent: Install the agent skill terraform-style-guide from github.com/hashicorp/agent-skills.
A skill can include scripts that run on your computer, so read its source first.
What Terraform style guide does
terraform-style-guide is an agent skill from HashiCorp that loads when an agent writes, reviews or generates Terraform configuration. It sets the order of work: provider and version constraints first, then data sources, resources in dependency order, outputs, and variables for anything configurable. Files follow a fixed split: terraform.tf, providers.tf, main.tf, variables.tf, outputs.tf and locals.tf, with variables and outputs kept alphabetical.
The formatting and naming rules in terraform-style-guide follow HashiCorp's published style guide. Code uses two-space indentation and aligned equals signs, meta-arguments come before arguments, and lifecycle blocks go last. Names are lowercase with underscores, singular, and do not repeat the resource type. Every variable needs a type and description, every output a description, and secrets are marked sensitive. for_each is preferred over count, except for conditional creation.
The skill ends with a review checklist: terraform fmt and terraform validate pass, versions are pinned, and no credentials are hardcoded. A separate SECURITY.md in the skill folder covers encryption, keeping secrets out of state and ephemeral resources. It also lists what never to commit, such as state files and plan files, and what always to commit, such as the dependency lock file.
When to use Terraform style guide
- You want an agent to write a new Terraform configuration that a HashiCorp reviewer would accept.
- You are reviewing a Terraform pull request and want a consistent checklist.
- Your Terraform files are one long main.tf and you want them split the standard way.
- You keep seeing untyped variables or outputs without descriptions in your modules.
When to pick something else
- Reviewing the output of terraform plan before an apply: HashiCorp's 20 skills (read 2026-10-01) include none made only for that job.
- Splitting a large configuration into reusable modules: use refactor-module from the same repository.
What Terraform style guide needs
- Terraform CLI for terraform fmt and terraform validate; tflint, checkov or tfsec are optional extras the skill mentions
Which agents Terraform style guide works in
HashiCorp documents Terraform style guide for GitHub Copilot, Claude Code, Codex, Cursor, OpenCode, IBM Bob. The open skills CLI also installs it into 78 agents, including Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode (we listed it with the CLI on October 1, 2026). See where each agent looks for skills.
Terraform style guide license
Terraform style guide is published under MPL-2.0. MPL-2.0 is a file-level copyleft license: you can use and copy the skill in any project, including closed source ones, but if you distribute changed versions of its files, those files stay under MPL-2.0 and must be shared as source.
Questions people ask
Does HashiCorp have an agent skill that reviews terraform plan output?
No. On 2026-10-01 hashicorp/agent-skills held 20 skills, 16 for Terraform and 4 for Packer, and none is dedicated to reading or reviewing terraform plan output. The closest is terraform-test, which can run tests in plan mode against assertions you write.
Can I copy this HashiCorp skill into my own repository?
Yes. The skill is MPL-2.0. You can copy and use it in any project, open or closed source. If you change its files and distribute them, the changed files must stay MPL-2.0 and be available as source; your own files are not affected.
Related skills for infrastructure as code
- Terraform skill: terraform-skill is Anton Babenko's agent skill for writing, testing and reviewing Terraform and OpenTofu, which names the risk before it writes code and never recommends a production apply without a reviewed plan.
- Refactor module: refactor-module is HashiCorp's agent skill for turning a monolithic Terraform configuration into reusable modules, with typed interfaces, documentation, tests and a state migration that recreates no resources.
- Terraform policy: terraform-policy is HashiCorp's agent skill for writing Terraform Policy files (.policy.hcl), testing them with .policytest.hcl, and converting Sentinel policies to the new format.
- Terraform test: terraform-test is HashiCorp's agent skill for writing and running Terraform's built-in tests: .tftest.hcl files with run blocks, assertions, expected failures, mock providers and CI pipelines.