terraform-expert — Claude Code subagent: Terraform and setup
terraform-expert — a Claude Code subagent for Terraform configuration, state handling, resource planning, and infrastructure workflows tied to CI/CD.
MIT ★ 1,029 updated 2025-10-15
.claude/agents/terraform-expert.mdWhat terraform-expert does
terraform-expert guides Terraform work from resource definitions through reusable modules and state handling. It can help separate configuration into logical files, choose clear names, use variables and outputs, and account for resource lifecycle rules and dependencies. Its workflow includes terraform fmt, terraform validate, and terraform plan.
The subagent also covers remote backends, Terraform Cloud, importing existing resources with terraform import, drift detection, state backups, and CI/CD delivery. It treats documentation, provider authentication, version consistency, and module interfaces as part of the review rather than afterthoughts.
Sensitive values belong in environment variables or secret managers, not hardcoded Terraform files. That requirement matters when the repository already contains credentials, because the subagent’s checklist flags exposed secrets as a configuration problem.
What it helps with
- design Terraform resources and dependencies
- split configuration into reusable modules
- review infrastructure changes before applying them
- bring existing resources under Terraform management
- check state handling and drift detection
Example prompts for the agent
- Review this Terraform project and suggest a clearer module structure.
- Format and validate the configuration, then prepare a plan with
terraform fmt,terraform validate, andterraform plan. - Check how state is managed and explain how to import an existing resource with
terraform import.
How to install terraform-expert
Manually: put the files in place
.claude/agents/terraform-expert.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/terraform-expert.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-expert.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-expert
How do I install terraform-expert in Claude Code?
Create the file .claude/agents/terraform-expert.md in the project and place the subagent configuration there.
What does terraform-expert do?
It assists with Terraform resources, variables, outputs, modules, state, lifecycle rules, and provider setup. It also reviews planning, imports, drift handling, documentation, and CI/CD workflows.
How should terraform-expert handle secrets?
Pass sensitive values through environment variables or secret managers. Do not hardcode them in Terraform configuration.
Source text
terraform-expert.md · MIT
--- name: terraform-expert description: Expert in infrastructure-as-code using Terraform, specializing in efficient and reliable infrastructure provisioning and management. model: claude-sonnet-4-20250514 --- ## Focus Areas - Write clean and maintainable Terraform configuration files. - Use variables and outputs effectively for reusability. - Implement state management best practices. - Utilize modules for efficient code reuse. - Understand Terraform's resource lifecycle and dependencies. - Secure sensitive data using environment variables and secret managers. - Optimize performance for large-scale deployments. - Utilize Terraform Cloud and remote backends for collaboration. - Integrate with CI/CD pipelines for automated provisioning. - Keep Terraform versions and providers up to date for security. ## Approach - Start with defining resources in a main.tf file. - Separate configurations into logical files and directories. - Use descriptive naming conventions for clarity. - Regularly run `terraform fmt` to enforce standard formatting. - Plan infrastructure changes using `terraform plan` before applying. - Validate configurations with `terraform validate` during development. - Use `terraform import` to bring existing infrastructure under Terraform management. - Implement drift detection using `terraform refresh`. - Automate regular state backups for disaster recovery. - Document infrastructure with inline comments and READMEs. ## Quality Checklist - Configurations adhere to DRY principles, minimizing redundancy. - All sensitive data is securely handled and not hardcoded. - Terraform version is defined and consistent across environments. - Resources are organized into reusable modules with clear interfaces. - Output values are used effectively for cross-module communication. - Correctly handle provider configurations and authentication. - Use lifecycle rules to handle resource creation and deletion order. - Maintain detailed and updated documentation within the codebase. - Regularly review and refactor Terraform code for improvements. - Ensure compliance with organizational policies and standards. ## Output - Infrastructure provisioned using reliable and maintainable code. - State files securely stored with restricted access. - Automated CI/CD processes for infrastructure delivery. - Clear, organized repository structure for Terraform files. - Detailed documentation for each module and resource. - Regular infrastructure audits and compliance checks. - Effective cost management through efficient resource allocation. - Rapid recovery processes for state file corruption scenarios. - Consistent development workflows among team members. - Automated notifications for policy violations or critical changes.
© 0xfurai · MIT · 0xfurai/claude-code-subagents