terraform-policy — Claude Code skill: install guide
Creates and tests Terraform Policy files, and converts Sentinel rules into Terraform Policy. Use it when policy files or their test cases need changes.
npx skills add hashicorp/agent-skills --skill terraform-policy -a claude-codeWhat terraform-policy does
This skill drafts .policy.hcl files, prepares or fixes .policytest.hcl cases, and moves rules from .sentinel into Terraform Policy. Authoring and conversion go through tfpolicy-author; test work goes through tfpolicy-test.
It asks for the installed tfpolicy version before giving guidance. In 0.2.x, resource and provider policies need a top-level required-provider block, while resource mocks in tests may omit state. Check the CLI version before editing.
With 0.3.x, every resource mock in .policytest.hcl needs attrs or prior_attrs, and an empty state skips that case. This line also validates schemas before tests run and includes core::alltrue() and core::anytrue().
What it helps with
- write a Terraform Policy rule from a requirement
- convert a
.sentinelrule to Terraform Policy - create a
.policytest.hcltest case - debug a failing policy test
- handle
tfpolicy0.2.xand0.3.xdifferences
Example prompts for the agent
- Write a
.policy.hclrule that rejects unencrypted EC2 instances. - Convert this
.sentinelpolicy into Terraform Policy. - Debug my
.policytest.hcltest for an EBS policy.
How to install terraform-policy
1Skills CLI (Vercel)
npx skills add hashicorp/agent-skills --skill terraform-policy -a claude-code2Manually: put the files in place
~/.claude/skills/terraform-policy/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/terraform-policy/
1Skills CLI (Vercel)
npx skills add hashicorp/agent-skills --skill terraform-policy -a codex2Manually: put the files in place
.agents/skills/terraform-policy/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add hashicorp/agent-skills --skill terraform-policy -a cursor2Manually: put the files in place
.cursor/skills/terraform-policy/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install hashicorp/agent-skills terraform-policy2Manually: put the files in place
.github/skills/terraform-policy/SKILL.md1Skills CLI (Vercel)
npx skills add hashicorp/agent-skills --skill terraform-policy -a gemini-cli2Platform CLI
gemini skills install https://github.com/hashicorp/agent-skills --path plugins/terraform/skills/terraform-policyManually: put the files in place
.devin/skills/terraform-policy/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add hashicorp/agent-skills --skill terraform-policy -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about terraform-policy
How do I install terraform-policy in Claude Code?
Run npx skills add hashicorp/agent-skills --skill terraform-policy -a claude-code, then run npx skills add hashicorp/agent-skills --skill terraform-policy -a claude-code again. The skill file is placed at ~/.claude/skills/terraform-policy/SKILL.md.
What does terraform-policy do?
It helps create Terraform Policy rules, write or debug their tests, and convert Sentinel policies. It routes authoring tasks to tfpolicy-author and tests to tfpolicy-test.
Why does the tfpolicy version matter?
In 0.3.x, a resource mock requires attrs or prior_attrs; an empty state skips the test case. 0.2.x permits resource mocks without state.