writing-terraform-code
Skill0 starsChanged 4 months agoMITView on GitHub
Writes and reviews Terraform HCL code following standard style conventions, checked against a real HCL parser rather than eyeballed - resource naming, variable/output interfaces, and state safety. Use whenever the user wants to write, review, or refactor Terraform infrastructure-as-code, or mentions .tf files, modules, or provisioning cloud resources with Terraform.
In this repository19 other files it gives its agents.
- adding-authenticationSkill
- auditing-seoSkill
- automating-git-workflowsSkill
- building-email-sequencesSkill
- building-graphql-apisSkill
- building-wordpress-pluginsSkill
- designing-carouselsSkill
- fine-tuning-ml-modelsSkill
- handling-web-formsSkill
- n8n-automationSkill
- organizing-spreadsheetsSkill
- reviewing-cloudflare-workers-codeSkill
- reviewing-code-for-securitySkill
- scaffolding-landing-pagesSkill
- setting-up-error-monitoringSkill
- setting-up-firebase-authSkill
- using-nextjs-best-practicesSkill
- working-with-postgres-databasesSkill
- writing-marketing-copySkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
Variables and outputs are the module's interface: every variable block needs a description and type.
- Very specific: line 16
Plan before apply, always: - never present apply as a one-step action.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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.
Files
Writing Terraform code
Writes Terraform that's readable, safely re-runnable, and structured for reuse - checked with a real HCL parser, not just visual review.
Workflow
- Resource naming: descriptive, consistent names (
aws_instance.web_server, notaws_instance.a) - this is what shows up in every plan/apply output and state file. - Variables and outputs are the module's interface: every
variableblock needs adescriptionandtype; everyoutputneeds adescription. See the tested validator below - this isn't optional polish, undocumented interfaces are what make a module unreusable by anyone but its author. - Never hardcode values that differ per environment - these belong in
.tfvarsor variables, not inline in resource blocks. - State safety: warn before suggesting anything that touches state directly (
terraform state mv/rm) - these need the user's explicit confirmation. - Plan before apply, always - never present
applyas a one-step action.
Tested: HCL structure validation
scripts/example-module/main.tf is a real Terraform module (AWS instances + security group + data source), parsed and structurally checked with python-hcl2 - not just written and assumed correct.
Confirmed parse output:
Variables found: [allowed_cidr_blocks, environment, instance_count]
Resources found: [aws_instance.web_server, aws_security_group.web_server_sg]
Outputs found: [web_server_ids, security_group_id]
No style issues - every variable has description+type, every output has description.Confirmed the check actually catches problems - ran the same validation against a deliberately incomplete file (variable and output with no description):
2 style issues found:
- variable 'region' missing description
- output 'instance_id' missing descriptionUse this check pattern (parse with python-hcl2 or terraform validate if the CLI is available, then walk variable/output blocks) before considering a module review complete - missing descriptions are easy to miss by eye across a large module and are exactly the kind of thing that makes a module frustrating for the next person.
Notes
- This environment doesn't have network access to install the Terraform CLI itself, so
terraform validate/terraform plancouldn't be run live here - the HCL parsing and structural checks above are real, but full provider-level validation (does this AWS resource configuration actually apply) needs the real CLI against real provider credentials. - For repeated resource patterns (e.g. the same config used across environments), suggest extracting a module rather than copy-pasting the block with minor edits.
count-based resources (likeaws_instance.web_serverabove) produce a list output (aws_instance.web_server[*].id) - remind the user this becomes a set-like structure that doesn't guarantee element order across applies if the count source changes;for_eachwith stable keys is safer when identity matters.
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
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.

