# Terraform Style Guide (terraform-style-guide)

> Generates and maintains Terraform HCL code following HashiCorp's official style conventions and best practices.

- Category: [Code Standards](https://www.myskills.tools/en/categories/code-standards/)
- Source: Official · HashiCorp
- Repository: https://github.com/hashicorp/agent-skills/tree/main/plugins/terraform/skills/terraform-style-guide (commit 4451cec)
- SKILL.md: https://github.com/hashicorp/agent-skills/blob/main/plugins/terraform/skills/terraform-style-guide/SKILL.md
- Install command: `npx skills add hashicorp/agent-skills --skill terraform-style-guide`
- License: MPL-2.0
- Compatible with: Claude Code, Codex
- Permissions: read-repo ✓, write-files ✓, shell ✓, network ✗
- Status: Scan passed
- A rule scan cannot catch every risk. Read this skill's SKILL.md and check its permissions before installing.

## Core rule

Every variable must include a type and description, and every output a description.

## Execution Phases

1. **Generate in order** — Start with providers and version constraints, then data sources, resources in dependency order and outputs, using variables for every configurable value.
2. **Organise files** — Split into terraform.tf, providers.tf, main.tf, variables.tf, outputs.tf and locals.tf, with variables and outputs alphabetical.
3. **Format and name** — Indent two spaces and align equals signs, meta-arguments first and lifecycle last; use singular lowercase_underscore names and prefer for_each over count.
4. **Secure and pin** — Pin versions explicitly, mark sensitive values, never hardcode credentials, apply SECURITY.md hardening; never commit state, always commit .terraform.lock.hcl.
5. **Validate** — Before committing, run terraform fmt -recursive and terraform validate, optionally tflint, checkov or tfsec, and walk the review checklist.

## Permissions (summarised from SKILL.md)

| Capability | Needed | Details |
|---|---|---|
| File writes | Required | Generates and edits Terraform configuration files (.tf). |
| Command execution | Limited | Only terraform fmt, terraform validate and checkers such as tflint, checkov and tfsec. |
| Network outbound | Not required | The skill calls for no network access and does not run plan or apply. |

## SKILL.md frontmatter (YAML)

```yaml
---
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.
metadata:
  lifecycle-status: active
---
```

Home: https://www.myskills.tools/en/ · URL: https://www.myskills.tools/en/skills/terraform-style-guide/
