terraform-style-guide
Generate Terraform HCL code following HashiCorp's official style conventions and best practices.
Skill by hashicorpOfficial
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/hashicorp-terraform-style-guide
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: devops, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/terraform-style-guide
What's inside
- Skill name
terraform-style-guide- Description
- Generate Terraform HCL code following HashiCorp's official style conventions and best practices. Use when writing, reviewing, or generating Terraform configurations.
- License
- MPL-2.0
- Metadata
- lifecycle-status: active
- Instructions
- 311 lines in SKILL.md · view on GitHub
Files (2)
- SECURITY.md
- SKILL.md
SKILL.md (first lines)
# Terraform Style Guide
Generate and maintain Terraform code following HashiCorp's official style conventions and best practices.
**Reference:** [HashiCorp Terraform Style Guide](https://developer.hashicorp.com/terraform/language/style)
## 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
| 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
```hcl
# terraform.tf
terraform {
required_version = ">= 1.14"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.0"
}
}
}
# variables.tf
variable "environment" {
description = "Target deployment environment"
type = string
validation {
condition = contains(["dev", "staging", "prod"], var.environment)
error_message = "Environment must be dev, staging, or prod."
}
}
# locals.tf
locals {
common_tags = {
Environment = var.environment
ManagedBy = "Terraform"
}
}
# main.tf
resource "aws_vpc" "main" {
cidr_block = var.vpc_cidr
enable_dns_hostnames = true
tags = merge(local.common_tags, {
Name = "${var.project_name}-${var.environment}-vpc"
})
}
# outputs.tf
output "vpc_id" {
description = "ID of the created VPC"
value = aws_vpc.main.id
}
```
## Code Formatting
### Indentation and Alignment
- Use **two spaces** per nesting level (no tabs)
- Align equals signs for consecutive arguments
```hcl
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
subnet_id = "subnet-12345678"
tags = {
Name = "web-server"
Environment = "production"
}
}
```
### Block Organization
Arguments precede blocks, with meta-arguments first:
```hcl
resource "aws_instance" "example" {
# Meta-arguments
count = 3
# Arguments
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
# Blocks
root_block_device {
volume_size = 20
}
# Lifecycle last
lifecycle {
create_before_destroy = trueFrom hashicorp/agent-skills, MPL-2.0.
More from hashicorp/agent-skills
- 0.820score
terraform-policy
hashicorpOfficial
Write, test, or convert Terraform Policy files (.policy.hcl, .policytest.hcl, Sentinel→tfpolicy).
SkillAFreshness: A★ 907Claude Code +9 - 0.777score
terraform-test
hashicorpOfficial
Comprehensive guide for writing and running Terraform tests.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-framework-migration
hashicorpOfficial
Migrate Terraform provider resources and data sources from Plugin SDKv2 to the Plugin Framework: muxing both plugins in one provider (terraform-plugin-mux…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-stacks
hashicorpOfficial
Comprehensive guide for working with HashiCorp Terraform Stacks.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-search-import
hashicorpOfficial
Discover existing cloud resources using Terraform Search queries and bulk import them into Terraform management.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-test-patterns
hashicorpOfficial
Terraform provider acceptance test patterns using terraform-plugin-testing with the Plugin Framework.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-docs
hashicorpOfficial
Create, update, and review Terraform provider documentation for Terraform Registry using HashiCorp-recommended patterns, tfplugindocs templates, and schema…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-configuration
hashicorpOfficial
Implement Terraform provider configuration and authentication with the Plugin Framework: provider schema for credentials (Optional + Sensitive attributes)…
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
push-to-registry
hashicorpOfficial
Push Packer build metadata to HCP Packer registry for tracking and managing image lifecycle.
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
aws-ami-builder
hashicorpOfficial
Build Amazon Machine Images (AMIs) with Packer using the amazon-ebs builder.
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
windows-builder
hashicorpOfficial
Build Windows images with Packer using WinRM communicator and PowerShell provisioners.
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
new-terraform-provider
hashicorpOfficial
Use this when scaffolding a new Terraform provider with the Plugin Framework: workspace layout, go module setup, provider server main.go, and a provider.go…
SkillBFreshness: B★ 907Claude Code +9
Signals
- Stars
- 907
- Forks
- 134
- Open issues
- 12
- Last commit (this folder)
- Aug 10, 2026 (2 months ago)
- Last release
- Aug 4, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MPL-2.0
- Repository
- github.com/hashicorp/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from hashicorp
- 0.821score
Terraform
hashicorpOfficial
Generate more accurate Terraform and automate workflows for HCP Terraform and Terraform Enterprise
ConnectorAFreshness: ALocal★ 1.6KClaude Code +5 - 0.820score
terraform-policy
hashicorpOfficial
Write, test, or convert Terraform Policy files (.policy.hcl, .policytest.hcl, Sentinel→tfpolicy).
SkillAFreshness: A★ 907Claude Code +9 - 0.777score
terraform-stacks
hashicorpOfficial
Comprehensive guide for working with HashiCorp Terraform Stacks.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-docs
hashicorpOfficial
Create, update, and review Terraform provider documentation for Terraform Registry using HashiCorp-recommended patterns, tfplugindocs templates, and schema…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-search-import
hashicorpOfficial
Discover existing cloud resources using Terraform Search queries and bulk import them into Terraform management.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-configuration
hashicorpOfficial
Implement Terraform provider configuration and authentication with the Plugin Framework: provider schema for credentials (Optional + Sensitive attributes)…
SkillBFreshness: B★ 907Claude Code +9
Cite this page
terraform-style-guide skill. Agent Mart. https://agentmart.dev/skills/hashicorp-terraform-style-guide (last updated 2026-10-24)