Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Specialized skill for analyzing Terraform configurations. Supports parsing, security scanning (tfsec, checkov), cost estimation (infracost), drift detection, and plan visualization across AWS, Azure, and GCP.
.claude/skills/a5c-ai-terraform-analyzer/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 109% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 87% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 65% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 156% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 84% | 0% |
You are terraform-analyzer - a specialized skill for analyzing Terraform configurations and Infrastructure as Code. This skill enables AI-powered infrastructure analysis for security, cost, and compliance.
This skill enables comprehensive Terraform analysis including:
Parse and analyze Terraform configurations:
hcl# Example configuration being analyzed resource "aws_instance" "web" { ami = var.ami_id instance_type = var.instance_type vpc_security_group_ids = [aws_security_group.web.id] subnet_id = aws_subnet.private.id root_block_device { volume_size = 100 volume_type = "gp3" encrypted = true } tags = { Name = "web-server" Environment = var.environment } } resource "aws_security_group" "web" { name = "web-sg" description = "Security group for web servers" vpc_id = aws_vpc.main.id ingress { from_port = 443 to_port = 443 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] # Security finding: open to world } egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } }
bash# Run tfsec security scan tfsec . --format json --out tfsec-report.json # Example findings { "results": [ { "rule_id": "aws-vpc-no-public-ingress-sgr", "severity": "CRITICAL", "description": "Security group rule allows ingress from public internet", "resource": "aws_security_group.web", "location": { "filename": "security.tf", "start_line": 15 }, "resolution": "Restrict ingress to specific CIDR blocks" } ] }
bash# Run Checkov security and compliance scan checkov -d . --output json > checkov-report.json # Example findings { "passed": 45, "failed": 3, "skipped": 0, "results": { "failed_checks": [ { "check_id": "CKV_AWS_23", "check_name": "Ensure every security groups rule has a description", "resource": "aws_security_group.web", "guideline": "https://docs.bridgecrew.io/docs/..." }, { "check_id": "CKV_AWS_24", "check_name": "Ensure no security groups allow ingress from 0.0.0.0:0 to port 22", "resource": "aws_security_group.web" } ] } }
bash# Run Terrascan policy scan terrascan scan -d . -o json > terrascan-report.json
Using Infracost for cost analysis:
bash# Generate cost breakdown infracost breakdown --path . --format json > cost-report.json # Example output { "version": "0.2", "currency": "USD", "projects": [ { "name": "production", "breakdown": { "resources": [ { "name": "aws_instance.web", "monthlyQuantity": 730, "unit": "hours", "hourlyRate": "0.0416", "monthlyCost": "30.37" }, { "name": "aws_ebs_volume.data", "monthlyQuantity": 100, "unit": "GB", "monthlyCost": "10.00" } ], "totalMonthlyCost": "540.37", "totalHourlyCost": "0.74" } } ], "totalMonthlyCost": "540.37" }
Detect configuration drift:
bash# Refresh and check for drift terraform plan -refresh-only -json > drift-report.json # Example drift detection { "resource_drift": [ { "resource": "aws_instance.web", "address": "aws_instance.web", "changes": { "before": { "instance_type": "t3.medium" }, "after": { "instance_type": "t3.large" }, "drift_reason": "Manual change via console" } } ], "summary": { "total_resources": 45, "drifted_resources": 1, "unchanged_resources": 44 } }
Analyze and visualize Terraform plans:
bash# Generate plan terraform plan -out=tfplan terraform show -json tfplan > plan.json # Plan analysis output { "format_version": "1.0", "resource_changes": [ { "address": "aws_instance.web", "mode": "managed", "type": "aws_instance", "name": "web", "change": { "actions": ["update"], "before": { "instance_type": "t3.small" }, "after": { "instance_type": "t3.medium" } } } ], "summary": { "add": 2, "change": 1, "destroy": 0 } }
Analyze Terraform module structure:
javascript// Module dependency analysis { "modules": { "root": { "path": ".", "source": "local", "version": null, "dependencies": ["./modules/vpc", "./modules/compute"] }, "vpc": { "path": "./modules/vpc", "source": "local", "resources": ["aws_vpc", "aws_subnet", "aws_route_table"] }, "compute": { "path": "./modules/compute", "source": "local", "resources": ["aws_instance", "aws_autoscaling_group"], "depends_on": ["vpc"] } }, "external_modules": [ { "source": "terraform-aws-modules/vpc/aws", "version": "5.0.0", "registry": "registry.terraform.io" } ] }
Check compliance with organizational policies:
yaml# Policy definition policies: - name: require-encryption description: All storage must be encrypted resource_types: [aws_ebs_volume, aws_rds_instance, aws_s3_bucket] rules: - attribute: encrypted value: true - attribute: storage_encrypted value: true - name: require-tags description: All resources must have required tags rules: - attribute: tags contains: [Environment, Owner, CostCenter] - name: restrict-instance-types description: Only allow approved instance types resource_types: [aws_instance] rules: - attribute: instance_type allowed_values: [t3.micro, t3.small, t3.medium, t3.large]
This skill can leverage the following MCP servers:
| Server | Description | Installation | |--------|-------------|--------------| | Terraform MCP Server (HashiCorp) | Official Terraform Registry integration | GitHub | | AWS Terraform MCP Server | Terraform with Checkov and AWS best practices | AWS Labs |
yamlworkflow: pre_commit: - terraform fmt -check - terraform validate - tfsec --minimum-severity HIGH ci_pipeline: - terraform init - terraform validate - tfsec --format sarif - checkov -d . --output sarif - infracost breakdown --path . pre_deploy: - terraform plan -out=tfplan - infracost diff --path tfplan - manual_review_required: true
yamlsecurity_thresholds: tfsec: max_critical: 0 max_high: 0 max_medium: 5 checkov: min_passed_percentage: 90 infracost: max_monthly_increase_percentage: 20 require_approval_above: 1000 # USD
This skill integrates with the following processes:
iac-review.js - Primary IaC analysis workflowcloud-architecture-design.js - Architecture validationdevops-architecture-alignment.js - DevOps integrationWhen analyzing configurations, provide structured output:
json{ "operation": "analyze", "status": "completed", "configuration": { "path": "./infrastructure", "provider": "aws", "resources": 45, "modules": 5 }, "security": { "tool": "tfsec", "findings": { "critical": 0, "high": 2, "medium": 5, "low": 8 }, "passed": true, "threshold_exceeded": false }, "compliance": { "tool": "checkov", "passed": 42, "failed": 3, "skipped": 0, "passed_percentage": 93.3 }, "cost": { "tool": "infracost", "monthly_estimate": "$540.37", "hourly_estimate": "$0.74", "change_from_baseline": "+$45.00" }, "drift": { "detected": true, "resources_drifted": 1, "total_resources": 45 }, "artifacts": [ "tfsec-report.json", "checkov-report.json", "cost-report.json" ], "recommendations": [ { "priority": "high", "category": "security", "description": "Restrict security group ingress rules", "resource": "aws_security_group.web" } ] }
| Error | Cause | Resolution | |-------|-------|------------| | Provider not configured | Missing credentials | Configure provider credentials | | Module not found | Invalid source path | Check module source configuration | | State lock error | Concurrent access | Wait or force unlock | | Validation failed | Invalid HCL syntax | Fix syntax errors |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 25,801 | 22,382 | -13% | 1 | 1 | 0% | 5,624 | 6,834 | +22% | 0 | 0 | — |
case-02 | fail→pass | 21,026 | 15,783 | -25% | 1 | 1 | 0% | 2,277 | 4,748 | +109% | 0 | 0 | — |
case-03 | fail→fail | 22,794 | 11,474 | -50% | 1 | 1 | 0% | 4,835 | 5,366 | +11% | 0 | 0 | — |
case-04 | pass→pass | 12,443 | 23,047 | +85% | 1 | 1 | 0% | 2,851 | 7,143 | +151% | 0 | 0 | — |
case-05 | pass→pass | 18,720 | 21,468 | +15% | 1 | 1 | 0% | 2,769 | 6,375 | +130% | 0 | 0 | — |
case-06 | pass→pass | 20,907 | 14,875 | -29% | 1 | 1 | 0% | 2,865 | 4,913 | +71% | 0 | 0 | — |
case-07 | fail→pass | 12,178 | 6,068 | -50% | 1 | 1 | 0% | 2,167 | 4,044 | +87% | 0 | 0 | — |
case-08 | pass→pass | 32,570 | 8,659 | -73% | 1 | 1 | 0% | 1,947 | 3,562 | +83% | 0 | 0 | — |
case-09 | fail→pass | 18,011 | 8,743 | -51% | 1 | 1 | 0% | 2,115 | 3,490 | +65% | 0 | 0 | — |
case-10 | fail→pass | 27,184 | 12,009 | -56% | 1 | 1 | 0% | 1,667 | 4,268 | +156% | 0 | 0 | — |
case-11 | fail→pass | 12,566 | 10,340 | -18% | 1 | 1 | 0% | 2,119 | 3,896 | +84% | 0 | 0 | — |
case-12 | fail→pass | 20,804 | 18,399 | -12% | 1 | 1 | 0% | 2,768 | 5,465 | +97% | 0 | 0 | — |
case-13 | fail→fail | 18,444 | 16,407 | -11% | 1 | 1 | 0% | 2,281 | 5,032 | +121% | 0 | 0 | — |
case-14 | pass→fail | 11,857 | 7,599 | -36% | 1 | 1 | 0% | 1,276 | 3,391 | +166% | 0 | 0 | — |
case-15 | pass→pass | 12,166 | 13,434 | +10% | 1 | 1 | 0% | 1,257 | 4,533 | +261% | 0 | 0 | — |
case-16 | fail→pass | 16,345 | 11,294 | -31% | 1 | 1 | 0% | 1,867 | 4,726 | +153% | 0 | 0 | — |
case-17 | fail→pass | 14,234 | 13,869 | -3% | 1 | 1 | 0% | 2,113 | 4,361 | +106% | 0 | 0 | — |
case-18 | fail→pass | 17,073 | 6,542 | -62% | 1 | 1 | 0% | 2,402 | 3,708 | +54% | 0 | 0 | — |
case-19 | fail→pass | 15,351 | 2,431 | -84% | 1 | 1 | 0% | 1,759 | 3,411 | +94% | 0 | 0 | — |
case-20 | pass→pass | 9,334 | 8,260 | -12% | 1 | 1 | 0% | 753 | 3,516 | +367% | 0 | 0 | — |
case-21 | pass→pass | 17,639 | 14,823 | -16% | 1 | 1 | 0% | 2,283 | 4,767 | +109% | 0 | 0 | — |
case-22 | pass→pass | 18,069 | 15,900 | -12% | 1 | 1 | 0% | 2,242 | 4,983 | +122% | 0 | 0 | — |
case-23 | fail→pass | 8,826 | 8,642 | -2% | 1 | 1 | 0% | 1,480 | 3,589 | +143% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +43 percentage points is the difference between those two pass rates over the 23 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.