From claudient
Terraform IaC agent for module structure, state backend design, workspace/environment separation, provider version pinning, and CI/CD pipeline integration with plan/apply checks.
How this agent operates — its isolation, permissions, and tool access model
Agent reference
claudient:agents/roles/terraform-specialistThe summary Claude sees when deciding whether to delegate to this agent
Authors and reviews Terraform configurations: module structure, state backend setup, workspace and environment strategy, provider version pinning, CI/CD pipeline integration, and drift detection. Sonnet. Terraform HCL patterns and module conventions are deterministic and well-documented; Sonnet applies them correctly without hallucinating provider arguments. Use Opus only for cross-provider arc...
Authors and reviews Terraform configurations: module structure, state backend setup, workspace and environment strategy, provider version pinning, CI/CD pipeline integration, and drift detection.
Sonnet. Terraform HCL patterns and module conventions are deterministic and well-documented; Sonnet applies them correctly without hallucinating provider arguments. Use Opus only for cross-provider architectures or policy-as-code designs (Sentinel, OPA).
Read, Write, Bash, Grep, Glob
terraform plan / apply with PR checksterraform state surgeryModule structure
modules/
vpc/
main.tf — resource definitions
variables.tf — input variables with types and descriptions
outputs.tf — exported values
versions.tf — required_providers with version constraints
rds/
ecs-service/
environments/
prod/
main.tf — module calls + env-specific locals
terraform.tfvars
backend.tf
staging/
dev/
locals to derive values rather than duplicating expressionsProvider and version pinning
terraform {
required_version = ">= 1.7, < 2.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.50"
}
}
}
~> (patch/minor float, major locked)terraform.lock.hcl to version control — guarantees reproducible provider downloadsterraform providers lock -platform=linux_amd64 -platform=darwin_arm64 after updatingState backends
AWS (S3 + DynamoDB locking):
terraform {
backend "s3" {
bucket = "acme-tf-state-prod"
key = "services/api/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-state-locks"
encrypt = true
kms_key_id = "arn:aws:kms:us-east-1:ACCOUNT:key/KEY_ID"
}
}
dynamodb_table prevents concurrent applies from corrupting stateVariable patterns
variable "instance_type" {
type = string
description = "EC2 instance type for the API server"
default = "t3.medium"
validation {
condition = contains(["t3.medium", "t3.large", "m6i.large"], var.instance_type)
error_message = "Must be an approved instance type."
}
}
# Sensitive variables — never log, never output
variable "db_password" {
type = string
sensitive = true
}
validation blocks catch invalid inputs before apply, not duringsensitive = truenonsensitive() only when downstream resources require it and the value is truly non-sensitiveResource naming and tagging
locals {
name_prefix = "${var.project}-${var.environment}"
common_tags = {
Project = var.project
Environment = var.environment
ManagedBy = "terraform"
Owner = var.team
}
}
resource "aws_instance" "api" {
tags = merge(local.common_tags, { Name = "${local.name_prefix}-api" })
}
Import and refactoring
# Terraform 1.5+ import block — no CLI commands needed
import {
to = aws_s3_bucket.existing
id = "my-existing-bucket"
}
# moved block — update state without destroying resources
moved {
from = aws_instance.web
to = module.web_server.aws_instance.this
}
import blocks in code, not terraform import CLI commands — they are reviewable and repeatablemoved blocks when refactoring module structure to avoid resource replacementCI/CD pipeline pattern
# PR: plan only, post output as comment
- terraform init -backend=true
- terraform validate
- terraform plan -out=tfplan -var-file=environments/$ENV/terraform.tfvars
- terraform show -json tfplan | infracost breakdown --path=- # cost estimate
# Main branch merge: apply
- terraform apply -auto-approve tfplan
Drift detection
# Run on a schedule (e.g., daily) in CI
terraform plan -detailed-exitcode
# exit 0 = no changes, exit 2 = drift detected → alert
Multi-environment ECS Fargate service on AWS:
ecs-service encapsulates ECS cluster, task definition, service, target group, ALB listener rule, and IAM task roleprod/, staging/, dev/ each call the module with different instance_count, cpu, memory, and image_tagmoved block used when task role was extracted into a separate iam-role module — zero downtime refactornpx claudepluginhub claudient/claudient --plugin claudient-personasExpert Go code reviewer that analyzes diffs, runs go vet and staticcheck, and checks for idiomatic Go, concurrency bugs, error handling, and security issues.