terraform-review
Skill2 starsChanged 2 months agoApache-2.0View on GitHub
Use when a PR diff adds or modifies Terraform/OpenTofu (.tf / .tofu / .tftest.hcl), flags identity churn (missing `moved` blocks, `count` index churn), secrets that land in state, unsafe destroy/state ops, version-floor violations, and backend/state antipatterns in the CHANGED HCL only. Skip for non-IaC diffs.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- NotHarshhaa/devops-skillstheir own version, first seen Sep 19, 2026
- thixpin/claude-configtheir own version, first seen Aug 9, 2026
- shinzoxD/knackboxtheir own version, first seen Jul 10, 2026
- gmegidish/skillstheir own version, first seen Apr 14, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- gmegidish/skills★ 13same name
- NotHarshhaa/devops-skills★ 8same name
- thixpin/claude-config★ 8same name
- shinzoxD/knackbox★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository18 other files it gives its agents.
- accessibility-reviewSkill
- apex-reviewSkill
- appsec-compliance-reviewSkill
- clang-formatSkill
- commit-message-reviewSkill
- design-doc-conformanceSkill
- guideline-distillerSkill
- kernel-change-intentSkill
- kernel-driver-hardwareSkill
- kernel-execution-flowSkill
- kernel-locking-concurrencySkill
- kernel-resource-lifecycleSkill
- kernel-review-disciplineSkill
- kernel-security-auditSkill
- kernel-subsystem-guidesSkill
- linux-kernel-reviewSkill
- qodo-calibrate-rulesSkill
- toml-portal-migration-auditSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 4 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Findings apply to the diff, not the repo: Only flag HCL that was *added or modified* in this PR.
- Distinctive: line 32
Every finding must trace to a rule below: If you cannot point to a specific rule in this file that the changed HCL violates, drop it, the …
- Very specific: line 35
Determine the runtime floor from the diff when possible: Read required_version in versions.tf / terraform {} blocks if the PR touches them.
- Distinctive: line 42
When you emit a finding, set the fields the review pipeline expects:
- Very specific: line 113
Production apply that re-runs
planinside the apply job: instead of applying the reviewed plan artifact. - Very specific: line 128
DynamoDB lock table configured on Terraform ≥ 1.10: instead of use_lockfile = true on the S3 backend.
- Distinctive: line 142
Blocking: when the floor is demonstrably too low, otherwise Recommended.
- Very specific: line 173
Untyped
map(any)/anyfor a long-lived module input: instead of optional() with typed defaults (1.3+).
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Terraform Review Skill
Review lens for Terraform/OpenTofu changes in a pull request. Every rule below is a concrete violation you can point at in the diff, not a generation workflow.
This is the review-oriented adaptation of Anton Babenko's terraform-skill (a coding
skill). The diagnostic categories and the version-floor knowledge are his; the contract,
stance, and rule framing have been flipped from "produce correct HCL" to "flag incorrect
HCL in a diff."
How to apply this skill (read first)
You are reviewing a unified diff, not a live workspace. Therefore:
- You cannot run anything. No
terraform validate,plan,init,fmt, or terraform-ls. Do not emit a finding whose justification is "run X to confirm." Judge from the changed lines alone. - Findings apply to the diff, not the repo. Only flag HCL that was added or modified in this PR. Unchanged surrounding code is out of scope.
- Every finding must trace to a rule below. If you cannot point to a specific rule in this file that the changed HCL violates, drop it, the generic "issues" agent handles ordinary bugs. This skill only fires on the Terraform-specific rules enumerated here.
- Determine the runtime floor from the diff when possible. Read
required_versioninversions.tf/terraform {}blocks if the PR touches them; otherwise treat the floor as unknown and preferremediation_recommendedfor version-gated rules rather than asserting a hard violation.
Mapping a finding to the SkillsFinding contract
When you emit a finding, set the fields the review pipeline expects:
| This skill's severity | action_level | category (typical) |
| Blocking, clear, harmful, will break or leak | action_required | Security or Correctness |
| Recommended, likely wrong but context-dependent | remediation_recommended | Correctness / Maintainability |
| Optional, maintainability nudge | informational | Maintainability |
Each finding's evidence.citations MUST include a SkillCitation with
source = "terraform-review". Put the offending span in diff_pointer. Give a concrete
fix_suggestion (the Fix line of each rule is your starting point).
Rule set
Rules are grouped by failure category. Each rule = what to flag in the diff → severity → why → fix.
1. Identity churn (resource addresses)
- Refactor that renames a resource/module address with no
movedblock in the same diff. → Blocking (Correctness). Renaming an address withoutmovedturns the change into destroy + recreate. Fix: add amoved { from = ... to = ... }block in the same PR; a rename should plan as a move, not a replacement. for_eachkeys built from values not known until apply (e.g. keyed off a computed resource ID/ARN). → Blocking (Correctness). Planning fails, keys must be known at plan time. Fix: key off input variables or business-meaningful static values.countintroduced for a collection where elements may be reordered/removed, orcount.indexused as long-lived identity. → Recommended (Correctness). Removing a middle element reshuffles every later address. Fix: usefor_each = toset(...)/ a map with stable keys.movedblock left inside a module that is itself being removed in the same diff. → Blocking (Correctness). The moves silently no-op and the resources get destroyed. Fix: handle the migration before/separately from the module removal.movedblock whosefrom/tocrosses a provider boundary. → Recommended (Correctness).movedcannot cross providers. Fix: useimport/removedas appropriate.terraform state mvsuggested in scripts/docs where a declarativemovedblock would be reviewable. → Recommended (Maintainability). Fix: prefermovedblocks.
2. Secret exposure (the big one, state is not safe just because it's masked)
sensitive = trueadded to a variable/output and treated as keeping the value out of state. → Blocking (Security).sensitiveonly masks display; the value still lives in state. Fix: on 1.11+ usewrite_only/*_woarguments; otherwise source from a cloud secret manager at runtime. Keep secret material out of Terraform inputs entirely.nonsensitive()used to "unwrap" a sensitive value into plan output / an output. → Blocking (Security). This launders secrets into plan artifacts and CI logs. Fix: remove thenonsensitive(); do not surface the secret.- Plaintext secret as a
variabledefault, or committed in*.tfvars("for demo" counts). → Blocking (Security). Fix: remove; reference a secret manager / env var. - Outputs exposing full connection strings or credentials, even when marked
sensitive. → Blocking (Security). Fix: expose only non-secret identifiers. password_wo(or other*_wo) paired with a data source that still reads the secret into state on refresh (e.g.aws_secretsmanager_secret_version.secret_string). → Blocking (Security). The write-only arg helps the resource, but the data source re-reads it. Fix: use anephemeralresource (1.10+) or a CI-injected env var.- Secrets echoed through
provisioner/local-execstdout. → Blocking (Security). Leaks into CI logs. Fix: don't pass secrets through provisioner commands. - A compliance framework named (SOC 2 / PCI / HIPAA / GDPR / FedRAMP) with no enforceable gate added (no policy stage, approval, or evidence artifact). → Recommended (Security). Fix: add the actual control, not just the claim. Note data-residency for GDPR/FedRAMP. (Encrypted ≠ audit evidence.)
3. Destroy & state safety
-auto-approveon a destroy, or a targeteddestroyin scripts/CI with noplan -destroyshown first. → Blocking (Correctness). Locals referencing a targeted resource pull all itsfor_eachconsumers in as implicit dependents, destroy deletes more than expected. Fix: require a reviewedplan -destroyartifact + explicit approval; never-auto-approvea destroy.- Production apply that re-runs
planinside the apply job instead of applying the reviewed plan artifact. → Recommended (Correctness). Fix: apply the savedplan -outartifact from the plan stage. *.tfstate(or.tfstate.backup) added to the diff / not git-ignored. → Blocking (Security). Fix: remove from VCS, add to.gitignore, move to a remote backend.- Local state introduced/kept for a team/production config (no
backendblock, orbackend "local"). → Blocking (Security). Fix: use a remote backend (locking, encryption, versioning, audit). rm .terraform.tfstate.lock.info/force-unlockadded without cause. → Recommended (Correctness). Fix: investigate why the lock exists first; don't blanket force-unlock.- Manual edits to
terraform.tfstate. → Blocking (Correctness). Fix: useterraform state mv/rm/import(ormoved/importblocks). - Prod and non-prod sharing one backend key, or one monolithic root state. → Recommended (Security/Maintainability). Fix: separate backend keys per environment; split by component at true ownership boundaries.
- DynamoDB lock table configured on Terraform ≥ 1.10 instead of
use_lockfile = trueon the S3 backend. → Recommended (Maintainability). Fix: prefer native S3 lockfile on 1.10+. terraform_remote_stateused within a single team's own stack to read values that are available as module outputs. → Recommended (Maintainability). Fix: pass via module outputs; reserveterraform_remote_statefor true ownership boundaries.- Destructive state op with no rollback/recovery note in the PR. → Recommended (Maintainability). Fix: document how to undo and what evidence to keep.
4. Version-floor guards (the crown jewel)
A feature used below its runtime floor will break; the right-hand column is the classic
mistake. If the diff uses a feature but the PR's required_version floor is below the
minimum (or the floor is unknown and the feature is recent), flag it. Severity is
Blocking when the floor is demonstrably too low, otherwise Recommended.
| Feature | Min version | Anti-pattern to flag in the diff |
for_each over count for stable identities | 0.12+ | count used for a collection where identity matters → index churn |
try() | 0.12.20+ | element(concat(...)) legacy fallback instead of try() |
nonsensitive() | 0.15+ | used to unwrap a sensitive value into plan output (secret laundering) |
nullable = false | 1.1+ | omitted, letting null silently override a default |
moved blocks | 1.1+ | omitted during rename → destroy/create |
optional() with defaults | 1.3+ | wrapper variables / loose map(any) contracts instead |
declarative import blocks | 1.5+ | ad-hoc CLI terraform import in automation instead |
check blocks | 1.5+ | check used expecting it to gate apply, it is advisory (warnings only). Use precondition/postcondition to block. |
native terraform test | 1.6+ | mocked-provider tests treated as full integration coverage |
| mock providers | 1.7+ | asserting computed values in command = plan mode (needs apply) |
removed blocks | 1.7+ | deleting resources with no lifecycle transition |
| provider-defined functions | 1.8+ | overusing data sources for simple transforms |
| cross-variable validation | 1.9+ | checks pushed into postconditions only |
S3 native lock-file (use_lockfile) | 1.10+ | DynamoDB lock table recommended even on ≥1.10 |
ephemeral values | 1.10+ | treated as interchangeable with sensitive (only ephemeral stays out of state) |
write_only / *_wo arguments | 1.11+ | sensitive = true used while assuming state is safe |
Also flag: silently emitting 1.10+/1.11+ features (use_lockfile, write_only,
removed, ephemeral) with no corresponding required_version bump in the same diff.
Fix in all cases: either raise required_version to the feature's floor, or use the
pre-floor fallback explicitly.
5. Contracts, structure & maintainability (lower severity)
- Exact provider/runtime pin
version = "5.0.0"where~> 5.0is more maintainable (non-prod contexts). → Optional (Maintainability). (Exact pins are correct for prod module consumption, judge by context.) - Untyped
map(any)/anyfor a long-lived module input instead ofoptional()with typed defaults (1.3+). → Recommended (Maintainability). Fix: type the contract. - Variable block missing
descriptionor explicittype, output missingdescription. → Optional (Maintainability). Fix: add them. ignore_changes = all/ broad ignore lists added to silence plan noise. → Recommended (Correctness). Fix: diagnose the drift root cause instead of ignoring.each.valueinside adynamicblock intending the outer iterator (shadowed by the inner block name). → Recommended (Correctness). Fix: setiterator = ...and use it.dynamicblock iteratingtoset(...)of maps/objects → non-deterministic block ordering in plan diffs. → Recommended (Correctness). Fix: sort the list or key a map by a stable field.- Hardcoded cloud IDs/ARNs (
vpc-0abc..., literalarn:aws:iam::...) introduced in the diff. → Recommended (Correctness). Often hallucinated from training data. Fix: use a data source or input variable. - Security-group anti-patterns: ingress/egress open to
0.0.0.0/0, or inlineingress/egressblocks inaws_security_group(AWS provider v5+). → Recommended (Security). Fix: least-privilege rules; separateaws_vpc_security_group_{ingress,egress}_ruleresources. - Encryption/TLS skipped, default VPC used for new data stores/resources. → Recommended (Security). Fix: enforce encryption at rest + TLS; dedicated VPC.
What NOT to flag
- Generic bugs, logic errors, or non-Terraform issues, those belong to the issues agent.
- HCL style/formatting unless a rule above names it.
- Anything in files not changed by this PR.
- Anything requiring execution to confirm (you have no workspace).
- A feature-floor "violation" when the PR does not touch
required_versionand the feature is old enough to be universally available, don't speculate about an unknown floor for, say,try().
Depth references (optional, read on demand)
These are the source skill's depth docs, carried over for examples and rationale. Read one only when a rule above fires and you want the worked detail. They are written in a generation voice, translate to review as above.
references/code-patterns.md,count/for_eachdeep dive,movedpatterns, the full Feature Guard Table, version management, provisioners-as-last-resort.references/security-compliance.md, secrets handling,write_only/ephemeral, trivy/checkov, compliance mappings.references/state-management.md, backends, locking, safe-destroy protocol, migration, multi-team isolation, recovery.
License & attribution
Apache License 2.0. Derived from terraform-skill by Anton Babenko
(https://github.com/antonbabenko/terraform-skill, v1.17.1, © 2026 Anton Babenko),
adapted into a PR-review variant by the PR Agent Pro Team. The reference files under
references/ are reproduced from the source project under the same license.
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.

