Skip to main content
skill CX Codex

terraform-expert — skill for Claude Code, Cursor, Copilot

terraform-expert — a skill for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode that gives the agent deep Terraform knowledge: modules, remote state, and resource lifecycle.

Apache-2.0 190 installs ★ 45 updated 2026-10-12

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add personamanagmentlayer/pcl --skill terraform-expert -a claude-code
Open on GitHub

What terraform-expert does

The skill runs across six platforms: Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode. The agent gets Read, Write, Edit, Bash (scoped to terraform:*), Glob, and Grep — enough to read configs, edit them, and run any Terraform command inside the working directory.

The skill covers the full command set (terraform init, plan, apply, destroy, state mv, import, force-unlock), naming conventions for resources and variables, an environments layout (dev/staging/prod), a remote state template using S3 with DynamoDB locking, and .gitignore rules for state files. For deeper topics, the agent pulls from references/CORE_CONCEPTS.md on demand.

Terraform >=1.6 is required. If .terraform.lock.hcl does not yet exist in the repo, the agent creates it on the first terraform init — committing that file is what keeps provider versions consistent across the team.

What it helps with

  • scaffold a Terraform module for VPC, EC2, or RDS with correct file structure
  • move a resource inside state without recreating it (terraform state mv)
  • configure a remote state backend on S3 with DynamoDB locking
  • split a configuration into dev/staging/prod environments with separate .tfvars files
  • import an existing cloud resource into Terraform (terraform import)

Example prompts for the agent

  • Create a Terraform module for an EKS cluster with variables for version and node type
  • Move aws_instance.old to aws_instance.new in state without destroying the resource
  • Set up a remote state S3 backend with DynamoDB locking for the prod environment

How to install terraform-expert

1Skills CLI (Vercel)

npx skills add personamanagmentlayer/pcl --skill terraform-expert -a claude-code

2Manually: put the files in place

~/.claude/skills/terraform-expert/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/terraform-expert/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about terraform-expert

How do I install terraform-expert in Claude Code?

Run npx skills add personamanagmentlayer/pcl --skill terraform-expert -a claude-code. The skill will be available at ~/.claude/skills/terraform-expert/SKILL.md.

What does the terraform-expert skill do?

It gives the agent full Terraform expertise: the complete init-plan-apply workflow, module authoring, state operations, and remote backend setup. The skill activates automatically when the task involves infrastructure as code, DevOps, or automation.

What version of Terraform does the skill require?

Terraform >=1.6. The skill follows the required_providers convention with pinned versions and locks them in .terraform.lock.hcl on first init.

Source text

SKILL.md · Apache-2.0
---
name: terraform-expert
version: 1.1.0
description: >-
  Expert-level Terraform infrastructure as code, modules, state management, and production
  best practices. Use when the user mentions infrastructure as code, devops, or automation,
  or when the task involves Terraform Basics, Resource Management, Modules, or State
  Management.
category: devops
author: PCL Team
license: Apache-2.0
tags:
  - terraform
  - infrastructure-as-code
  - iac
  - devops
  - automation
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(terraform:*)
  - Glob
  - Grep
requirements:
  terraform: '>=1.6'
---

# Terraform Expert

You are an expert in Terraform with deep knowledge of infrastructure as code, module development, state management, and production operations. You design and manage scalable, maintainable infrastructure using Terraform following industry best practices.

## Terraform Commands

**Basic Workflow:**

```bash
# Initialize
terraform init
terraform init -upgrade  # Upgrade providers

# Format code
terraform fmt
terraform fmt -recursive

# Validate configuration
terraform validate

# Plan changes
terraform plan
terraform plan -out=tfplan
terraform plan -var="instance_count=5"
terraform plan -var-file="prod.tfvars"

# Apply changes
terraform apply
terraform apply tfplan
terraform apply -auto-approve

# Destroy resources
terraform destroy
terraform destroy -target=aws_instance.web

# Show resources
terraform show
terraform show tfplan

# List resources
terraform state list

# Show specific resource
terraform state show aws_instance.web[0]
```

**State Management:**

```bash
# Pull remote state
terraform state pull > terraform.tfstate

# Push local state
terraform state push terraform.tfstate

# Move resource in state
terraform state mv aws_instance.old aws_instance.new

# Remove resource from state
terraform state rm aws_instance.web

# Import existing resource
terraform import aws_instance.web i-1234567890abcdef0

# Replace resource
terraform apply -replace=aws_instance.web
```

**Other Commands:**

```bash
# Generate graph
terraform graph | dot -Tsvg > graph.svg

# Unlock state
terraform force-unlock LOCK_ID

# Taint resource (mark for recreation)
terraform taint aws_instance.web

# Untaint resource
terraform untaint aws_instance.web

# Get outputs
terraform output
terraform output instance_id
terraform output -json

# Console (interactive)
terraform console
```

## Best Practices

### 1. Use Remote State

```hcl
terraform {
  backend "s3" {
    bucket         = "terraform-state"
    key            = "prod/terraform.tfstate"
    region         = "us-east-1"
    encrypt        = true
    dynamodb_table = "terraform-locks"
  }
}
```

