refactor-module

Guide Terraform module extraction decisions and boundary definitions.

22|3|Updated Jan 8, 2026
One-click install
npx skills add https://github.com/acedergren/agentic-tools --skill refactor-module
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-module
Source: https://github.com/acedergren/agentic-tools/tree/main/skills/refactor-module
Command: npx skills add https://github.com/acedergren/agentic-tools --skill refactor-module

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Terraform module extraction decisions and anti-pattern awareness to prevent module sprawl and risky state migrations.

Core Features & Use Cases

  • Decision framework to determine when to modularize (4+ usages) vs inline (1-2 usages).
  • Anti-patterns coverage (Leaky Abstractions, Premature Modularization, State Migration Nightmare, Version Hell) with concrete mitigations.
  • Structured refactoring process including duplication analysis, interface design, module extraction, testing, and safe state migration.
  • Use case: multi-team environments needing consistent module boundaries and upgrade strategies.

Quick Start

  1. Identify a repeated Terraform pattern across your repo.
  2. Assess duplication against the decision framework to decide module extraction.
  3. Design the module interface, extract resources, write tests, and migrate state with backup.

Frequently Asked Questions about refactor-module

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

FAQPage Schema
When should I extract Terraform code into a module instead of keeping it inline?

Extract Terraform code into modules when a pattern is repeated 4 or more times, while keeping code inline for 1-2 usages to avoid premature modularization. This threshold prevents module sprawl and leaky abstractions.

What are common Terraform modularization anti-patterns I should avoid?

Common Terraform modularization anti-patterns include leaky abstractions, premature modularization, state migration nightmares, and version hell. Mitigations involve careful interface design, structured extraction, and backing up state before migration.

How do I safely migrate Terraform state when refactoring code into modules?

Safely migrate Terraform state during module refactoring by following a structured process of duplication analysis, interface design, resource extraction, testing, and performing state migration with backups.

What is the best way to define module boundaries in a multi-team Terraform environment?

Define module boundaries in multi-team Terraform environments by establishing consistent module interfaces and upgrade strategies. This coordinates versioned environments and ensures safe, scalable modularization across teams.

Does refactoring Terraform into modules cause version conflicts across environments?

Refactoring Terraform into modules can cause version hell across environments if unmanaged. Establishing consistent module boundaries and structured upgrade strategies mitigates these multi-team coordination risks.