Autocomplete
Shell autocomplete lets your terminal predict and complete Terraform commands, subcommands, and flags as you type. This reduces typos and speeds up workflows. Install autocomplete for your current shell with the installer:source ~/.bashrc or source ~/.zshrc) so the completion scripts take effect.
If you use Zsh, make sure you create or update
~/.zshrc instead of ~/.bashrc. Restart or reload your shell after installing autocomplete to enable completions.Built-in CLI help
Terraform’s CLI provides contextual, on-demand help for every command and flag. When you need quick guidance, use the global help or target a specific subcommand. General help:terraform plan does and lists all its available flags and options:
terraform --help or terraform <subcommand> --help for fast, accurate guidance in the terminal. For deeper examples, tutorials, and full reference material, consult the official documentation at developer.hashicorp.com/terraform.
Formatting code with terraform fmt
Terraform includesterraform fmt to reformat configuration files to a canonical, consistent style across your repository. Use it locally or in CI to enforce a shared style and make diffs easier to review.
Example resource before formatting:
terraform fmt in a directory to rewrite .tf files with Terraform’s canonical formatting:
terraform fmt -check in CI pipelines to fail the build when files are not formatted, ensuring contributors run the formatter before opening pull requests.

When adding
terraform fmt -check to CI, ensure contributors run terraform fmt locally (or integrate it into pre-commit hooks) to avoid blocking pull requests with formatting-only changes.Quick reference table
Summary
- Enable shell autocomplete with
terraform -install-autocompleteand reload your shell to speed up command entry and reduce errors. - Use
terraform --helpandterraform <subcommand> --helpfor fast, contextual, terminal-native documentation. - Use
terraform fmtandterraform fmt -recursiveto automatically format Terraform configuration files; addterraform fmt -checkto CI to enforce formatting standards.
Links and references
- Official Terraform documentation: https://developer.hashicorp.com/terraform
- Terraform CLI reference: https://developer.hashicorp.com/terraform/cli
- Pre-commit hooks for Terraform formatting: https://pre-commit.com/