terraform-style-guide
Terraform Style Guide
Scope Boundaries
- Use this skill when the task matches the trigger condition described in
description. - Do not use this skill when the primary task falls outside this skill's domain.
Apply this checklist when writing or reviewing Terraform code.
Trigger Reference
- Use
references/trigger-matrix.mdas the canonical trigger and co-activation matrix. - Resolve skill activation from changed files with
python3 scripts/resolve_style_guides.py <changed-path>...when automation is available. - Validate trigger matrix consistency with
python3 scripts/validate_trigger_matrix_sync.py.
Architecture and module design
Quality Gate Reference
- Use
references/quality-gate-command-matrix.mdfor CI check-only vs local autofix command mapping.
- Keep modules small, focused, and reusable by responsibility.
- Separate environment composition from reusable module internals.
- Expose clear module interfaces with typed inputs and minimal outputs.
- Keep dependency direction explicit; avoid hidden cross-module coupling.
Naming and code structure
- Use consistent
snake_casenames for variables, locals, resources, and outputs. - Keep resource blocks readable with logical grouping.
- Use
localsfor repeated expressions and derived values. - Replace unexplained literals with named locals/constants and include units (
rotation_days).
Variables and configuration safety
- Define variable types explicitly and add validation rules.
- Mark sensitive values with
sensitive = true. - Require critical inputs explicitly and fail plan/apply when missing.
- Do not hardcode fallback defaults for required environment-derived values.
State and lifecycle discipline
- Use remote state with locking for collaborative environments.
- Keep state boundaries intentional to reduce blast radius.
- Review lifecycle rules (
create_before_destroy,prevent_destroy) explicitly. - Avoid unmanaged drift; reconcile differences intentionally.
Security and compliance
- Enforce least-privilege IAM and narrow resource policies.
- Enable encryption at rest and in transit where supported.
- Avoid exposing secrets in plain text outputs or logs.
- Run policy/security scanners before merge.
Performance and scalability
- Avoid unnecessary resource churn by stabilizing identifiers and
for_eachkeys. - Keep plans deterministic and readable in large stacks.
- Split very large stacks to keep plan/apply time bounded.
- Minimize provider/API call volume where possible.
Testing and verification
- Run validation and lint checks on every change.
- Review
terraform planoutput carefully for destructive actions. - Add environment-specific integration checks for critical modules.
- Document manual rollback/remediation steps for risky infra changes.
Observability and operations
- Emit infrastructure changes through auditable pipelines.
- Track drift, failed applies, and policy violations.
- Ensure runbooks exist for failed deployment recovery.
- Keep change approvals explicit for high-impact resources.
CI required quality gates (check-only)
- Run
terraform fmt -check -recursive. - Run
terraform validate. - Run
tflint(or project linter equivalent). - Run
tfsec/checkov(or project policy scanner equivalent).
Optional autofix commands (local)
- Run
terraform fmt -recursiveto apply formatting.
More from kentoshimizu/sw-agent-skills
graph-algorithms
Graph algorithm workflow for modeling entities/relations and selecting traversal, path, ordering, or flow strategies. Use when correctness or performance depends on graph representation and algorithm choice; do not use for schema-only modeling or deployment topology planning.
14bash-style-guide
Style, review, and refactoring standards for Bash shell scripting. Trigger when `.sh` files, files with `#!/usr/bin/env bash` or `#!/bin/bash`, or CI workflow blocks with `shell: bash` are created, modified, or reviewed and Bash-specific quality controls (quoting safety, error handling, portability, readability) must be enforced. Do not use for generic POSIX `sh`, PowerShell, or language-specific application style rules. In multi-language pull requests, run together with other applicable `*-style-guide` skills.
11architecture-clean-architecture
Clean Architecture workflow for enforcing dependency direction, stable domain boundaries, and use-case-centered application design. Use when teams must separate business rules from frameworks and delivery mechanisms; do not use for isolated module cleanup without boundary implications.
11powershell-style-guide
Style, review, and refactoring standards for PowerShell scripting. Trigger when `.ps1`, `.psm1`, `.psd1` files, or CI workflow blocks with `shell: pwsh` or `shell: powershell` are created, modified, or reviewed and PowerShell-specific quality controls (error handling, parameter validation, readability, operational safety) must be enforced. Do not use for Bash, generic POSIX `sh`, or language-specific application style rules. In multi-language pull requests, run together with other applicable `*-style-guide` skills.
10github-codeowners-management
Govern CODEOWNERS rules so review routing reflects real ownership and risk boundaries on GitHub. Use when repository ownership mapping or mandatory reviewer rules must be defined, updated, or audited; do not use for non-GitHub runtime architecture or data-layer design.
9security-authentication
Security workflow for authentication architecture, credential lifecycle, and session/token assurance. Use when login, identity proofing, MFA, or session security decisions are required; do not use for authorization policy design or non-security quality tuning.
9