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
npx skills add personamanagmentlayer/pcl --skill terraform-expert -a claude-codeWhat 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
.tfvarsfiles - 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.oldtoaws_instance.newin 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-code2Manually: put the files in place
~/.claude/skills/terraform-expert/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/terraform-expert/
1Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill terraform-expert -a codex2Manually: put the files in place
.agents/skills/terraform-expert/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill terraform-expert -a cursor2Manually: put the files in place
.cursor/skills/terraform-expert/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install personamanagmentlayer/pcl stdlib/devops/terraform-expert2Manually: put the files in place
.github/skills/terraform-expert/SKILL.md1Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill terraform-expert -a gemini-cli2Platform CLI
gemini skills install https://github.com/personamanagmentlayer/pcl --path stdlib/devops/terraform-expertManually: put the files in place
.devin/skills/terraform-expert/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill terraform-expert -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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