Terraform Skill

Terraform & OpenTofu Skill for AI Agents

A Terraform and OpenTofu best-practices skill: tests, modules, state, CI/CD and security scanning for AWS, Azure and GCP

SkillLow risk

antonbabenko/terraform-skill

Install

npx skills add https://github.com/antonbabenko/terraform-skill

For any Agent Skills compatible tool

This is third-party code. Review the repository files before installing.

What it does

The skill teaches an agent to write and review Terraform and OpenTofu code. It includes a decision matrix for native tests vs Terratest, module structure and versioning rules, remote state and locking, GitHub Actions and GitLab CI templates, and Trivy and Checkov integration. Every response must state version assumptions, risk category, a validation plan and rollback notes.

Who it is for. DevOps engineers and developers who maintain infrastructure as code.

Good fit when

  • You are creating a Terraform module with tests
  • You are setting up remote state with locking and encryption
  • You need a CI pipeline for Terraform with cost estimation
  • You want a best-practices review of an existing configuration

Not a fit when

  • Your infrastructure uses Pulumi, CloudFormation or Ansible
  • You need ready modules for Yandex Cloud: examples cover AWS, Azure and GCP

Example request

Create a Terraform module for an AWS VPC with native tests

Limitations

Examples default to AWS, and Azure or GCP equivalents must be requested. Do not add antonbabenko/terraform-skill as a separate marketplace: it clashes by name with antonbabenko/agent-plugins.

How to disable. Remove the terraform-skill plugin in your agent or delete the skill folder, and uninstall the extension in Gemini CLI.

Security check

  • The skill is markdown instructions and reference files

README in short

Anton Babenko's Terraform and OpenTofu practices skill, compatible with Claude Code, Cursor, Copilot, Gemini CLI, OpenCode, Codex and Kiro. The README describes sections on testing, modules, state, CI/CD and security. There are per-agent install instructions, and for Kiro the repo also works as a Power with an optional terraform-mcp-server. Example prompts are included.

SKILL.md

---
name: terraform-skill
description: Use when writing, reviewing, or debugging Terraform/OpenTofu modules, tests, CI, scans, or state ops - diagnoses failure mode (identity churn, secrets, blast radius, CI drift, state corruption) with version-aware guards.
license: Apache-2.0
metadata:
  author: Anton Babenko
  version: 1.17.1
---

# Terraform Skill for Claude

Diagnose-first guidance for Terraform and OpenTofu. Core file is a workflow; depth lives in references loaded on demand.

## Response Contract

Every Terraform/OpenTofu response must include:

1. **Assumptions & version floor** — runtime (`terraform` or `tofu`), exact version, providers, state backend, execution path (local/CI/Cloud/Atlantis), environment criticality. State assumptions explicitly if the user did not provide them.
2. **Risk category addressed** — one or more of: identity churn, secret exposure, blast radius, CI drift, compliance gaps, state corruption, provider upgrade risk, testing blind spots.
3. **Chosen remediation & tradeoffs** — what was chosen, what was traded off, why.
4. **Validation plan** — exact commands (`fmt -check`, `validate`, `plan -out`, policy check) tailored to runtime and risk tier.
5. **Rollback notes** — for any destructive or state-mutating change: how to undo, what evidence to keep.

Never recommend direct production apply without a reviewed plan artifact and approval.

Never run `terraform destroy` (targeted or full) without first running `terraform plan -destroy` and showing the user every resource that will be deleted — including implicit dependents pulled in via locals or `for_each`. Get explicit confirmation before proceeding. Never use `-auto-approve` on destroy.

## Workflow

1. **Capture execution context** — runtime+version, provider(s), backend, execution path, environment criticality.
2. **Diagnose failure mode(s)** using the routing table below. If intent spans categories, load both references.
3. **Load only the matching reference file(s)** — do not preload depth the task does not need.
4. **Propose fix with risk controls** — why this addresses the mode, what could still go wrong, guardrails (tests/approvals/rollback).
5. **Generate artifacts** — HCL, migration blocks (`moved`, `import`), CI changes, policy rules.
6. **Validate before finalizing** — run validation commands tailored to risk tier.
7. **Emit the Response Contract** at the end.

## Diagnose Before You Generate

