Create reusable, composable Terraform modules with proper versioning and registry integration
View on GitHubpluginagentmarketplace/custom-plugin-terraform
terraform-assistant
January 20, 2026
Select agents to install to:
npx add-skill https://github.com/pluginagentmarketplace/custom-plugin-terraform/blob/main/skills/terraform-modules/SKILL.md -a claude-code --skill terraform-modulesInstallation paths:
.claude/skills/terraform-modules/# Terraform Modules Skill
Design and build production-ready, reusable Terraform modules following industry best practices.
## Module Structure
```
my-module/
├── main.tf # Primary resources
├── variables.tf # Input declarations
├── outputs.tf # Output declarations
├── versions.tf # Provider requirements
├── locals.tf # Computed values
├── README.md # Documentation
├── examples/
│ ├── basic/
│ └── complete/
└── tests/
└── module_test.go
```
## Quick Start Template
### versions.tf
```hcl
terraform {
required_version = ">= 1.5.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.0, < 6.0"
}
}
}
```
### variables.tf
```hcl
variable "name" {
type = string
description = "Resource name prefix"
validation {
condition = length(var.name) <= 32
error_message = "Name must be 32 characters or less."
}
}
variable "environment" {
type = string
description = "Deployment environment"
validation {
condition = contains(["dev", "staging", "prod"], var.environment)
error_message = "Must be dev, staging, or prod."
}
}
variable "tags" {
type = map(string)
description = "Resource tags"
default = {}
}
```
### main.tf
```hcl
locals {
common_tags = merge(var.tags, {
Module = "my-module"
Environment = var.environment
})
}
resource "aws_resource" "main" {
name = var.name
tags = local.common_tags
}
```
### outputs.tf
```hcl
output "id" {
description = "Resource ID"
value = aws_resource.main.id
}
output "arn" {
description = "Resource ARN"
value = aws_resource.main.arn
}
```
## Input Patterns
### Required vs Optional
```hcl
# Required - no default
variable "vpc_id" {
type = string
description = "VPC ID (required)"
}
# Optional with default
variable "instance_type" {
type = string
description = "EC2 instance type"
default = "t3.micro"
}
# Optio