hashicorp/refactor-module
Transform monolithic Terraform configurations into reusable modules
Open source
Description
refactor-module is an agent skill from HashiCorp that turns a monolithic Terraform configuration into reusable modules, following HashiCorp's module design principles. It handles interface design, encapsulation, state migration, documentation and test scaffolding, and it works with local, private and public module registries. The page says that refactoring Terraform state by hand is error-prone because it needs careful ordering of moved blocks, plan checks and dependency mapping, and the skill does that work in a systematic way. Example jobs from the page are splitting a 500-line main.tf into separate VPC, compute and data modules, migrating state references after resources are extracted into a module, adding typed variable validation to a module that used untyped strings, generating moved blocks to relocate state without destroying and recreating resources, and structuring module outputs so downstream configurations keep working. It suits engineers who have grown a Terraform codebase and want to split it up safely. Install it with npx skills add https://github.com/hashicorp/agent-skills --skill refactor-module. HashiCorp publishes it in its agent-skills repository on GitHub, and the page labels it official.…
Highlights
- Splits configurations into reusable modules
- Interface design and encapsulation
- Generates moved blocks for state migration
- Typed variable validation
- Works with local, private and public registries
Ratings & Reviews
No ratings yet
Be the first to rate hashicorp/refactor-module.
People also visit

terraform-module-generation
Terraform module generation and refactoring skills including module design

terraform-style-guide
Generate Terraform HCL code following HashiCorp's official style conventions

terraform-engineer
Implementing infrastructure as code with Terraform across AWS, Azure, or GCP

terraform-code-generation
Terraform code generation skills including HCL generation, style guides
hashicorp/refactor-module FAQ
What does refactor-module do?
Turns a monolithic Terraform configuration into reusable modules, handling interfaces, state and documentation.
How do I install it?
Run npx skills add https://github.com/hashicorp/agent-skills --skill refactor-module.
Does it move state safely?
The page says it generates moved blocks to relocate state without destroying and recreating resources.
Which registries are supported?
Local, private and public module registries, according to the page.
Who publishes it?
HashiCorp, in its agent-skills repository on GitHub. The page labels it official.
What are the best hashicorp/refactor-module alternatives?
Popular alternatives to hashicorp/refactor-module include refactor-module, terraform-module-generation and terraform-style-guide. See all hashicorp/refactor-module alternatives








