npx skills add ...
npx skills add hashicorp/terraform-agent-kit --skill terraform-style-guide
Generate Terraform HCL code following HashiCorp's official style conventions and best practices. Use when writing, reviewing, or generating Terraform configurations.
This repo is now called hashicorp/agent-skills. Both names install the same content, but the install count here only covers this one.
npx skills add hashicorp/terraform-agent-kit --skill terraform-style-guide
Generate and maintain Terraform code following HashiCorp's official style conventions and best practices.
Reference: HashiCorp Terraform Style Guide
When generating Terraform code:
| 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 |
Arguments precede blocks, with meta-arguments first:
main for resources where a specific descriptive name is redundant or unavailable, provided only one instance existsEvery variable must include type and description:
Every output must include description:
Refer to SECURITY.md. It includes guidance on encrypting resources, preventing sensitive data in state, and secure configurations.
Use the latest major version of each provider and the latest minor version of Terraform, unless otherwise constrained by a dependency lock file or by other modules used by the configuration.
Version constraint operators:
= 1.0.0 - Exact version>= 1.0.0 - Greater than or equal~> 1.0 - Allow rightmost component to increment>= 1.0, < 2.0 - Version rangeNever commit:
terraform.tfstate, terraform.tfstate.backup.terraform/ directory*.tfplan.tfvars files with sensitive dataAlways commit:
.tf configuration files.terraform.lock.hcl (dependency lock file)Run before committing:
Additional tools:
tflint - Linting and best practicescheckov / tfsec - Security scanningterraform fmtterraform validatesensitive = trueBased on: HashiCorp Terraform Style Guide