### 2. Use Modules

```hcl
# Organize code into reusable modules
modules/
├── vpc/
├── ec2/
├── rds/
└── s3/
```

### 3. Use Variables and Outputs

```hcl
# Parameterize everything
# Document with descriptions
# Use validation rules
```

### 4. Use Version Constraints

```hcl
terraform {
  required_version = ">= 1.6"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}
```

### 5. Use Naming Conventions

```hcl
# Resource naming
resource "aws_instance" "web" {}  # Not "web_server"

# Variable naming
variable "instance_type" {}  # Snake case

# Tag naming
tags = {
  Name        = "prod-web-server"
  Environment = "production"
}
```

### 6. Separate Environments

```
environments/
├── dev/
│   ├── main.tf
│   └── terraform.tfvars
├── staging/
│   ├── main.tf
│   └── terraform.tfvars
└── prod/
    ├── main.tf
    └── terraform.tfvars
```

### 7. Use .gitignore

```
# .gitignore
.terraform/
*.tfstate
*.tfstate.backup
.terraform.lock.hcl
*.tfvars  # If contains secrets
crash.log
```

### 8. Enable Provider Locking

```hcl
# Commit .terraform.lock.hcl to version control
# Ensures consistent provider versions
```

## Approach

When writing Terraform:

1. **Plan Before Apply**: Always review plan output
2. **Use Modules**: DRY principle, reusable components
3. **Remote State**: S3 + DynamoDB for locking
4. **Version Everything**: Terraform, providers, modules
5. **Parameterize**: Use variables, not hardcoded values
6. **Document**: README files, variable descriptions
7. **Test**: Use terraform validate, fmt, plan
8. **Separate Environments**: Different tfvars or workspaces

Always write Terraform code that is maintainable, reusable, and follows infrastructure as code best practices.

## Reference Documentation

Detailed material lives alongside this skill and is read on demand:

- [Core Expertise](references/CORE_CONCEPTS.md) — Terraform Basics, Resource Management, Modules, State Management, Advanced Features

© PCL Team · Apache-2.0 · personamanagmentlayer/pcl

Similar skills

All skills for DevOps and infrastructure →
terraform-infrastructure-as-code manutej terraform-infrastructure-as-code equips your coding agent to structure Terraform manifests, configure cloud providers, and manage remote state. Useful when spinning up infrastructure with HCL. CX Codex +1 455installs terraform-best-practices NickCrew terraform-best-practices adds enterprise Terraform guidelines covering module layout, secure remote state, workspace isolation, and CI/CD security scanning. CX Codex +1 109installs terraform-aws-implement official github terraform-aws-implement — a GitHub Copilot subagent that writes and reviews Terraform for AWS. Trigger it in Copilot chat when cloud resources need to be built or an existing module checked. CX Codex +1 ★ 41,430repo stars terraform-generator akin-ozer The terraform-generator skill writes Terraform configs: resources, modules, providers, variables and outputs. Useful when you want infrastructure as code without hand-writing HCL. CX Codex +1 713installs huawei-cloud-terraform-installer huaweicloud huawei-cloud-terraform-installer is a Claude Code skill that installs Terraform CLI on Linux and Windows via the Huawei Cloud mirror. It triggers automatically when an IaC task detects Terraform is missing. CX Codex +1 19,100installs huawei-cloud-terraform-generator huaweicloud The huawei-cloud-terraform-generator Claude Code skill builds Terraform configurations for Huawei Cloud infrastructure. It turns a deployment goal into a resource plan and applies it only after you approve. CX Codex +1 18,400installs

From the same set104

The whole set →
looker-expert looker-expert — a Looker skill for the assistant: writes and reviews LookML, designs explores and measures, and catches fanout bugs before they reach a dashboard. CX Codex +1 194installs ruby-expert ruby-expert is a Claude Code skill for Ruby development, including Rails and RSpec testing. It activates for requests about Sinatra, gems, or metaprogramming. CX Codex +1 193installs code-review-expert code-review-expert conducts multi-stage code reviews targeting OWASP vulnerabilities, N+1 query bottlenecks, and overall maintainability. CX Codex +1 192installs cicd-expert cicd-expert guides CI/CD pipeline architecture, container builds, vulnerability scans, and Kubernetes release strategies. CX Codex +1 192installs go-expert go-expert — a skill that hands your coding agent Go conventions: goroutines, channels, context cancellation, error wrapping. Useful when you touch backend code. CX Codex +1 190installs monitoring-expert monitoring-expert — a skill for setting up monitoring, metrics and alerting with Prometheus, Grafana, Loki and distributed tracing. Builds observability from scratch or clarifies the three pillars of observation. CX Codex +1 189installs audit-expert audit-expert guides code security reviews, vulnerability checks, and compliance audits for SOC 2, GDPR, HIPAA, and PCI-DSS. CX Codex +1 188installs typescript-expert typescript-expert — a skill for expert-level TypeScript 5.0+ development with strict typing, modern build tools, and testing frameworks. CX Codex +1 187installs

Project sponsors

Companies that keep this analytics open