
Description
refactor-module is an agent skill from HashiCorp's agent-skills collection, listed on skills.sh. It guides an agent in turning a monolithic Terraform configuration into reusable, maintainable modules, following HashiCorp's module design principles and common community practice. The agent analyses the existing code and refactors it into modules with clear interface contracts made of variables and outputs, proper encapsulation, versioning and documentation, and testing frameworks. The skill also covers a migration path for existing state, so resources already managed by Terraform can move to the new module structure without being recreated. Prerequisites include the existing configuration, an understanding of resource dependencies, the ability to inspect current state with terraform state list and terraform show -json for migration planning, and knowledge of module registry patterns. It is a SKILL.md file of instructions that an agent loads when a task calls for it, and it is free to install. Its skills.sh audits show Gen Agent Trust Hub Pass, Socket Pass and Snyk Pass.…
Highlights
- Refactors monolithic Terraform into modules
- Clear variable and output contracts
- Migration path for existing state
- Testing and documentation guidance
- Free to install
Ratings & Reviews
No ratings yet
Be the first to rate refactor-module.
People also visit
hashicorp/refactor-module
Transform monolithic Terraform configurations into reusable modules

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
refactor-module FAQ
What does refactor-module do?
It helps an agent split a large Terraform configuration into reusable modules with clear interfaces.
How do I install it?
Run: npx skills add https://github.com/hashicorp/agent-skills --skill refactor-module
Will it affect my existing infrastructure?
The skill includes a migration path for existing state, and it asks the agent to inspect the current state first.
What do I need before using it?
The Terraform configuration, an understanding of its dependencies, and access to read the current state.
What did the security audits show?
skills.sh lists three audits: Gen Agent Trust Hub Pass, Socket Pass and Snyk Pass.
What are the best refactor-module alternatives?
Popular alternatives to refactor-module include hashicorp/refactor-module, terraform-module-generation and terraform-style-guide. See all refactor-module alternatives







