agentleFS
abdullahkhawerabdullahkhawer/devops-skills/skills/terraform-linting/SKILL.md

terraform-linting

Skill8 starsChanged 6 months agoApache-2.0View on GitHub

Lint and format Terraform code using tflint and terraform fmt/validate according to standard conventions. Use when asked to lint, format, or check style issues in Terraform files.

  • Installs packages

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run this skill when asked to lint, format, or check style for Terraform code.

    line 8
  2. Very specific:

    If tflint is not installed, inform the user and ask before installing:

    line 17
  3. Very specific:

    Only run auto-fix commands after showing the user what will change and getting explicit confirmation.

    line 66
  4. Very specific:

    All variables have a description and, where sensible, a type constraint.

    line 74
  5. Distinctive:

    No hardcoded credentials, account IDs, or ARNs — use variables or data sources.

    line 75
  6. Very specific:

    NEVER install tflint without asking the user first.

    line 80
  7. Very specific:

    NEVER run terraform init against a real backend without asking the user first — offer to run validate only if the working directory is …

    line 81
  8. Distinctive:

    Always run in check/diff mode first — only apply auto-fixes after the user confirms.

    line 82

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Terraform Linting Skill

Run this skill when asked to lint, format, or check style for Terraform code.

Step 1 — Detect available tooling

which terraform tflint 2>/dev/null
ls .tflint.hcl 2>/dev/null

If tflint is not installed, inform the user and ask before installing:

brew install tflint

terraform fmt and terraform validate ship with the Terraform CLI, so no separate install is needed for those.


Step 2 — Run formatting check

terraform fmt -recursive -check -diff

Show the diff to the user before applying any formatting changes.


Step 3 — Run validation

terraform validate

Requires terraform init to have been run in the directory first — if it fails with a missing-provider error, inform the user rather than running init yourself if it would touch a real backend.


Step 4 — Run the linter

tflint --recursive

Respect the project's .tflint.hcl if present (enabled plugins/rules) — do not override it. If no .tflint.hcl exists, run with default rules and mention that a config file could be added.

Report all findings grouped by file, with line numbers and rule names (e.g. terraform_deprecated_index, aws_instance_invalid_type).


Step 5 — Apply fixes (only with user confirmation)

terraform fmt -recursive
tflint --fix --recursive

Only run auto-fix commands after showing the user what will change and getting explicit confirmation. Most tflint findings (e.g. deprecated syntax, unused variables, invalid instance types) require manual review even when a --fix is available.


Standard conventions enforced

  • Formatting is always terraform fmt-compliant (2-space indentation, aligned = signs).
  • Resource and variable names: snake_case, descriptive, no redundant type prefixes (e.g. aws_instance.web, not aws_instance.aws_instance_web).
  • All variables have a description and, where sensible, a type constraint.
  • No hardcoded credentials, account IDs, or ARNs — use variables or data sources.
  • Provider versions are pinned via required_providers in a versions.tf or the root module.

Rules

  • NEVER install tflint without asking the user first.
  • NEVER run terraform init against a real backend without asking the user first — offer to run validate only if the working directory is already initialized.
  • Always run in check/diff mode first — only apply auto-fixes after the user confirms.
  • Respect the project's existing .tflint.hcl — do not suggest a different ruleset without asking.
  • Report the exact command run and its full output — do not summarize away findings.
  • Flag any hardcoded secret-looking string (access keys, tokens, passwords) as a security finding regardless of whether tflint catches it.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.