---
title: "Terraform Policy Authoring and Tests: review, setup & limitations · Undominated.ai"
canonical: https://undominated.ai/skills/hashicorp-terraform-policy/
description: "Author or migrate policy HCL with version-specific mock schemas and targeted pass/fail policy tests."
---

# Terraform Policy Authoring and Tests: review, setup & limitations · Undominated.ai

> Author or migrate policy HCL with version-specific mock schemas and targeted pass/fail policy tests.

[← Explore all skills](/skills/)

INFRASTRUCTURE / hashicorp

# Terraform Policy Authoring and Tests

Author or migrate policy HCL with version-specific mock schemas and targeted pass/fail policy tests.

 [See setup guidance ↓](#setup)[Original source ↗](https://github.com/hashicorp/agent-skills/tree/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy)

SOURCE REVIEW

 Reviewed 2026-10-15
 Evidence 5 linked sources
 Publisher hashicorp
 Licence [MPL-2.0 ↗](https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/LICENSE)
 Revision f706481af9b8
 [Read what was—and wasn’t—checked ↓](#review)

“Write, test, or convert Terraform Policy files (.policy.hcl, .policytest.hcl, Sentinel→tfpolicy). Triggers: policy.hcl, policytest, convert sentinel, tfpolicy, write a policy.”

 [hashicorp · upstream description ↗](https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy/SKILL.md) Our analysis follows below.

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.

### A good fit for

 - Writing or converting a .policy.hcl file once the tfpolicy CLI version is known
- Debugging a .policytest.hcl mock that 0.3.x will skip when attrs are empty
- Convert a Sentinel rule into a focused Terraform Policy with representative failures.
- Debug a mock test that passes because another policy or resource scenario supplied the wrong context.
- Trace a mock-schema failure back to the target policy’s provider requirements.

### Weigh up before choosing

 - The skill does not write .tftest.hcl or general Terraform configuration.
- On 0.2.x, tfpolicy test does not preflight mocked attrs against provider schemas.
- If the CLI version is unknown, the file says to ask rather than pick a path silently.
- This review did not execute the resource.
- The pinned guidance separates tfpolicy 0.2 and 0.3 behavior; verify the installed CLI before using examples.
- Mock evaluation has documented differences from real plans; policy tests alone do not establish production enforcement.

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.

[Upstream setup instructions ↗](https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/README.md)

DOCUMENTED COMMAND

 npx skills add hashicorp/agent-skills/plugins/terraform/skills/terraform-policy Copy command ↗

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 Copy reviewed-revision command ↗ - 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

### Compatibility

Agents supporting directory-based SKILL.md instructions

### Local instructions; runtime access depends on the workflow

 - Writes policy/test files; enforcing a policy in HCP Terraform can block real deployments and requires separate configured access.

### Cost model

The skill is free; service usage and infrastructure can incur charges.

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 ↗](https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy/SKILL.md) Checked 2026-10-14 https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy/SKILL.md Supports: summary, whySelected, bestFor, limitations, install, access, review
- [Publisher repository and installation guidance ↗](https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/README.md) Checked 2026-10-14 https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/README.md Supports: install
- [MPL-2.0 licence ↗](https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/LICENSE) Checked 2026-10-14 https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/LICENSE Supports: license
- [plugins/terraform/skills/terraform-policy/references/tfpolicy-test.md ↗](https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy/references/tfpolicy-test.md) Checked 2026-10-14 https://github.com/hashicorp/agent-skills/blob/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy/references/tfpolicy-test.md Supports: review, limitations, access, install
- [Pinned continuation review C2-W46 ↗](https://raw.githubusercontent.com/hashicorp/agent-skills/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy/SKILL.md) Checked 2026-10-15 https://raw.githubusercontent.com/hashicorp/agent-skills/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy/SKILL.md Supports: review.findings, bestFor

KEEP COMPARING

## Other approaches to consider.

Related by category or shared topics. These are alternatives to inspect, not a measured quality order.

 [### Azure Verified Module Review ↗ Review Terraform module structure against the pinned AVM requirements guide.](/skills/hashicorp-azure-verified-modules/)[### Packer Azure Image Builder ↗ Prepare Azure managed or Compute Gallery images with Packer.](/skills/hashicorp-azure-image-builder/)[### Terraform Provider Documentation ↗ Generate Registry documentation from implemented schema descriptions, focused templates and reusable HCL examples.](/skills/hashicorp-provider-docs/)

 [AI Tools ↗](/tools/)[Skills ↗](/skills/)[Agents ↗](/agents/)[MCP Servers ↗](/mcp-servers/)[Workflows ↗](/workflows/)

## Continue your investigation

 - [Choose a toolkit](/tools/)
- [Inspect execution hosts](/agents/)
- [Check tool access](/mcp-servers/)
- [Check project dependencies](/check-repo/)
