INFRASTRUCTURE / hashicorp
Terraform Policy Authoring and Tests
Author or migrate policy HCL with version-specific mock schemas and targeted pass/fail policy tests.
“Write, test, or convert Terraform Policy files (.policy.hcl, .policytest.hcl, Sentinel→tfpolicy). Triggers: policy.hcl, policytest, convert sentinel, tfpolicy, write a policy.”
01 / THE REASONING
Why this made the selection.
- It routes Terraform Policy authoring and tests by the installed tfpolicy minor line, 0.2.x or 0.3.x.
- It refuses module tftest files and general HCL, and it does not invent guidance when the CLI version is unknown.
- Keeps authoring and test references together and distinguishes policytest from Terraform module tests.
- Documents missing-versus-null attributes, per-file resource graphs and misleading expected-failure cases.
02 / THE REVIEW RECORD
What we actually inspected.
Source review has boundaries.
A clear record is more useful than a “safe” badge.
Material inspected
- plugins/terraform/skills/terraform-policy/SKILL.md
- plugins/terraform/skills/terraform-policy/references/tfpolicy-test.md
- README.md
- LICENSE
Our findings
- Authoring and testing instructions depend on whether tfpolicy is 0.2.x or 0.3.x.
- A 0.2.x policy file that contains resource or provider policies must include a required_providers block for tfpolicy validate.
- The do-not-use section sends .tftest.hcl work to terraform-test and general HCL to terraform-style-guide.
- The skill does not contain the policy language itself; it routes to tfpolicy-author and tfpolicy-test.
- Test reference explains required_providers belongs in the policy file and newer preflight checks include skipped mocks.
- It distinguishes absent keys from explicit null and warns getresources sees all resources in one test file.
- The newer CLI path reuses the target policy’s required_providers block for mock schema validation and rejects a schema mismatch before running tests.
Not established by this review
- The resource was not executed and its tools were not called.
- No skill execution, authenticated service operation, or outcome benchmark was performed.
- Not executed: it was not installed or run.
The review applies to the material and revision named here. A newer upstream release can change its behavior.
03 / PUT IT TO WORK
Add a skill to your workflow.
DOCUMENTED COMMAND
npx skills add hashicorp/agent-skills/plugins/terraform/skills/terraform-policy Run in your terminal to choose your AI tools, project or global scope, and installation method. This short command follows the current upstream version; the review covers the revision shown above.
Optional: install the reviewed revision
Keeps the original source and installer version where recorded, while leaving your AI tools and installation scope for you to choose.
npx skills add https://github.com/hashicorp/agent-skills/tree/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy - Install the pinned skill directory interactively, retaining its bundled references and scripts.
- Check tfpolicy version and retain both authoring/testing references.
- Target the intended policy explicitly and isolate conflicting cross-resource scenarios into separate test files.
Before you start
- tfpolicy CLI and target provider schemas
- Existing rule requirements or Sentinel policy and test fixtures
04 / FOLLOW THE EVIDENCE
The source trail.
Our notes are separate from the original resource.
Check upstream before adopting a new version.
- Pinned skill definition ↗Checked
https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy/SKILL.md
Supports: summary, whySelected, bestFor, limitations, install, access, review
https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/README.md
Supports: install
- MPL-2.0 licence ↗Checked
https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/LICENSE
Supports: license
https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy/references/tfpolicy-test.md
Supports: review, limitations, access, install
https://raw.githubusercontent.com/hashicorp/agent-skills/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy/SKILL.md
Supports: review.findings, bestFor