Skip to content
Back to skills

Opentofu Patterns

ASecurity

OpenTofu and Terraform patterns - config-driven refactoring (moved, import, removed), for_each vs count, variables and secrets in state, version pinning and the lock file, fmt/validate in CI, and review-time anti-patterns. Use whenever the project contains `.tf`/`.tfvars` files or a `.terraform.lock.hcl`, OR the user asks about OpenTofu, Terraform, HCL, state, providers, or modules, even if neither tool is mentioned by name.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 5, 2026
ai-agentsterraformrefactoringgit

Works with

  • cli

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned October 7, 2026

npx -y skills add ku5ic/claude-kit --skill opentofu-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Opentofu Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Opentofu Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ku5ic-opentofu-patterns/badge)](https://www.skillsdirectory.com/skills/ku5ic-opentofu-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: opentofu-patterns
description: OpenTofu and Terraform patterns - config-driven refactoring (moved, import, removed), for_each vs count, variables and secrets in state, version pinning and the lock file, fmt/validate in CI, and review-time anti-patterns. Use whenever the project contains `.tf`/`.tfvars` files or a `.terraform.lock.hcl`, OR the user asks about OpenTofu, Terraform, HCL, state, providers, or modules, even if neither tool is mentioned by name.
---

# OpenTofu patterns

Default assumption: OpenTofu 1.12. Most rules hold for Terraform too, since the language is shared.

- Features marked "OpenTofu 1.11+" or "1.12+" are OpenTofu releases; check Terraform's own docs before using one in a Terraform project.
- Adapt advice to `required_version` in the project's `versions.tf` (or wherever the `terraform {}` block lives) and to which CLI the project runs (`tofu` or `terraform`).

## Reference files

| File                                                                     | Covers                                                                               |
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| [reference/refactoring-and-state.md](reference/refactoring-and-state.md) | `moved`, `import`, `removed` blocks, `lifecycle`, what state holds                   |
| [reference/configuration.md](reference/configuration.md)                 | `for_each` vs `count`, `enabled`, variables, pinning and the lock file, provisioners |
| [reference/workflow.md](reference/workflow.md)                           | `fmt` and `validate` in checks, and what the kit's guard blocks                      |
| [reference/anti-patterns.md](reference/anti-patterns.md)                 | Seven review-time anti-patterns with severity calls                                  |

## References

- OpenTofu docs: https://opentofu.org/docs/
- What's new in OpenTofu: https://opentofu.org/docs/intro/whats-new/
- Terraform language docs: https://developer.hashicorp.com/terraform/language

## Version notes

Checked: 2026-09-26 against https://opentofu.org/docs and the GitHub releases of opentofu/opentofu and hashicorp/terraform

- OpenTofu 1.12.6 (2026-08-19); 1.12: `lifecycle { destroy = false }`, and `prevent_destroy` may refer to variables. 1.13.0-rc1 (2026-09-17) is a release candidate, not covered.
- OpenTofu 1.11: the `enabled` meta-argument, ephemeral resources, variables and outputs, and write-only attributes.
- Terraform 1.16.4 (2026-09-23), for reference only.

Files in this skill

  • SKILL.md2.6 KB
  • reference/anti-patterns.md2 KB
  • reference/configuration.md1.9 KB
  • reference/refactoring-and-state.md2.4 KB
  • reference/workflow.md920 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.