Terraform Best Practices logo

Terraform Best Practices

Organization
terramate-io
terraform-best-practices

Terraform and Infrastructure as Code optimization guidelines from Terramate. This skill should be used when writing, reviewing, or refactoring Terraform/OpenTofu code to ensure optimal patterns for security, maintainability, and reliability. Triggers on tasks involving Terraform modules, infrastructure provisioning, state management, or IaC optimization.

Overview

Publisherterramate-io
Repositoryagent-skills
Skill nameterraform-best-practices
Stars
35
Forks
0
Bundled files
38
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 38 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by terramate-io on GitHub. Read the source before you install it.

Installation

Install the Terraform Best Practices AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/terramate-io/agent-skills/tree/main/skills/terraform-best-practices
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/terramate-io/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/terraform-best-practices .claude/skills/terraform-best-practices
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Terraform Best Practices in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Terraform Best Practices on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Terraform Best Practices is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Terraform Best Practices

Comprehensive optimization guide for Terraform and Infrastructure as Code, maintained by Terramate. Contains 37 rules across 10 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Writing new Terraform modules or configurations
  • Implementing infrastructure patterns (AWS, GCP, Azure, etc.)
  • Reviewing code for security and reliability issues
  • Refactoring existing Terraform/OpenTofu code
  • Optimizing state management and performance
  • Setting up team workflows and governance

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Organization & WorkflowCRITICALorg-
2State ManagementCRITICALstate-
3Security Best PracticesCRITICALsecurity-
4Module DesignHIGHmodule-
5Resource OrganizationMEDIUM-HIGHresource-
6Variable & Output PatternsMEDIUMvariable-, output-
7Language Best PracticesMEDIUMlanguage-
8Provider ConfigurationMEDIUMprovider-
9Performance OptimizationLOW-MEDIUMperf-
10Testing & ValidationLOWtest-

Quick Reference

1. Organization & Workflow (CRITICAL) - 5 rules

  • org-version-control - All Terraform code in version control
  • org-workspaces - One workspace per environment per configuration
  • org-access-control - Control who can change what infrastructure
  • org-change-workflow - Formal process for infrastructure changes
  • org-audit-logging - Track all infrastructure changes

2. State Management (CRITICAL) - 3 rules

  • state-remote-backend - Always use remote state backends
  • state-locking - Enable state locking to prevent corruption
  • state-import - Import existing infrastructure into Terraform

3. Security Best Practices (CRITICAL) - 3 rules

  • security-no-hardcoded-secrets - Never hardcode secrets in code
  • security-credentials - Use proper credential management (OIDC, Vault, IAM roles)
  • security-iam-least-privilege - Follow least privilege principle

4. Module Design (HIGH) - 5 rules

  • module-single-responsibility - One module per logical component
  • module-naming - Use consistent naming conventions (terraform--)
  • module-versioning - Version all module references
  • module-composition - Compose modules like building blocks
  • module-registry - Use existing community/shared modules

5. Resource Organization (MEDIUM-HIGH) - 5 rules

  • resource-naming - Use consistent naming conventions
  • resource-tagging - Tag all resources for cost tracking
  • resource-lifecycle - Use lifecycle blocks (prevent_destroy, ignore_changes)
  • resource-count-vs-foreach - Prefer for_each over count
  • resource-immutable - Prefer immutable infrastructure patterns

6. Variable & Output Patterns (MEDIUM) - 6 rules

  • variable-types - Use specific types, positive naming, nullable
  • variable-validation - Add validation rules for early error detection
  • variable-sensitive - Mark secrets as sensitive, no defaults
  • variable-descriptions - Document all variables with descriptions
  • output-descriptions - Document all outputs with descriptions
  • output-no-secrets - Never output secrets directly

7. Language Best Practices (MEDIUM) - 5 rules

  • language-no-heredoc-json - Use jsonencode/yamlencode, not HEREDOC
  • language-locals - Use locals to name complex expressions
  • language-linting - Run terraform fmt and tflint
  • language-data-sources - Use data sources instead of hardcoding
  • language-dynamic-blocks - Use dynamic blocks for DRY code

8. Provider Configuration (MEDIUM) - 1 rule

  • provider-version-constraints - Pin provider versions

9. Performance Optimization (LOW-MEDIUM) - 2 rules

  • perf-parallelism - Tune parallelism for large deployments
  • perf-debug - Enable debug logging for troubleshooting

10. Testing & Validation (LOW) - 2 rules

  • test-strategies - Testing pyramid (validate, lint, plan, integration)
  • test-policy-as-code - Implement policy checks (OPA, Checkov, tfsec)

How to Use

Read individual rule files for detailed explanations and code examples:

rules/state-remote-backend.md
rules/security-no-hardcoded-secrets.md
rules/module-versioning.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Terraform Best Practices AI skill do?

Terraform and Infrastructure as Code optimization guidelines from Terramate. This skill should be used when writing, reviewing, or refactoring Terraform/OpenTofu code to ensure optimal patterns for security, maintainability, and reliability. Triggers on tasks involving Terraform modules, infrastructure provisioning, state management, or IaC optimization.

Why use Terraform Best Practices on TypingMind?

Because you install it once and use it with any model. Terraform Best Practices is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Terraform Best Practices in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/terramate-io/agent-skills/tree/main/skills/terraform-best-practices. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Terraform Best Practices?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Terraform Best Practices?

As many as you like. As long as a model supports skills, you can use Terraform Best Practices with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Terraform Best Practices AI skill free?

Yes. It is published on GitHub by terramate-io under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