hashicorp avatar

Refactor Module

Transforms monolithic Terraform configurations into reusable modules with state migration and validation.

CCM score
71 of 100
skills.sh installs
6.9K
GitHub stars
941
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers the full refactor flow: resource analysis, interface design, code transformation, and state migration
  • Defines input and output contracts with variable validation blocks and typed output values
  • Generates moved blocks and inspects state via terraform state list and terraform show -json
  • Designed for teams splitting large Terraform configurations into maintainable, versioned modules

Install

$ npx -y skills add hashicorp/agent-skills --skill refactor-module -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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 inspect current state via terraform state list / terraform show -json (for migration planning)
  • Knowledge of module registry patterns

Input Parameters

Details

Repository
github.com/hashicorp/agent-skills
Category
DevOps & Cloud

More from hashicorp/agent-skills

All 16

Similar to Refactor Module

More DevOps & Cloud