skills/terraform-conventions/SKILL.md
Terraform code conventions: file organization, naming, variables, outputs, formatting, and the plan/apply workflow. Trigger: When writing Terraform files, reviewing HCL code style, organizing .tf files, or adding new Terraform modules.
npx skillsauth add 333-333-333/agents terraform-conventionsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
.tf filesEvery Terraform directory MUST have these files. No exceptions.
| File | Contains | Rule |
|------|----------|------|
| versions.tf | terraform {} block — required providers, version constraints | ONE per directory, never duplicated |
| provider.tf | Provider configuration blocks | ONE provider per block, sensitive config via variables |
| variables.tf | ALL variable blocks | Grouped by section with comment dividers |
| outputs.tf | ALL output blocks | Mirror the resource structure |
| main.tf | Resources and data sources | Split into domain files when > 300 lines |
When main.tf grows beyond ~300 lines, split by domain:
main.tf → roles.tf, channels.tf, permissions.tf
→ network.tf, compute.tf, storage.tf
→ iam.tf, databases.tf, pubsub.tf
See assets/file-layout-example.tf for the standard layout.
| Element | Convention | Good | Bad |
|---------|-----------|------|-----|
| Resources | snake_case, descriptive noun | discord_text_channel.dev_backend | discord_text_channel.ch1 |
| Variables | snake_case, clear purpose | server_name | name, sn |
| Outputs | snake_case, match resource | server_id | id, output1 |
| Locals | snake_case | default_tags | dt |
| Files | lowercase.tf | variables.tf | Variables.tf, vars.tf |
| Modules | kebab-case directory | modules/vpc-network/ | modules/VPCNetwork/ |
Every variable MUST have:
description — no exceptionstype — always explicit, never rely on inferencedefault — ONLY if there's a sensible universal defaultsensitive = true — for any secret (tokens, passwords, keys)validation blocks — for values with known constraintsSee assets/variables-example.tf for the full pattern.
Every output MUST have:
descriptionsensitive = true if it exposes secrets# ===) to separate logical sectionsSee assets/resource-organization.tf for the pattern.
1. Edit .tf files
2. terraform fmt -recursive # Auto-format all files
3. terraform validate # Check syntax and types
4. terraform plan # Review the diff — READ IT CAREFULLY
5. terraform apply # Apply with confirmation
NEVER skip plan. Always review the diff before applying. Look for unexpected destroys or replacements.
terraform fmt before every commit — non-negotiable= signs within a block for readabilityNew Terraform directory? → Create all 5 standard files (versions, provider, variables, main, outputs)
main.tf > 300 lines? → Split by domain into separate .tf files
Variable has a secret? → Add sensitive = true
Variable has known values? → Add validation block
Output exposes a secret? → Add sensitive = true
Multiple providers needed? → One provider block each in provider.tf, alias if same type
| File | Description |
|------|-------------|
| assets/file-layout-example.tf | Standard file layout for a new Terraform directory |
| assets/variables-example.tf | Variable patterns with types, defaults, validation, and sensitivity |
| assets/resource-organization.tf | Resource grouping and comment divider conventions |
terraform fmt -recursive # Format all .tf files
terraform validate # Check syntax
terraform plan # Preview changes
| Don't | Do |
|-------|-----|
| Dump everything in main.tf | Split by domain when > 300 lines |
| Variables without descriptions | ALWAYS add description |
| Hardcode values in resources | Use variables with defaults |
| Skip terraform plan | ALWAYS review the plan before apply |
| Use short cryptic names | Use descriptive snake_case names |
| Rely on type inference | Always set explicit type on variables |
| Commit without terraform fmt | Format before every commit |
testing
Review Flutter components and screens for UX/UI compliance. Trigger: When user invokes /ux-review command or requests UX audit.
development
TypeScript strict patterns and best practices. Trigger: When implementing or refactoring TypeScript in .ts/.tsx (types, interfaces, generics, const maps, type guards, removing any, tightening unknown).
testing
Testing philosophy and strategy for every feature: test pyramid, mandatory levels per change type, completion checklist, and skill delegation. Trigger: When planning tests for a feature, reviewing test coverage, defining acceptance criteria, or asking what tests a change needs.
development
Terraform security practices: sensitive variables, secret management, state protection, .gitignore patterns, and CI/CD credential handling. Trigger: When handling secrets in Terraform, configuring state backends, reviewing .gitignore for Terraform, or setting up CI/CD pipelines for infrastructure.