Terraform Skill for Claude banner
antonbabenko antonbabenko

Terraform Skill for Claude

DevOps community intermediate

Description

Comprehensive Terraform and OpenTofu guidance covering testing, modules, CI/CD, and production patterns. Based on terraform-best-practices.com and enterprise experience.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

Repository README

This is the README for antonbabenko/terraform-skill, shared by 4 entries in this directory. It describes the repository, not this entry specifically.


name: terraform-skill description: Use when working with Terraform or OpenTofu - creating modules, writing tests (native test framework, Terratest), setting up CI/CD pipelines, reviewing configurations, choosing between testing approaches, debugging state issues, implementing security scanning (trivy, checkov), or making infrastructure-as-code architecture decisions license: Apache-2.0 metadata: author: Anton Babenko version: 1.6.0

Terraform Skill for Claude

Comprehensive Terraform and OpenTofu guidance covering testing, modules, CI/CD, and production patterns. Based on terraform-best-practices.com and enterprise experience.

When to Use This Skill

**Activate this skill when:**

  • Creating new Terraform or OpenTofu configurations or modules
  • Setting up testing infrastructure for IaC code
  • Deciding between testing approaches (validate, plan, frameworks)
  • Structuring multi-environment deployments
  • Implementing CI/CD for infrastructure-as-code
  • Reviewing or refactoring existing Terraform/OpenTofu projects
  • Choosing between module patterns or state management approaches

**Don't use this skill for:**

  • Basic Terraform/OpenTofu syntax questions (Claude knows this)
  • Provider-specific API reference (link to docs instead)
  • Cloud platform questions unrelated to Terraform/OpenTofu

Core Principles

1. Code Structure Philosophy

**Module Hierarchy:**

Type When to Use Scope
Resource Module Single logical group of connected resources VPC + subnets, Security group + rules
Infrastructure Module Collection of resource modules for a purpose Multiple resource modules in one region/account
Composition Complete infrastructure Spans multiple regions/accounts

**Hierarchy:** Resource → Resource Module → Infrastructure Module → Composition

**Directory Structure:**

environments/        # Environment-specific configurations
├── prod/
├── staging/
└── dev/

modules/            # Reusable modules
├── networking/
├── compute/
└── data/

examples/           # Module usage examples (also serve as tests)
├── complete/
└── minimal/

**Key principle from terraform-best-practices.com:**

  • Separate environments (prod, staging) from modules (reusable components)
  • Use examples/ as both documentation and integration test fixtures
  • Keep modules small and focused (single responsibility)

**For detailed module architecture, see:** [Code Patterns: Module Types & Hierarchy](references/code-patterns.md)

2. Naming Conventions

**Resources:**

# Good: Descriptive, contextual
resource "aws_instance" "web_server" { }
resource "aws_s3_bucket" "application_logs" { }

# Good: "this" for singleton resources (only one of that type)
resource "aws_vpc" "this" { }
resource "aws_security_group" "this" { }

# Avoid: Generic names for non-singletons
resource "aws_instance" "main" { }
resource "aws_s3_bucket" "bucket" { }

**Singleton Resources:**

Use `"this"