Skip to content
Back to skills

Terraform Standards

ASecurity

Personal Terraform defaults for writing, reviewing, or refactoring Terraform code. Use when working on `.tf` or `.tfvars` files, root or child modules, data sources, locals, import or moved blocks, environment variable files, module variables and outputs, or `tfe` provider resources. The project's own conventions take precedence over these defaults.

  • 9 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 17, 2026
code-qualityterraformrefactoringgitbackend

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 17, 2026

npx -y skills add leefowlercu/agent-kit --skill terraform-standards --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Terraform Standards?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Terraform Standards
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leefowlercu-terraform-standards/badge)](https://www.skillsdirectory.com/skills/leefowlercu-terraform-standards)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: terraform-standards
description: Personal Terraform defaults for writing, reviewing, or refactoring Terraform code. Use when working on `.tf` or `.tfvars` files, root or child modules, data sources, locals, import or moved blocks, environment variable files, module variables and outputs, or `tfe` provider resources. The project's own conventions take precedence over these defaults.
---

# Terraform Standards

## Precedence

This skill holds the user's personal Terraform defaults. It fills gaps; it does not override the project.

When guidance conflicts, follow the first source that addresses it:

1. The user's instructions in the current conversation.
2. The project's written standards: the nearest `AGENTS.md` or `CLAUDE.md`, `CONTRIBUTING.md`, and style or architecture docs.
3. The project's enforced tooling: `.tflint.hcl`, pre-commit hooks, and the checks CI runs, such as `terraform fmt -check` or `terraform validate`.
4. The conventions in the surrounding code: file layout, naming, variable and output style, and module structure. If the repository is inconsistent, match the nearest code (the same module).
5. This skill.

- Do not restructure, rename, or move existing code to match this skill unless the user asks.
- Apply this skill's layout and style rules only where the project has no rule or pattern of its own.
- In reviews, judge code against the project's conventions, not this skill's.
- When following the project means departing from this skill in a way the user might not expect, say so in one line.

## Rule Levels

- MUST: mandatory requirement within this skill.
- SHOULD: strong recommendation unless there is a clear, documented reason not to.
- MAY: optional guidance that is acceptable when it fits local context.

These levels rank rules within this skill only. Every rule below, including MUST, yields to the sources listed under Precedence.

## Workflow

1. Before editing, check Precedence sources 2-4: instruction files, lint and CI configuration, and the existing files in the module you are changing.
2. Make the change, applying this skill wherever the project is silent.
3. Run `terraform fmt` on changed files.
4. Run `terraform validate` when the working directory is already initialized. Do not run `terraform init`, `plan`, or `apply` unless the user asks, because they can reach remote backends and providers.
5. Report the commands you ran and anything you could not verify.

## File & Folder Organization Standards

### Root Module Standards

- MUST keep these files in every root module:
  1. `main.tf` for Terraform resources and child modules.
  2. `variables.tf` for root module variables.
  3. `outputs.tf` for root module outputs.
  4. `terraform.tf` for the `terraform` block, including required Terraform version and required providers.
  5. `providers.tf` for provider definitions and configuration used by the root module.

### Data Sources, Locals Block, Import Block, and Moved Block Standards

- MUST place Terraform data sources in a separate `data.tf` file in the same directory as the referencing module.
- MUST place Terraform locals in a separate `locals.tf` file in the same directory as the referencing module.
- MUST place Terraform import blocks in a separate `imports.tf` file in the workspace root alongside root module files.
- SHOULD keep import blocks separate from main resource definitions so `terraform -generate-config-out` workflows remain practical.
- MUST place Terraform moved blocks in a separate `moved.tf` file in the workspace root alongside root module files.

### Environment Variables Files Standards

- MUST create environment-specific variable files as `environments/<environment>.tfvars` when asked for an environment file.
- SHOULD follow this pattern for common environments:
  - `environments/dev.tfvars`
  - `environments/staging.tfvars`
  - `environments/prod.tfvars`
- MUST use these files for non-sensitive values assigned to root module variables.

### Local Child Module Standards

- MUST define local child modules under a `modules/` subdirectory of the root module.
- MUST keep each child module in its own subdirectory under `modules/` (for example `modules/project`).
- MUST give each child module its own `main.tf`, `variables.tf`, and `outputs.tf` files.
- MUST place data sources or locals that are specific to a child module in that child module's `data.tf` or `locals.tf` file (for example `modules/project/data.tf` or `modules/project/locals.tf`).

## Code Generation Standards

### General Terraform Standards

- MUST make generated Terraform code conform to the Terraform Style Guide: https://developer.hashicorp.com/terraform/language/style
- MUST NOT exclude `.tfvars` files in `.gitignore`, because they are used to apply variables to modules.

### Child Module Standards

- MUST NOT include `description` attributes on child module variable or output definitions.
- MUST keep descriptions on root module variables and outputs instead.
- SHOULD rely on implicit context when naming child module outputs. For example, if a child module creates a `tfe_project` resource and exposes that resource ID, the output identifier should be `id` so callers can use context from references such as `module.projects["example"].id`.
- MUST surface child module outputs through the root module with explicit contextual identifiers. For example, if the root module creates a `projects` child module with `for_each` or `count`, a surfaced root output should use a contextual identifier such as `project_ids`.
- MUST stop and ask the user when the correct root output name is ambiguous.

### Terraform Provider-Specific Standards

#### TFE Provider (https://registry.terraform.io/providers/hashicorp/tfe/latest/docs)

- MUST check the current `tfe` provider configuration before generating `tfe` resources.
- MUST NOT include an `organization` attribute in `tfe` resource definitions when the provider configuration already sets `organization`.

Files in this skill

  • SKILL.md5.8 KB
  • agents/openai.yaml295 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in code-quality →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.