| Failure category | Symptoms | Primary references |
|------------------|----------|--------------------|
| **Identity churn** | Resource addresses shift after refactor, `count` index churn, missing `moved` blocks | [Code Patterns: count vs for_each](references/code-patterns.md#count-vs-for_each-deep-dive), [Code Patterns: moved blocks](references/code-patterns.md#moved-blocks-terraform-11), [Code Patterns: LLM mistakes](references/code-patterns.md#llm-mistake-checklist--code-patterns) |
| **Secret exposure** | Secrets in defaults, state, logs, CI artifacts | [Security & Compliance](references/security-compliance.md), [Code Patterns: write-only](references/code-patterns.md#write-only-arguments-terraform-111), [State Management](references/state-management.md) |
| **Blast radius** | Oversized stacks, shared prod/non-prod state, unsafe applies | [State Management](references/state-management.md), [Module Patterns](references/module-patterns.md) |
| **Destroy cascade** | Targeted destroy deletes more than expected; locals referencing a targeted resource make all `for_each` consumers implicit dependents | Response Contract: plan-destroy first; [State Management: Safe Destroy](references/state-management.md#safe-destroy-protocol) |
| **CI drift** | Local plan ≠ CI plan, apply without reviewed artifact, unpinned versions | [CI/CD Workflows](references/ci-cd-workflows.md), [Code Patterns: versions](references/code-patterns.md#version-management) |
| **Compliance gaps** | Missing policy stage, no approval model, no evidence retention | [Security & Compliance](references/security-compliance.md), [CI/CD Workflows](references/ci-cd-workflows.md) |
| **Testing blind spots** | Plan-only validation of computed values, set-type indexing, mock/real confusion | [Testing Frameworks](references/testing-frameworks.md) |
| **State corruption / recovery** | Stuck lock, backend migration, drift reconciliation | [State Management](references/state-management.md) |
| **Provider upgrade risk** | Breaking-change provider bump, unpinned modules | [Code Patterns: versions](references/code-patterns.md#version-management), [Module Patterns](references/module-patterns.md) |
| **Provider lifecycle** | Removing a provider with resources still in state, orphaned resources, `removed` block usage | [State Management: Provider Removal](references/state-management.md#provider-removal) |
| **Bootstrap / orchestration misuse** | `null_resource` + `local-exec` for bootstrap, `remote-exec` for setup scripts, provisioner stdout leaking secrets in CI logs | [Code Patterns: Provisioners as Last Resort](references/code-patterns.md#provisioners-as-last-resort) |
| **Navigation / safe-rename blind spots** | Cannot locate symbol defs/refs semantically, value-symbol rename done as blind text replace, grep-only refactor missing refs, hallucinated `rg` shim | [Code Intelligence](references/code-intelligence-lsp.md#terraform-ls-capability-matrix) |
| **Cross-cloud / provider mapping** | "What's the Azure/GCP equivalent of X", picking a backend/auth model per cloud | [State Management: Cross-cloud equivalents](references/state-management.md#cross-cloud-equivalents) |

## When to Use This Skill

**Activate when:** creating or reviewing Terraform/OpenTofu configurations or modules, setting up or debugging tests, structuring multi-environment deployments, implementing IaC CI/CD, choosing module patterns or state organization, configuring or migrating remote state backends.

**Don't use for:** basic HCL syntax questions Claude already knows, provider API reference (link to docs), cloud-platform questions unrelated to Terraform/OpenTofu.

FAQ

Are Azure and GCP supported?

Yes, the README treats all three clouds as first-class, but examples default to AWS. Ask for the equivalent for your cloud.

Do I need the code-intelligence plugin?

No, the skill works on its own. Code-intelligence is a recommended companion for code navigation.

Kubernetes MCP

MCP Server Kubernetes

Editors’ pick

MCP server for managing a Kubernetes cluster through kubectl and Helm, with a non-destructive mode

MCP serverHigh risk1.6K
Editors’ pick

HashiCorp's official MCP server for the Terraform Registry and HCP Terraform: providers, modules, policies and workspaces

MCP serverHigh risk1.5K

CLI for full-cycle CI/CD to Kubernetes: image builds, Helm-based deploys and container registry cleanup

CLIHigh risk4.7K

A Helm alternative for deploying charts to Kubernetes with release plans, resource tracking and encrypted secrets

CLIHigh risk1.1K