terraform-specialist — Claude Code subagent for Terraform
A Terraform subagent that builds modules, wires up remote state and hunts drift. Useful once your infrastructure outgrows a single main.tf.
npx claude-code-templates@latest --agent devops-infrastructure/terraform-specialistWhat terraform-specialist does
This subagent treats infrastructure as code: it designs modules with input variables, sets up a backend for remote state, and pins providers with version constraints. It also handles workspaces for multiple environments, imports existing resources and detects drift.
The agent follows a fixed set of habits. It keeps things DRY, treats state files as sacred and backs them up, reviews plan before apply, locks provider versions for reproducibility, and pulls values from data sources instead of hardcoding them. Output includes modules, backend configuration, provider requirements, Makefile or scripts for routine operations, and pre-commit hooks for validation. You also get .tfvars examples plus both plan and apply output.
Its toolset is small: Read, Write, Edit and Bash. So it edits your configuration directly and runs commands through the shell, which means it touches your working directory and your provider credentials. Have Terraform installed and backend access configured before the first run, or plan will not build. And if the project has a state file that people have edited by hand, back it up first: the agent reshapes configuration into modules, and any mismatch shows up on the very first plan.
What it helps with
- split a sprawling
main.tfinto reusable modules - move state to S3, Azure Storage or Terraform Cloud
- pin provider versions so builds stop drifting apart
- separate environments with workspaces
- import existing resources and surface config drift
Example prompts for the agent
- Split this
main.tfinto modules with input variables and show me a.tfvarsexample - Set up remote state in S3 and add version constraints for the AWS provider
- Check for drift between the current state and the config, then propose an import plan
How to install terraform-specialist
1claude-code-templates
npx claude-code-templates@latest --agent devops-infrastructure/terraform-specialist2Manually: put the files in place
.claude/agents/terraform-specialist.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/terraform-specialist.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/terraform-specialist.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about terraform-specialist
How do I install terraform-specialist in Claude?
Run npx claude-code-templates@latest --agent devops-infrastructure/terraform-specialist. The agent file then lives at .claude/agents/terraform-specialist.md.
What does terraform-specialist do?
It designs Terraform modules, configures a backend for remote state, pins providers, splits environments across workspaces and detects drift. It also writes scripts for common operations and pre-commit hooks.
Which tools does the subagent have?
Read, Write, Edit and Bash. That is why it can both edit configuration and run Terraform commands in your directory.