Terraform style guide
Applies HashiCorp's Terraform style conventions: standard file split, formatting, naming, typed variables, for_each over count, pinned versions and secrets kept out of state. Use when writing, reviewing or generating Terraform HCL.
terraform-style-guide- Author
- HashiCorp
- Source
- hashicorp/agent-skills/plugins/terraform/skills/terraform-style-guide @ 5e30fa5
- License
- MPL-2.0
About this skill
What it does
The skill turns HashiCorp's Terraform style guide into rules for writing and reviewing HCL. Code goes into a standard file split: terraform.tf, providers.tf, main.tf, variables.tf, outputs.tf, locals.tf. Formatting means two-space indents, aligned equals signs, meta-arguments first and lifecycle last. Names are lowercase with underscores, singular, without the resource type, and main for a lone resource. Every variable needs type and description, every output a description; for_each is preferred over count, which stays for on/off resources. State, .terraform/ and plan files stay out of git; .terraform.lock.hcl goes in.
SECURITY.md in the folder adds hardening defaults (encryption at rest, private networking, least-privilege security groups, logging) and an order for secrets: the resource's own secrets-manager option first, such as manage_master_user_password on RDS; then an ephemeral resource feeding a write-only _wo attribute, from Terraform 1.11; a plain resource that leaves the secret in state only as a last resort.
It ends with a review checklist and terraform fmt -recursive plus terraform validate before a commit; tflint, checkov and tfsec are optional extras. Examples use the AWS provider.
When to use it, and when not
Use it when the agent writes a new configuration or module, or to check existing .tf files against HashiCorp's conventions.
It is a checklist, not a scanner: it reads neither plan nor state. Stacks, tests and policy files have their own skills in this pack.
How to run it
We do not copy this skill: its files are under MPL-2.0, a file-level copyleft licence outside the set we copy under. Install it from HashiCorp's repository with the button to the source: one skill via npx skills add hashicorp/agent-skills/plugins/terraform/skills/terraform-style-guide, or the whole terraform plugin with 16 skills, in Claude Code claude plugin marketplace add hashicorp/agent-skills and claude plugin install terraform@hashicorp. In Codex: codex plugin marketplace add hashicorp/agent-skills, then install terraform from /plugins and start a new session. In Claude Code, the plugin's skill may appear with a prefix, as /terraform:terraform-style-guide.
- Claude Code:
/terraform-style-guide, or ask for the skill by name. - Codex:
$terraform-style-guide. - Cursor: type
/in the Agent chat and pickterraform-style-guide.
Example: /terraform-style-guide Write a module for an S3 bucket with versioning and KMS encryption, split into the standard files.
How it differs from similar skills
Outside this pack the catalog has no Terraform skill. Kubernetes manifest review is the nearest in kind: an infrastructure checklist, but for K8s YAML, with a findings table and server-side dry runs. Azure Verified Modules for Terraform is a stricter MUST/SHOULD rule set for Azure modules seeking AVM certification, and Refactor Terraform into modules relies on this skill for the style of the modules it creates.
Install
This skill is not copied to the catalog: its licence allows a copy only under the same licence, and the catalog does not copy under such licences. Install it from the author's repository.
Connect through AnyModel API
This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.
AnyModel