Skip to content
Skillpedia
Deploy & cloud (DevOps)29k Β· #9612

terraform-patterns

What it does

This skill helps write and review Terraform code, which defines cloud infrastructure in files. It is for engineers who manage infrastructure and want safer, cleaner configuration.

When to use it

  • βœ“When you are reviewing Terraform files for mistakes or bad structure.
  • βœ“When you are designing a reusable Terraform module.
  • βœ“When you want a security review of infrastructure code before changes.

Skill link

https://github.com/alirezarezvani/claude-skills/blob/main/engineering/terraform-patterns/skills/terraform-patterns/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/alirezarezvani/claude-skills/blob/main/engineering/terraform-patterns/skills/terraform-patterns/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œReview my Terraform files for security problems and bad patterns before I apply them.”

5 new skills a week. 1 minute to read.

How it works

It analyzes module structure and scans the configuration for misconfigurations and exposed secrets, then suggests fixes.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Terraform Patterns

Predictable infrastructure. Secure state. Modules that compose. No drift.

Opinionated Terraform workflow that turns sprawling HCL into well-structured, secure, production-grade infrastructure code. Covers module design, state management, provider patterns, security hardening, and CI/CD integration.

Not a Terraform tutorial β€” a set of concrete decisions about how to write infrastructure code that doesn't break at 3 AM.


Slash Commands

Command What it does
/terraform-patterns review Analyze Terraform code for anti-patterns, security issues, and structure problems
/terraform-patterns module Design or refactor a Terraform module with proper inputs, outputs, and composition
/terraform-patterns security Audit Terraform code for security vulnerabilities, secrets exposure, and IAM misconfigurations

When This Skill Activates

Recognize these patterns from the user:

  • "Review this Terraform code"
  • "Design a Terraform module for..."
  • "My Terraform state is..."
  • "Set up remote state backend"
  • "Multi-region Terraform deployment"
  • "Terraform security review"
  • "Module structure best practices"
  • "Terraform CI/CD pipeline"
  • Any request involving: .tf files, HCL, Terraform modules, state management, provider configuration, infrastructure-as-code

If the user has .tf files or wants to provision infrastructure with Terraform β†’ this skill applies.


Workflow

/terraform-patterns review β€” Terraform Code Review

  1. Analyze current state

    • Read all .tf files in the target directory
    • Identify module structure (flat vs nested)
    • Count resources, data sources, variables, outputs
    • Check naming conventions
  2. Apply review checklist

    MODULE STRUCTURE
    β”œβ”€β”€ Variables have descriptions and type constraints
    β”œβ”€β”€ Outputs expose only what consumers need
    β”œβ”€β”€ Resources use consistent naming: {provider}_{type}_{purpose}
    β”œβ”€β”€ Locals used for computed values and DRY expressions
    └── No hardcoded values β€” everything parameterized or in locals
    
    STATE & BACKEND
    β”œβ”€β”€ Remote backend configured (S3, GCS, Azure Blob, Terraform Cloud)
    β”œβ”€β”€ State locking enabled (DynamoDB for S3, native for others)
    β”œβ”€β”€ State encryption at rest enabled
    β”œβ”€β”€ No secrets stored in state (or state access is restricted)
    └── Workspaces or directory isolation for environments
    
    PROVIDERS
    β”œβ”€β”€ Version constraints use pessimistic operator: ~> 5.0
    β”œβ”€β”€ Required providers block in terraform {} block
    β”œβ”€β”€ Provider aliases for multi-region or multi-account
    └── No provider configuration in child modules
    
    SECURITY
    β”œβ”€β”€ No hardcoded secrets, keys, or passwords
    β”œβ”€β”€ IAM follows least-privilege principle
    β”œβ”€β”€ Encryption enabled for storage, databases, secrets
    β”œβ”€β”€ Security groups are not overly permissive (no 0.0.0.0/0 ingress on sensitive ports)
    └── Sensitive variables marked with sensitive = true
    
  3. Generate report

    python3 scripts/tf_module_analyzer.py ./terraform
    
  4. Run security scan

    python3 scripts/tf_security_scanner.py ./terraform
    

/terraform-patterns module β€” Module Design

  1. Identify module scope

    • Single responsibility: one module = one logical grouping
    • Determine inputs (variables), outputs, and resource boundaries
    • Decide: flat module (single directory) vs nested (calling child modules)
  2. Apply module design checklist

    STRUCTURE
    β”œβ”€β”€ main.tf        β€” Primary resources
    β”œβ”€β”€ variables.tf   β€” All input variables with descriptions and types
    β”œβ”€β”€ outputs.tf     β€” All outputs with descriptions
    β”œβ”€β”€ versions.tf    β€” terraform {} block with required_providers
    β”œβ”€β”€ locals.tf      β€” Computed values and naming conventions
    β”œβ”€β”€ data.tf        β€” Data sources (if any)
    └── README.md      β€” Usage examples and variable documentation
    
    VARIABLES
    β”œβ”€β”€ Every variable has: description, type, validation (where applicable)
    β”œβ”€β”€ Sensitive values marked: sensitive = true
    β”œβ”€β”€ Defaults provided for optional settings
    β”œβ”€β”€ Use object types for related settings: variable "config" { type = object({...}) }
    └── Validate with: validation { condition = ... }
    
    OUTPUTS
    β”œβ”€β”€ Output IDs, ARNs, endpoints β€” things consumers need
    β”œβ”€β”€ Include description on every output
    β”œβ”€β”€ Mark sensitive outputs: sensitive = true
    └── Don't output entire resources β€” only specific attributes
    
    COMPOSITI
    
FAQ

Does it cover remote state?

Yes, it includes setting up a remote state backend.

Does it run terraform apply for me?

No, it reviews and suggests changes; you run your own deploy steps.

Which clouds does it cover?

It covers general Terraform patterns, including provider setup, IAM and multi-region setups.

Details

Original description by the author

Use for any Terraform module, state backend, provider setup or IaC security review, before editing .tf files. Analyzes modules with tf_module_analyzer.py and scans for misconfigurations with tf_security_scanner.py.

repo: alirezarezvani/claude-skills

Popularity

GitHub stars
29k
Ranking position
#9612
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills