# terraform-best-practices

This skill guides Terraform code reviews and authoring, covering file layout, modules, state, and security. Use it when shaping infrastructure configuration.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · ★ 109
- Author: c0x12c
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/c0x12c/ai-toolkit/tree/HEAD/toolkit/skills/terraform-best-practices/SKILL.md
- Updated: 2026-06-18
- HTML: https://affpapa.org/en/nevibecode/skills/terraform-best-practices

## What it does

The skill lays out conventions for splitting configuration across files and environments, naming resources and variables, and defining module inputs and outputs. It also covers pinned module versions, remote state, and references between stacks.

Security guidance includes sensitive variables, encrypted storage, private databases, and security-group rules. It flags patterns such as secrets in code, wildcard IAM permissions, unpinned modules, and state without locking. Its S3 backend example uses DynamoDB for locking, so the backend setup needs to account for that.

The CI/CD section outlines formatting checks, validation, and a plan on pull requests, followed by applying after a merge. It advises against automatic applies on pull requests and recommends passing secrets through CI environment variables. This is a reference for Terraform conventions, not a replacement for checking the settings in your own configuration.

## Requirements
- Works with: Terraform

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill terraform-best-practices -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill terraform-best-practices -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill terraform-best-practices -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install c0x12c/ai-toolkit terraform-best-practices
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill terraform-best-practices -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/c0x12c/ai-toolkit --path toolkit/skills/terraform-best-practices
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill terraform-best-practices -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/c0x12c/ai-toolkit/tree/HEAD/toolkit/skills/terraform-best-practices/SKILL.md

## When to use it
- organize Terraform configuration by file and environment
- choose consistent names for resources and variables
- define reusable modules with pinned versions
- configure remote state and locking
- spot secrets and unsafe settings in Terraform code

## Example prompts
- Review these Terraform files for secrets and unsafe settings.
- Suggest a file layout for this Terraform configuration.
- Check this module and its callers for unpinned versions and interface issues.

## Similar
- [wizard](https://affpapa.org/en/nevibecode/skills/wizard.md) — skill · 553369 installs
- [hyperframes-cli](https://affpapa.org/en/nevibecode/skills/heygen-com-hyperframes-cli.md) — skill · 1300000 installs
- [setup-pre-commit](https://affpapa.org/en/nevibecode/skills/setup-pre-commit.md) — skill · 489289 installs
- [using-git-worktrees](https://affpapa.org/en/nevibecode/skills/using-git-worktrees.md) — skill · 217153 installs
- [finishing-a-development-branch](https://affpapa.org/en/nevibecode/skills/finishing-a-development-branch.md) — skill · 214439 installs
- [orca-cli](https://affpapa.org/en/nevibecode/skills/orca-cli.md) — skill · 354000 installs

From the same set: [c0x12c/ai-toolkit](https://affpapa.org/en/nevibecode/by/c0x12c/ai-toolkit.md) — 33 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
