agentleFS
fmindfmind/dot/skills/infra-as-code/SKILL.md

infra-as-code

Skill10 starsChanged 56 days agoMITView on GitHub

Manage OpenTofu/Terraform modules, providers, state, and plans.

  • Reads credentials

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Scaffold new repositories: follow the scaffold guide.

    line 23
  2. Very specific:

    Review the plan: read tofu show tmp/plan.tfplan and flag every replacement, destroy, IAM change, and cost-relevant resource before asking …

    line 31

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

Infrastructure as Code

Canonical infrastructure as code with OpenTofu (the open-source Terraform fork; the binary is tofu). A repository that needs a BSL-licensed feature or employer-mandated HashiCorp Terraform pins terraform in its own mise configuration and documents the deviation.

Defaults

  • Default to OpenTofu via mise: opentofu tool, tofu binary; verify provider, backend, state, and language-feature compatibility before a Terraform migration.
  • Use the template tasks and hooks: mise.toml exposes the canonical vocabulary per mise — check fans out to format, validate, lint (tflint), scan (trivy), and leaks; lefthook.yml wires the hooks per lefthook.
  • Generate docs with terraform-docs: terraform-docs injects the inputs/outputs table into README.md between <!-- BEGIN_TF_DOCS --> / <!-- END_TF_DOCS --> markers, configured by terraform-docs.yml; mise run build regenerates it without cloud access.
  • Authenticate without service-account keys: Application Default Credentials locally; Workload Identity Federation in CI per github-actions.
  • Scaffold new repositories: follow the scaffold guide.

Workflow

  1. Resolve the target: identify the root module, backend, workspace (tofu workspace show), cloud project, credentials, and the authorized change scope. A fresh clone runs mise run install first: validation, linting, and tests need tofu init providers and tflint --init rulesets.
  2. Edit minimally: change the smallest root module that owns the resource; keep one state per concern.
  3. Check before planning: run mise run check and mise run test; tests stay offline only while every provider is mocked (the starter's mock_provider), otherwise plan-mode tests can authenticate, refresh state, and read data sources. Native tests over tests/*.tftest.hcl use command = plan (main.tftest.hcl); encode "must never happen" rules (public buckets, missing labels) as check:scan trivy findings or plan-test assertions.
  4. Plan explicitly: mise run plan writes tmp/plan.tfplan for the selected backend, workspace, and cloud target; feed secrets per State and secrets below. A plan can access APIs, state, and data sources, so keep plan and apply out of automatic gates.
  5. Review the plan: read tofu show tmp/plan.tfplan and flag every replacement, destroy, IAM change, and cost-relevant resource before asking for apply authority.
  6. Apply the reviewed plan when authorized: tofu apply tmp/plan.tfplan against the same target, then delete the saved plan.
  7. Verify: re-read the changed resources and run the same target's plan with its secret inputs, e.g. sops exec-env secrets.enc.env 'tofu plan -input=false -detailed-exitcode'; exit 0 means no remaining drift, 2 means pending changes, 1 is an error.

State and secrets

  • State is secret: state can store sensitive resource attributes in plaintext — never in git, always in the versioned GCS bucket, ideally wrapped by OpenTofu's encryption block. Read state-encryption before enabling it or migrating existing state.
  • Keep secrets out of tfvars and plans: *.tfvars is gitignored; commit only *.example.tfvars. Feed secrets per sops-secrets as TF_VAR_<name> entries: sops exec-env secrets.enc.env 'tofu plan -out=tmp/plan.tfplan'. A saved plan stores ordinary variable values, sensitive ones included; declare secret inputs ephemeral = true, pass them only to write-only arguments (for example secret_data_wo with an incremented secret_data_wo_version), and supply them again at apply: sops exec-env secrets.enc.env 'tofu apply tmp/plan.tfplan'.

Gotchas

  • Apply-mode tests create resources: command = apply creates real (then destroyed) resources; reserve it for behavior a plan cannot prove, with approved project access and cost.
  • tflint rulesets are downloaded: tflint --init (in install:lint) fetches the plugins pinned in tflint.hcl; export GITHUB_TOKEN in CI to avoid API rate limits.
  • terraform-docs needs markers: inject mode only rewrites between the TF_DOCS markers; add them to README.md once at scaffold time.
  • Provider majors move fast: versions.tf pins the google provider to one major with ~>; bump majors deliberately with upgrade-tools and read the upgrade guide, because resources rename across majors.
  • One state per concern: several small root modules (one per GCS prefix) beat one monolithic state — smaller blast radius, faster plans.

Task guides

<!-- guides:start -->
  • scaffold: Create a new OpenTofu root module from the templates, validate it offline, lock providers, and promote its GCS backend.
  • state-encryption: Enable OpenTofu client-side state and plan encryption with GCP KMS, including plaintext state migration.
<!-- guides:end -->

Documentation

  • OpenTofu · tflint · trivy config · terraform-docs · State encryption
  • Releases: OpenTofu · what's new
  • Upstream: hashicorp/agent-skills per the vendor-skill policy; select only the Terraform or provider guidance the stack needs.
  • Companion skills: mise (task vocabulary), sops-secrets (encrypted variables), github-actions (CI), code-security (full-repo scans), Google catalog (product skills).

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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.