Skip to main content
subagent CX Codex

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

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/agents/terraform-expert.md
Open on GitHub

What 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, and terraform 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.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

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

Similar subagents

All subagents for DevOps and infrastructure →

From the same set137

The whole set →
prisma-expert prisma-expert designs Prisma schemas, refines database queries, and manages migrations. Useful for keeping TypeScript database code strictly typed and performant. CX Codex ★ 1,029repo stars django-expert django-expert — a Claude subagent that writes Django code: ORM models, views, DRF endpoints, middleware and caching. Handy when a task turns on query performance or API shape. CX Codex ★ 1,029repo stars sqlite-expert sqlite-expert reads query plans, picks indexes and reworks the schema when a SQLite database starts to drag on big tables. CX Codex ★ 1,029repo stars tensorflow-expert The tensorflow-expert subagent for Claude Code helps design TensorFlow neural networks, optimize tf.data pipelines, and prepare models for TensorFlow Serving or Lite. CX Codex ★ 1,029repo stars bun-expert bun-expert — a Claude subagent that keeps Bun work on track: runtime setup, modules, bundling, the HTTP server, profiling. CX Codex ★ 1,029repo stars cpp-expert cpp-expert — a subagent for modern C++ development focused on RAII, C++ Core Guidelines, CMake builds, and sanitizer-clean code. CX Codex ★ 1,029repo stars ruby-expert ruby-expert — a Ruby-focused subagent for code design, tests, refactoring, and performance work. Use it when a Ruby task needs language-specific review. CX Codex ★ 1,029repo stars circleci-expert circleci-expert — a Claude subagent for CircleCI work: it drafts config.yml, organises workflows and orbs, and tracks down jobs that fail. CX Codex ★ 1,029repo stars

Project sponsors

Companies that keep this analytics open