terraform-style-guide: Claude Code Skill & Agent Tool
An open-source skill by hashicorp (opens in a new tab), published in the hashicorp/agent-skills (opens in a new tab) repository on GitHub. HashiCorp's official skill for writing and reviewing Terraform HCL that follows their style conventions, file organization and best practices.
Install terraform-style-guide
Requires Node.jsnpx skills add hashicorp/agent-skills --skill terraform-style-guideRun this command in your project terminal to install this skill for Claude Code.
What this skill does
terraform-style-guide is HashiCorp's official skill for generating and reviewing Terraform configuration that follows the company's published style conventions. When you ask your agent to write, review or generate Terraform, it applies a consistent strategy instead of improvising.
Files follow a standard organization — terraform.tf for versions, then variables.tf, locals.tf, main.tf and outputs.tf — and code is formatted the way terraform fmt expects, with aligned arguments and blocks in a predictable order. Resource names are descriptive nouns with underscores, every variable has a type and a description, and every output is documented. For multiple resources the agent prefers for_each over count, keeping count for conditional creation, so instances keep stable names.
Security and stability get their own rules: version constraints are pinned explicitly for Terraform and its providers, sensitive values are marked as sensitive, credentials are never hard-coded, and aliased providers handle multi-region deployments. The skill ends with validation tools and a code review checklist — formatted, validated, organized, typed, documented, pinned and free of secrets — that the agent can run through before you merge. Use it with Claude Code to keep infrastructure as code readable and consistent across a team.
Key Capabilities
- Standard file layout: terraform.tf, variables.tf, locals.tf, main.tf and outputs.tf
- Formatting, block order and naming conventions from HashiCorp's style guide
- Typed, documented variables and outputs, with for_each preferred over count
- Pinned versions, sensitive values marked and no hard-coded credentials
- Code review checklist with terraform fmt and terraform validate
How to use with Claude Code & AI Agents
Install the skill
Run the command above at the root of your project. The CLI asks which agents to set up — Claude Code, Cursor and other supported agents — and adds terraform-style-guide to the project, so teammates who pull the repository get it too. Add-gto install it for your user account across every project.Open a new agent session
Start a fresh Claude Code session in that project so the agent loads the new skill. Have ready: Terraform CLI (for fmt and validate).Ask in plain words
Describe the task, for example:“Write a Terraform module for an S3 bucket following HashiCorp's style guide.”The agent matches your request to the skill's description and follows its SKILL.md instructions step by step. Read them on GitHub before using the skill on a system that matters.