Skip to main content
skill CX Codex

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.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add hashicorp/agent-skills --skill terraform-policy -a claude-code
Open on GitHub

What 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 .sentinel rule to Terraform Policy
  • create a .policytest.hcl test case
  • debug a failing policy test
  • handle tfpolicy 0.2.x and 0.3.x differences

Example prompts for the agent

  • Write a .policy.hcl rule that rejects unencrypted EC2 instances.
  • Convert this .sentinel policy into Terraform Policy.
  • Debug my .policytest.hcl test for an EBS policy.

How to install terraform-policy

1Skills CLI (Vercel)

npx skills add hashicorp/agent-skills --skill terraform-policy -a claude-code

2Manually: put the files in place

~/.claude/skills/terraform-policy/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/terraform-policy/

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.

Similar skills

Everything for DevOps and infrastructure →

From the same set16

new-terraform-provider A skill that walks the agent through bootstrapping a Terraform provider on the Plugin Framework, from directory layout to a passing build. CX Codex +1 3,900installs run-acceptance-tests Runs and investigates Terraform provider acceptance tests with the TestAcc prefix. Use it for missing environment variables, failed runs, or tests that pass when they should not. CX Codex +1 3,700installs provider-test-patterns A skill that guides acceptance testing for Terraform providers using terraform-plugin-testing and the Plugin Framework. CX Codex +1 3,300installs azure-verified-modules A skill that carries the Azure Verified Modules requirements, so your agent can write and review Terraform modules that pass AVM certification. CX Codex +1 3,300installs aws-ami-builder A skill that walks your agent through building Amazon Machine Images with Packer and the amazon-ebs builder — template, source AMI filters, build commands. CX Codex +1 3,200installs provider-docs Guides Terraform provider documentation workflows for the Terraform Registry. It coordinates schema descriptions, docs templates, and tfplugindocs generation. CX Codex +1 3,200installs push-to-registry Teaches AI assistants how to register Packer build details in HCP. Useful for tracking machine image lifecycles and linking artifacts directly to Terraform. CX Codex +1 3,000installs windows-builder A skill for building Windows images with Packer over WinRM and PowerShell provisioners. Useful for Windows AMIs, Azure images and VMware templates. CX Codex +1 2,700installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor