refactor-module

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

5|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/lidge-jun/cli-jaw-skills --skill refactor-module-lidge-jun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-module
Source: https://github.com/lidge-jun/cli-jaw-skills/tree/main/terraform/module-generation/skills/refactor-module
Command: npx skills add https://github.com/lidge-jun/cli-jaw-skills --skill refactor-module-lidge-jun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenge of managing large, monolithic Terraform configurations by transforming them into modular, reusable, and maintainable codebases, adhering to best practices.

Core Features & Use Cases

  • Automated Refactoring: Analyzes existing Terraform code and restructures it into well-defined modules.
  • Best Practice Adherence: Implements HashiCorp's module design principles and community standards.
  • State Migration: Provides guidance and strategies for migrating existing state to the new module structure.
  • Use Case: Refactor a sprawling main.tf file that manages an entire VPC, subnets, and security groups into a clean, versioned VPC module that can be reused across multiple environments.

Quick Start

Use the refactor-module skill to transform the Terraform configuration in the directory '/path/to/monolith' into a new module named 'my-new-module', preserving state.

Frequently Asked Questions about refactor-module

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

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

To refactor Terraform configurations into reusable modules, this Skill analyzes existing monolithic code, designs module interfaces, transforms the code structure, and guides state migration. It ensures adherence to HashiCorp's module design principles for maintainability.

What is the best way to break down a monolithic Terraform file managing a VPC?

The best way to break down a monolithic Terraform file is to analyze the existing code and restructure it into clean, versioned modules. This Skill transforms sprawling VPC and subnet configurations into reusable components across multiple environments.

How does state migration work when transforming Terraform code into modules?

State migration during Terraform module transformation involves providing specific guidance and strategies for moving existing state to the new module structure. This ensures your infrastructure state remains consistent when refactoring monolithic configurations.

Does this Terraform refactoring approach support different module registries?

Yes, this Terraform refactoring approach supports various abstraction levels and target registries. It analyzes existing code to design appropriate module interfaces, ensuring maintainability and adherence to community standards.

Can I use this to create a versioned VPC module from existing infrastructure code?

Yes, you can use this to create a versioned VPC module from existing infrastructure code. It analyzes your existing Terraform configurations and transforms them into clean, reusable modules that can be deployed across multiple environments.