refactor-module

Installation
Summary

Break monolithic Terraform configurations into reusable, well-structured modules with clear contracts and migration paths.

  • Analyzes existing code to identify refactoring candidates, groups resources by logical function, and assesses complexity before design
  • Generates module interfaces with typed variables, validation rules, and descriptive outputs following HashiCorp best practices
  • Provides state migration strategies using moved blocks (Terraform 1.1+) or manual terraform state mv commands to preserve existing state
  • Includes testing frameworks, documentation templates, and common patterns for resource grouping, configuration layering, and module composition
  • Identifies pitfalls like over-abstraction, tight coupling, and state migration errors with concrete examples and remediation guidance
SKILL.md

Skill: Refactor Module

Overview

This skill guides AI agents in transforming monolithic Terraform configurations into reusable, maintainable modules following HashiCorp's module design principles and community best practices.

Capability Statement

The agent will analyze existing Terraform code and systematically refactor it into well-structured modules with:

  • Clear interface contracts (variables and outputs)
  • Proper encapsulation and abstraction
  • Versioning and documentation
  • Testing frameworks
  • Migration path for existing state

Prerequisites

  • Existing Terraform configuration to refactor
  • Understanding of resource dependencies
  • Access to current state file (for migration planning)
  • Knowledge of module registry patterns
Related skills

More from hashicorp/agent-skills

Installs
2.2K
GitHub Stars
613
First Seen
Jan 26, 2026