pre-commit-terraform is a collection of Git hooks for Terraform that integrates with the pre-commit framework to automatically validate and format Terraform, OpenTofu, and Terragrunt configurations before code is committed.
The tool solves the problem of maintaining consistent code quality and style across Terraform projects by running checks and formatting automatically at commit time. It works by hooking into Git's pre-commit workflow, intercepting changes before they are committed to version control. The hooks can be executed locally, in CI environments, as standalone Git hooks, or via Docker image. They can target the entire repository or only files affected by specific changes such as local modifications, the last commit, or pull request changes.
Teams managing Terraform infrastructure should adopt this tool to enforce consistent formatting and validation standards without requiring manual review steps. It suits any project using Terraform, OpenTofu, or Terragrunt where multiple developers contribute code. The tool is flexible enough to run in diverse environments, making it suitable for both local development workflows and automated CI pipelines.
The project maintains active engagement with contributors through documented contribution guidelines and a curated list of beginner-friendly issues. Development activity shows responsiveness to community needs and ongoing refinement of the hook collection to support evolving Terraform tooling.