Cursor plugin for Terraform 1.9+ and OpenTofu 1.8+. Teaches the AI to write production-grade HCL: for_each over count, remote backend with state locking, version pinning, moved / removed / import blocks for safe refactoring, ephemeral resources for secrets, check blocks for runtime invariants, OpenTofu state encryption, OIDC federation for CI auth. Catches 20 regressions LLMs trained on older HCL still produce.
LLMs trained on HCL from 2020-2023 produce code that ships drift-prone, insecure, or destroy-on-rename infrastructure. They write:
0.0.0.0/0ingress on SSH / RDP / database ports (single most common shipped vulnerability)count = length(var.things)for stable collections (removing an item renumbers + destroys the rest)backend "local" { }or no backend block in shared modules (no state locking, no team workflow)- No
required_version, norequired_providersversion pin (next provider release silently breaks the plan) lifecycle { ignore_changes = all }to silence drift instead of fixing itnull_resource+local-execwhere a real provider resource exists- Rename a resource without a
movedblock (destroys + recreates) terraform importCLI usage in scripts/docs instead ofimport {}blocksterraform.workspaceinterpolated into resource names (workspaces used as environments)- Secrets in
variabledefaults,*.tfvarsfiles, or HCL literals - Static AWS access keys declared in provider blocks
actions = ["*"]/resources = ["*"]in IAM policy documents- Unmarked sensitive outputs (passwords appear in plan logs)
publicly_accessible = trueon RDS, missing encryption on EBS/RDShttp_tokens = "optional"on EC2 metadata (IMDSv1 enabled)- Module
source = "git::..."without?ref=v...pin (upstream breaks consumers) - Variables without
type,description, orvalidation terraform_remote_statefor everything instead of provider data sourcesdynamicblocks iterating over a single literal element- Missing
terraform fmt/validate/tflint/ policy scan in CI
git clone https://github.com/RoninForge/roninforge-terraform.git ~/.cursor/plugins/local/roninforge-terraformOr copy into your project:
git clone https://github.com/RoninForge/roninforge-terraform.git
cp -r roninforge-terraform/rules/* your-project/.cursor/rules/
cp -r roninforge-terraform/skills/* your-project/.cursor/skills/
cp -r roninforge-terraform/agents/* your-project/.cursor/agents/| Rule | Scope | What it does |
|---|---|---|
terraform-core |
Always active | Version pinning, remote backend + locking, for_each over count, moved/removed/import blocks, typed + validated variables, ephemeral secrets (1.10+), OIDC federation, repo layout, OpenTofu deltas |
terraform-anti-patterns |
Always active | 20 regressions: 0.0.0.0/0 on management ports, count misuse, local backend, unpinned providers, ignore_changes=all, null_resource overuse, terraform_remote_state for everything, workspace-as-env, plaintext secrets, static AWS keys, wildcard IAM, IMDSv1, public DBs |
terraform-modules |
**/*.tf |
Module design: structure, inputs surface, output curation, semver discipline, examples directory, *.tftest.hcl |
terraform-aws-security |
**/*.tf |
AWS-specific: S3 public-access blocks + encryption + versioning, IAM least-privilege, RDS hardening, IMDSv2, security groups by reference, VPC flow logs, GuardDuty, Security Hub, KMS rotation, tagging |
terraform-testing |
Agent-requested | *.tftest.hcl framework, expect_failures, mocked providers (OpenTofu 1.8+), apply tests, terratest, OPA policy tests |
| Skill | Command | What it does |
|---|---|---|
| New module | /terraform-new-module |
Scaffold a reusable module: versions.tf + variables.tf + main.tf + outputs.tf + examples + tests + README |
| Refactor with moved | /terraform-refactor-with-moved |
Safely rename or restructure resources without destroy+create; covers cross-module moves and count->for_each migrations |
| Validate | /terraform-validate |
Scan codebase for the 20 tracked anti-patterns, report by severity |
| Migrate secrets | /terraform-migrate-secrets |
Move plaintext HCL secrets to Secrets Manager + ephemeral resources, rotate exposed credentials, mark sensitive outputs |
| Agent | What it does |
|---|---|
terraform-reviewer |
Reviews HCL by severity: critical (security risk, data loss), warnings (regressions), suggestions (style + future-proofing) |
Existing Terraform .cursorrules cover formatting and naming. None of them:
- Catch
0.0.0.0/0on management ports (single most common shipped vulnerability) - Force
for_eachovercountwith the destroy-on-renumber explanation - Teach
moved(1.1+) /import(1.5+) /removed(1.7+, OpenTofu 1.6+) blocks for safe refactoring - Cover ephemeral resources (Terraform 1.10+) for secret handling
- Differentiate Terraform vs OpenTofu (BSL vs MPL licensing, state encryption, mock providers)
- Bundle a secrets-migration skill for projects that have already leaked
tests/fixtures/anti-pattern-sample/ is a deliberate trash fire: hardcoded region, count, 0.0.0.0/0 SSH, plaintext password in terraform.tfvars, null_resource + local-exec, public RDS, IMDSv1, ignore_changes = all, workspace-as-environment.
tests/fixtures/correct-sample/ is the same shape rewritten with pinned versions, remote backend, for_each, validated admin CIDRs, ephemeral secrets, IMDSv2, encrypted private RDS, deletion-protected, curated outputs.
MIT - see LICENSE