# terraform-test

Guides an agent through Terraform test files, scenarios, assertions, and plan or apply runs. Use it when checking modules, resources, and outputs.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 8800 installs · ★ 909
- Author: hashicorp
- License: MPL-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/hashicorp/agent-skills/tree/HEAD/plugins/terraform/skills/terraform-test/SKILL.md
- Updated: 2026-10-05
- HTML: https://affpapa.org/en/nevibecode/skills/terraform-test

## What it 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.

## Requirements
- Works with: Terraform

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add hashicorp/agent-skills --skill terraform-test -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/terraform-test/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/terraform-test/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add hashicorp/agent-skills --skill terraform-test -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/terraform-test/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add hashicorp/agent-skills --skill terraform-test -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/terraform-test/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install hashicorp/agent-skills terraform-test
```

2. **Manually: put the files in place**
- File: `.github/skills/terraform-test/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add hashicorp/agent-skills --skill terraform-test -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/hashicorp/agent-skills --path plugins/terraform/skills/terraform-test
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/terraform-test/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add hashicorp/agent-skills --skill terraform-test -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/hashicorp/agent-skills/tree/HEAD/plugins/terraform/skills/terraform-test/SKILL.md

## When to use it
- create a `.tftest.hcl` test file
- check module outputs
- write a `plan` scenario without creating resources
- test an expected validation failure
- mock a provider for a test

## Example prompts
- Create `tests/defaults_unit_test.tftest.hcl` that checks the `vpc_id` output.
- Write a `plan` test for a resource controlled by a variable.
- Add `expect_failures` for an invalid `environment` value.

## Similar
- [terraform-skill](https://affpapa.org/en/nevibecode/skills/terraform-skill.md) — skill · 7400 installs
- [terraform-validator](https://affpapa.org/en/nevibecode/skills/terraform-validator.md) — skill · 640 installs
- [terraform-generator](https://affpapa.org/en/nevibecode/skills/terraform-generator.md) — skill · 639 installs
- [terraform-patterns](https://affpapa.org/en/nevibecode/skills/terraform-patterns.md) — skill · 617 installs
- [infisical-terraform](https://affpapa.org/en/nevibecode/skills/infisical-terraform.md) — skill · 478 installs
- [terraform-engineer](https://affpapa.org/en/nevibecode/skills/terraform-engineer.md) — skill · 5400 installs

From the same set: [hashicorp/agent-skills](https://affpapa.org/en/nevibecode/by/hashicorp/agent-skills.md) — 20 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
