cloudgeni-ai/opengeni/refactor-module
Claude Code and agent skill by cloudgeni-ai/opengeni
- community
Checking that the SKILL.md file is still in the repository.
Transform monolithic Terraform configurations into reusable, maintainable modules following HashiCorp's module design principles and community best practices.
Install
npx vskill@latest install cloudgeni-ai/opengeni/refactor-moduleSKILL.md
The same SKILL.md was published earlier as midudev/autoskills/refactor-module.
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
Input Parameters
| Parameter | Type | Required | Description | |
|---|---|---|---|---|
source_directory | string | Yes | Path to existing Terraform configuration | |
module_name | string | Yes | Name for the new module | |
abstraction_level | string | No | "simple", "intermediate", "advanced" (default: intermediate) | |
preserve_state | boolean | Yes | Whether to maintain state compatibility | |
target_registry | string | No | Target module registry (local, private, public) |
Execution Steps
1. Analysis Phase
2. Module Design
Interface Design
Encapsulation Strategy
3. Code Transformation
Before: Monolithic Configuration
After: Modular Structure
4. State Migration
Generate Migration Plan
Manual State Migration (Pre-1.1)
5. Module Documentation
6. Testing
Use skill terraform-test
Test File: A .tftest.hcl or .tftest.json file containing test configuration and run blocks that validate your Terraform configuration.
Test Block: Optional configuration block that defines test-wide settings (available since Terraform 1.6.0).
Run Block: Defines a single test scenario with optional variables, provider configurations, and assertions. Each test file requires at least one run block.
Assert Block: Contains conditions that must evaluate to true for the test to pass. Failed assertions cause the test to fail.
Mock Provider: Simulates provider behavior without creating real infrastructure (available since Terraform 1.7.0).
Test Modes: Tests run in apply mode (default, creates real infrastructure) or plan mode (validates logic without creating resources).
File Structure
Terraform test files use the .tftest.hcl or .tftest.json extension and are typically organized in a tests/ directory. Use clear naming conventions to distinguish between unit tests (plan mode) and integration tests (apply mode):
Refactoring Patterns
Pattern 1: Resource Grouping
Extract related resources into cohesive modules:
- Networking (VPC, Subnets, Route Tables)
- Compute (ASG, Launch Templates, Load Balancers)
- Data (RDS, ElastiCache, S3)
Pattern 2: Configuration Layering
Pattern 3: Composition
Common Pitfalls
1. Over-Abstraction
2. Tight Coupling
3. State Migration Errors
Always test migration in non-production first:
Version Control Strategy
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpackages/runtime/src/curated_skill_library/refactor-module/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cloudgeni-ai/opengeni/refactor-module)