refactor-module

Refactor monolithic Terraform configurations into reusable modules with state migration plans.

790|117|Updated Nov 8, 2025
One-click install
npx skills add https://github.com/hashicorp/agent-skills --skill refactor-module-hashicorp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-module
Source: https://github.com/hashicorp/agent-skills/tree/main/terraform/module-generation/skills/refactor-module
Command: npx skills add https://github.com/hashicorp/agent-skills --skill refactor-module-hashicorp

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactor-module fixes monolithic Terraform configurations by producing reusable, well-structured modules.

Core Features & Use Cases

  • Analyze existing configurations to identify module boundaries, interfaces (variables/outputs), and dependency relationships.
  • Create encapsulated module structures with clear interfaces, versioning, and documentation.
  • Plan and execute state migrations to minimize drift and avoid recreation, with a safe migration path for existing deployments.

Quick Start

Use the refactor-module skill to transform an existing Terraform configuration into a modular structure. Provide the path to the current Terraform project and the desired module name.

Frequently Asked Questions about refactor-module

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor monolithic Terraform configurations into reusable modules?

Refactoring monolithic Terraform configurations involves analyzing existing setups to identify module boundaries, defining structured variables and outputs, and creating encapsulated module structures with clear documentation and versioning.

What is the best way to split a single-file Terraform setup into a modular architecture?

The best way to split a single-file Terraform setup is to identify dependency relationships, extract encapsulated components into separate modules, and enforce structured interfaces for variables and outputs to ensure reusability.

How do I handle Terraform state migration when moving resources into new modules?

Terraform state migration during refactoring requires planning and executing state moves to minimize drift and avoid resource recreation, ensuring a safe migration path for existing deployments.

When should I refactor my Terraform project into multiple modules?

You should refactor your Terraform project into multiple modules when your configuration grows large enough that monolithic files become difficult to maintain, and you need reusable, encapsulated components with clear interfaces.

Can I refactor a Terraform configuration of any size into modules?

Yes, refactoring applies to Terraform configurations of varying sizes, guiding the transformation from single-file setups to modular architectures while supporting state migration for existing deployments.