skills/.curated/terraform-doc-generator/SKILL.md
Auto-generate comprehensive README.md documentation for Terraform modules with usage examples, inputs, outputs, and requirements
npx skillsauth add guicedee/ai-rules terraform-doc-generatorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a Terraform documentation expert. When this skill is invoked, you help users automatically generate comprehensive, professional README.md files for their Terraform modules, including usage examples, requirements, inputs, outputs, and more.
When a user requests documentation generation:
Parse Terraform Files:
Generate README Sections:
Create Examples:
Add Metadata:
# Terraform Module: {module-name}
{Brief description of what this module does}
## Features
- Feature 1
- Feature 2
- Feature 3
## Usage
### Basic Example
```hcl
module "{module_name}" {
source = "{source_path}"
{required_variables}
}
module "{module_name}" {
source = "{source_path}"
{all_variables_with_examples}
}
| Name | Version | |------|---------| | terraform | >= {version} | | {provider} | >= {version} |
| Name | Version | |------|---------| | {provider} | >= {version} |
| Name | Type | |------|------| | {resource} | resource | | {data_source} | data source |
| Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | {variable} | {description} | {type} | {default} | yes/no |
| Name | Description | |------|-------------| | {output} | {description} |
Contributions are welcome! Please see CONTRIBUTING.md.
{license_type}
{author_information}
## Parsing Terraform Files
### Extract Variables
From `variables.tf`:
```hcl
variable "name" {
description = "Name of the resource"
type = string
default = "example"
}
variable "environment" {
description = "Environment name (dev, staging, prod)"
type = string
validation {
condition = contains(["dev", "staging", "prod"], var.environment)
error_message = "Must be dev, staging, or prod."
}
}
Parsed Output: | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | name | Name of the resource | string | "example" | no | | environment | Environment name (dev, staging, prod) | string | n/a | yes |
From outputs.tf:
output "id" {
description = "ID of the resource"
value = azurerm_resource_group.main.id
}
output "name" {
description = "Name of the resource"
value = azurerm_resource_group.main.name
}
Parsed Output: | Name | Description | |------|-------------| | id | ID of the resource | | name | Name of the resource |
From main.tf:
resource "azurerm_resource_group" "main" {
name = var.name
location = var.location
}
data "azurerm_client_config" "current" {}
Parsed Output: | Name | Type | |------|------| | azurerm_resource_group.main | resource | | azurerm_client_config.current | data source |
From versions.tf or terraform.tf:
terraform {
required_version = ">= 1.6"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0"
}
}
}
Parsed Output:
Files:
main.tf - Single resourcevariables.tf - Few variablesoutputs.tf - Basic outputsREADME:
Files:
main.tf - Multiple resourcesvariables.tf - Many variables with validationoutputs.tf - Multiple outputsexamples/ - Multiple examplesREADME:
Structure:
modules/
├── compute/
│ ├── main.tf
│ └── README.md
├── network/
│ ├── main.tf
│ └── README.md
└── storage/
├── main.tf
└── README.md
README:
# Terraform Module: {name}
[](https://www.terraform.io)
[](LICENSE)
## Architecture
```mermaid
graph TD
A[Resource Group] --> B[Virtual Network]
B --> C[Subnet]
C --> D[Virtual Machine]
```
### Add Usage Notes
```markdown
## Usage Notes
- This module creates resources in Azure
- Requires contributor access to subscription
- Uses managed identity for authentication
- Supports all Azure regions
## Migration from v1.x to v2.x
### Breaking Changes
- Variable `subnet_id` renamed to `subnet_ids` (now accepts list)
- Output `vnet_id` replaced with `network`
### Migration Steps
1. Update variable references:
```hcl
# Before
subnet_id = azurerm_subnet.main.id
# After
subnet_ids = [azurerm_subnet.main.id]
# Before
vnet_id = module.network.vnet_id
# After
vnet_id = module.network.network.id
## Script Integration
If `scripts/doc-generator.js` exists, use it:
```bash
# Generate README for current directory
node scripts/doc-generator.js
# Generate README for specific module
node scripts/doc-generator.js --path ./modules/network
# Generate with examples
node scripts/doc-generator.js --path . --include-examples
# Update existing README (preserve custom sections)
node scripts/doc-generator.js --update
# Generate and commit
node scripts/doc-generator.js --commit
Create .git/hooks/pre-commit:
#!/bin/bash
# Auto-generate documentation before commit
node .codex/skills/terraform-doc-generator/scripts/doc-generator.js --update
# Stage updated README
git add README.md
GitHub Actions:
name: Update Documentation
on:
push:
branches: [main]
paths:
- '**.tf'
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate Documentation
run: |
node .codex/skills/terraform-doc-generator/scripts/doc-generator.js --update
- name: Commit Changes
run: |
git config --global user.name 'docs-bot'
git config --global user.email '[email protected]'
git add README.md
git diff --staged --quiet || git commit -m "docs: auto-update README"
git push
# Azure {Resource} Module
Terraform module for managing Azure {Resource}.
## Features
- Creates and manages Azure {Resource}
- Supports {feature 1}
- Includes {feature 2}
- Configurable {feature 3}
## Usage
```hcl
module "{resource}" {
source = "path/to/module"
name = "my-{resource}"
location = "eastus"
resource_group_name = azurerm_resource_group.main.name
tags = {
Environment = "Production"
}
}
This module creates billable resources. See Azure Pricing.
### Template: AWS Module
```markdown
# AWS {Resource} Module
Terraform module for {resource description}.
## Features
- Creates {resource}
- Supports {feature}
- Includes {security feature}
## Usage
```hcl
module "{resource}" {
source = "path/to/module"
name = "my-{resource}"
region = "us-east-1"
tags = {
Environment = "Production"
}
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"{service}:{action}",
"{service}:Describe*"
],
"Resource": "*"
}
]
}
## Documentation Best Practices
### 1. Be Concise but Complete
✅ **Good**:
```markdown
Creates an Azure Virtual Network with customizable address space and DNS servers.
❌ Too Brief:
VNet module.
❌ Too Verbose:
This module provides a comprehensive solution for creating and managing
Azure Virtual Networks with support for multiple address spaces, custom
DNS configurations, DDoS protection, and integration with Azure Firewall...
✅ Good:
module "network" {
source = "../.."
name = "vnet-prod"
location = "eastus"
resource_group_name = "rg-network"
address_space = ["10.0.0.0/16"]
tags = {
Environment = "Production"
}
}
❌ Bad:
module "network" {
source = "path/to/module"
# Add your configuration here
}
## Known Limitations
- Maximum of 100 subnets per VNet
- Address space cannot be changed after creation
- Peering requires non-overlapping address spaces
## Troubleshooting
### Issue: Address space overlap
**Symptom**: `AddressSpaceOverlap` error
**Solution**: Ensure address spaces don't overlap with peered VNets
Before publishing a module:
Install:
brew install terraform-docs
Generate:
terraform-docs markdown table . > README.md
Config (.terraform-docs.yml):
formatter: markdown table
sections:
show:
- header
- inputs
- outputs
- providers
- requirements
- resources
content: |-
# {{.Header}}
{{.Content}}
## Examples
See [examples](./examples/) directory.
Developer README (README.md):
User Guide (USAGE.md):
API Reference (API.md):
See references/ for:
development
Install Codex skills into $CODEX_HOME/skills from a curated list or a GitHub repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo (including private repos).
tools
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Codex's capabilities with specialized knowledge, workflows, or tool integrations.
development
WebAwesome icon integration for JWebMP — modern, open-source icon library. Provides 1,500+ icons with solid/regular styles, sizing, rotation, animation, and CSS utilities. Drop-in FontAwesome alternative with fresh designs. Use when working with WebAwesome icons, modern icon designs, or as FontAwesome alternative in JWebMP applications.
development
WebAwesome Pro integration for JWebMP with premium icons and features. Extends jwebmp-webawesome with additional styles, premium icons, and advanced features. Use when working with WebAwesome Pro icons or premium WebAwesome features in JWebMP applications.