terraform-test — Claude Code skill: Terraform tests
Guides an agent through Terraform test files, scenarios, assertions, and plan or apply runs. Use it when checking modules, resources, and outputs.
npx skills add hashicorp/agent-skills --skill terraform-test -a claude-codeWhat terraform-test does
This skill guides the creation of .tftest.hcl and .tftest.json files with run blocks, variables, and assert checks. It covers output checks, conditional resources, resource counts, tags, and data sources.
Use plan for logic checks, while apply creates temporary real resources. That makes provider settings worth checking before an apply run, even though existing infrastructure and state files are protected.
It also covers expected failures with expect_failures, sequential scenarios, and plan options. Provider and data-source mocks require Terraform 1.7.0+; module sources are limited to local paths or the registry.
What it helps with
- create a
.tftest.hcltest file - check module outputs
- write a
planscenario without creating resources - test an expected validation failure
- mock a provider for a test
Example prompts for the agent
- Create
tests/defaults_unit_test.tftest.hclthat checks thevpc_idoutput. - Write a
plantest for a resource controlled by a variable. - Add
expect_failuresfor an invalidenvironmentvalue.
How to install terraform-test
1Skills CLI (Vercel)
npx skills add hashicorp/agent-skills --skill terraform-test -a claude-code2Manually: put the files in place
~/.claude/skills/terraform-test/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/terraform-test/
1Skills CLI (Vercel)
npx skills add hashicorp/agent-skills --skill terraform-test -a codex2Manually: put the files in place
.agents/skills/terraform-test/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add hashicorp/agent-skills --skill terraform-test -a cursor2Manually: put the files in place
.cursor/skills/terraform-test/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install hashicorp/agent-skills terraform-test2Manually: put the files in place
.github/skills/terraform-test/SKILL.md1Skills CLI (Vercel)
npx skills add hashicorp/agent-skills --skill terraform-test -a gemini-cli2Platform CLI
gemini skills install https://github.com/hashicorp/agent-skills --path plugins/terraform/skills/terraform-testManually: put the files in place
.devin/skills/terraform-test/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add hashicorp/agent-skills --skill terraform-test -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-test
How do I install terraform-test in Claude Code?
Run npx skills add hashicorp/agent-skills --skill terraform-test -a claude-code, then run npx skills add hashicorp/agent-skills --skill terraform-test -a claude-code again. The skill file is placed at ~/.claude/skills/terraform-test/SKILL.md.
What does terraform-test do?
It helps an agent write and run Terraform tests with run scenarios and assert conditions. The guidance covers both plan and apply modes.
What Terraform version is needed for mocks?
Mock providers and data sources require Terraform 1.7.0+. They should be skipped on earlier versions.