All Tools View Categories About Contact Privacy

Terraform pre-commit Config Generator

Build a .pre-commit-config.yaml with Terraform fmt, validate, docs, tflint and tfsec hooks.

Runs entirely in your browser - nothing is uploaded and no cloud connection is made.
Your generated .pre-commit-config.yaml will appear here.

About Terraform pre-commit Config Generator

pre-commit keeps Terraform formatted and validated before code is committed, catching style and correctness problems locally instead of failing later in CI. The Terraform pre-commit Config Generator scaffolds a .pre-commit-config.yaml with the popular antonbabenko/pre-commit-terraform hooks plus the standard pre-commit-hooks so you do not have to hand-write the YAML. Select the hooks you want, pin a revision, set fail_fast, and export a ready-to-use configuration. Everything runs in your browser, so nothing is uploaded and you can iterate on the file instantly. This is perfect for teams onboarding new repositories, for template authors who ship starter repos, and for anyone who wants a reproducible formatting and validation gate without reading the pre-commit documentation end to end. The generated file follows the exact schema the pre-commit framework expects, so it works with a plain install and a single pre-commit install command in your checkout. Because the hooks run on every commit, trivial formatting drift and obvious security mistakes are caught by the author rather than by a shared pipeline, which keeps main branches cleaner. The generator also includes the generic hooks that apply to every repository, not only Terraform, so you get a complete baseline configuration from a single screen. The tool is especially useful inside platform engineering because it encodes a known-good baseline that every team can adopt without debate. You can also diff two generated configs to see what changed when you bump the pinned revision, which makes upgrading hooks a deliberate, reviewable step rather than a surprise. Keeping the configuration in version control means the exact set of controls is auditable and reversible, which auditors and senior engineers both appreciate.

Features

  • Terraform hooks - fmt, validate, docs, tflint, tfsec and checkov, each toggleable.
  • Generic hooks - trailing-whitespace, end-of-file-fixer and check-merge-conflict.
  • Pinned revision - set a specific antonbabenko tag for reproducible CI runs.
  • fail_fast - stop at the first failing hook when enabled.
  • Markdown export - copy the config as a fenced markdown code block for documentation.
  • Copy, Download, Print - export the YAML wherever you need it.
  • Private - all assembly happens locally in the browser.
  • Hook ordering - Terraform hooks are listed before generic hooks so formatting runs first.
  • Repository isolation - each repo gets its own pinned config, avoiding drift between teams.
  • Clear labels - every control is named so engineers understand what runs on commit.
  • Revision awareness - bumping the pinned tag is a single-field change you review in git.

How to Use

  1. Open the tool and find the revision and hook panel on the left side of the page.
  2. Set a revision for antonbabenko/pre-commit-terraform, for example v1.92.0, to pin the hook versions.
  3. Select Terraform hooks by ticking the ones you want, such as terraform_fmt and terraform_validate.
  4. Toggle fail_fast if you want pre-commit to stop at the first failure.
  5. Load a sample to prefill a sensible default set of hooks and a revision.
  6. Generate config to assemble the .pre-commit-config.yaml output.
  7. Export by copying, downloading, printing, or copying as Markdown.
  8. Commit the file as .pre-commit-config.yaml at the repository root and run pre-commit install.
  9. Review the output in the preview pane and confirm the selected hooks match your policy.
  10. Tune over time - revisit the revision and hooks as your standards evolve.
  11. Share the result - paste the Markdown copy into a runbook or onboarding doc.

Examples

Example 1 - minimal - rev v1.92.0 with terraform_fmt and terraform_validate produces a two-hook config plus the generic hooks.

Example 2 - hardened - enabling terraform_tflint, terraform_tfsec and terraform_checkov together with fail_fast yields a security-focused gate that fails fast on the first problem it finds.

Example 3 - docs only - selecting only terraform_docs generates a config that keeps module READMEs in sync automatically on each commit. Each example reflects a common real-world policy, so the generated file is a safe starting point you can trim to taste.

Benefits

  • Consistent code - formatting and validation are enforced before merge.
  • Safer changes - security and lint scans run on every commit.
  • Reproducible - pinned revisions keep CI behavior stable over time.
  • Private - runs fully in the browser with no upload.
  • Portable - the generated YAML drops straight into any repository.
  • Cleaner history - auto-fixed formatting means fewer noisy diffs during review.
  • Onboarding speed - new repos get a proven gate in seconds, not days of setup.
  • Reviewable upgrades - a one-line revision bump keeps hook changes visible in pull requests.

Frequently Asked Questions

What does this tool generate?
It builds a .pre-commit-config.yaml wiring the antonbabenko/pre-commit-terraform hooks plus common pre-commit-hooks (trailing-whitespace, end-of-file-fixer, check-merge-conflict).
Which Terraform hooks are available?
terraform_fmt, terraform_validate, terraform_docs, terraform_tflint, terraform_tfsec and terraform_checkov. Select the ones you want.
What revision should I use?
Use a pinned tag of antonbabenko/pre-commit-terraform, e.g. v1.92.0. Pinning keeps CI reproducible.
What is fail_fast?
When true, pre-commit stops at the first failing hook instead of running all of them.
Does this upload anything?
No. Everything is assembled in your browser and nothing leaves your machine.
Can I download the result?
Yes. Copy .pre-commit-config.yaml, download it, or print it.