skills/.curated/terraform-plan-analyzer/SKILL.md
Parse, explain, and analyze terraform plan output for impact assessment, cost estimation, and risk evaluation
npx skillsauth add guicedee/ai-rules terraform-plan-analyzerInstall 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 plan analysis expert. When this skill is invoked, you help users understand terraform plan output, assess impact, estimate costs, identify risks, and make informed decisions before applying changes.
When a user requests plan analysis:
Parse Plan Output:
Impact Assessment:
Risk Evaluation:
Cost Analysis:
Terraform uses these symbols in plan output:
+ Create resource- Destroy resource~ Update in-place-/+ Destroy and recreate<= Read (data source)# Comment/noteCreate (New resource):
# azurerm_resource_group.main will be created
+ resource "azurerm_resource_group" "main" {
+ id = (known after apply)
+ location = "eastus"
+ name = "my-rg"
}
Update in-place (No downtime):
# azurerm_storage_account.main will be updated in-place
~ resource "azurerm_storage_account" "main" {
id = "/subscriptions/.../mystorageaccount"
~ min_tls_version = "TLS1_0" -> "TLS1_2"
# (15 unchanged attributes hidden)
}
Replace (Destroy then create - DOWNTIME):
# azurerm_virtual_machine.main must be replaced
-/+ resource "azurerm_virtual_machine" "main" {
~ id = "/subscriptions/.../myvm" -> (known after apply)
~ vm_size = "Standard_D2s_v3" -> "Standard_D4s_v3" # forces replacement
name = "my-vm"
}
Destroy (Resource removed):
# azurerm_resource_group.old will be destroyed
- resource "azurerm_resource_group" "old" {
- id = "/subscriptions/.../old-rg" -> null
- location = "eastus" -> null
- name = "old-rg" -> null
}
(known after apply): Value will be determined during apply(sensitive value): Value is marked sensitiveforces replacement: This change requires recreating the resourceBasic plan:
terraform plan
Save plan to file:
terraform plan -out=tfplan
JSON format for analysis:
terraform plan -out=tfplan
terraform show -json tfplan > plan.json
Detailed exit code:
terraform plan -detailed-exitcode
Exit codes:
0: No changes1: Error2: Changes presentHigh Impact Changes:
Medium Impact Changes:
Low Impact Changes:
Critical Risks:
High Risks:
Medium Risks:
Low Risks:
Cost Increases:
Cost Decreases:
Cost Neutral:
terraform plan -out=tfplan
terraform show -json tfplan > plan.json
Look at the plan summary:
Plan: 5 to add, 3 to change, 2 to destroy.
This tells you:
For each resource change, assess:
Identify cascading changes:
# Resources that depend on changed resources
# will show in the plan
Ensure the plan matches your intentions:
~ resource "azurerm_storage_account" "main" {
~ tags = {
+ "Environment" = "Production"
}
}
Analysis:
-/+ resource "azurerm_linux_virtual_machine" "main" {
~ vm_size = "Standard_D2s_v3" -> "Standard_D4s_v3" # forces replacement
}
Analysis:
-/+ resource "azurerm_storage_account" "main" {
~ name = "oldstorageaccount" -> "newstorageaccount" # forces replacement
}
Analysis:
# azurerm_network_interface.main must be replaced
-/+ resource "azurerm_network_interface" "main" {
...
}
# azurerm_linux_virtual_machine.main must be replaced
# (because azurerm_network_interface.main must be replaced)
-/+ resource "azurerm_linux_virtual_machine" "main" {
...
}
Analysis:
❌ Dangerous:
-/+ resource "azurerm_mssql_database" "main" {
~ name = "olddb" -> "newdb" # forces replacement
}
Warning: Database will be deleted with all data!
✅ Safe alternative: Backup, migrate, then recreate
❌ Causes downtime:
-/+ resource "azurerm_linux_virtual_machine" "main" {
~ vm_size = "Standard_D2s_v3" -> "Standard_D4s_v3"
}
Warning: VM will be recreated
✅ Safe alternative: Use blue-green deployment
❌ Can break connectivity:
~ resource "azurerm_network_security_group" "main" {
- security_rule {
- access = "Allow" -> null
- destination_address_prefix = "*" -> null
- destination_port_range = "443" -> null
}
}
Warning: Removing security rules may break access
❌ Risk of data loss:
- resource "azurerm_storage_container" "data" {
- name = "important-data" -> null
}
Warning: Container and all blobs will be deleted!
When analyzing a plan, provide:
Terraform Plan Analysis
=======================
Summary:
Resources to Add: {count}
Resources to Change: {count}
Resources to Destroy: {count}
Impact Assessment:
High Impact: {count} changes
Medium Impact: {count} changes
Low Impact: {count} changes
Risk Level: {CRITICAL|HIGH|MEDIUM|LOW}
Critical Warnings:
⚠ {warning}
⚠ {warning}
Resource Breakdown:
CREATE:
+ azurerm_resource_group.new
+ azurerm_storage_account.new
UPDATE IN-PLACE:
~ azurerm_storage_account.existing
- Tags update (low risk)
REPLACE (DESTROY + CREATE):
-/+ azurerm_linux_virtual_machine.main
! WARNING: This will cause downtime
! Reason: VM size change forces replacement
DESTROY:
- azurerm_resource_group.old
! WARNING: All resources in this group will be deleted
Cost Impact:
Estimated Monthly Change: +$150
New Resources: +$200
Removed Resources: -$50
Recommendations:
1. Backup database before applying
2. Schedule change during maintenance window
3. Notify stakeholders of planned downtime
4. Consider blue-green deployment for VM
Approval Required: YES (due to destructive changes)
If scripts/plan-analyzer.js exists, use it:
# Analyze plan file
node scripts/plan-analyzer.js --plan plan.json --report full
# Check for breaking changes
node scripts/plan-analyzer.js --plan plan.json --check-breaking
# Estimate cost impact
node scripts/plan-analyzer.js --plan plan.json --cost-analysis
# Generate approval request
node scripts/plan-analyzer.js --plan plan.json --approval-report
name: Terraform Plan Analysis
on:
pull_request:
paths:
- '**.tf'
jobs:
plan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Terraform Plan
run: |
terraform init
terraform plan -out=tfplan
terraform show -json tfplan > plan.json
- name: Analyze Plan
run: |
node .codex/skills/terraform-plan-analyzer/scripts/plan-analyzer.js \
--plan plan.json \
--report full > plan-analysis.md
- name: Comment on PR
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const analysis = fs.readFileSync('plan-analysis.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: analysis
});
# Generate plan history
terraform plan -out=tfplan-$(date +%Y%m%d-%H%M%S)
terraform show -json tfplan-* > plan-history.json
# Compare changes
node scripts/plan-analyzer.js --compare plan-old.json plan-new.json
# Generate plan without actually planning
terraform plan -refresh-only -out=refresh.tfplan
# Analyze drift
node scripts/plan-analyzer.js --plan refresh.tfplan --detect-drift
# Analyze specific resource
terraform plan -target=azurerm_resource_group.main
Before approving a plan:
Q: Why is this resource being replaced? A: Look for "forces replacement" comments. Common reasons:
Q: Can I prevent replacement? A: Sometimes:
lifecycle { prevent_destroy = true } to blockQ: What does "(known after apply)" mean? A: The value will be determined when the resource is created/updated. Common for:
Q: How do I estimate costs? A: Use:
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.