Stacks

Review a pull request in Terraform HCL with Atlas in 2026

Updated 7 min read

Atlas helps Terraform HCL developers review pull requests by fetching the branch, reading changed files in full, and using `lsp` to check for broken references, ensuring `terraform test` and `terraform fmt` are run, and validating the `terraform plan` output before any changes are applied in 2026.

How Atlas reviews Terraform HCL pull requests with full context

Atlas reviews Terraform HCL pull requests by first fetching the branch and producing a unified diff, then reading the full changed files, not just hunks. This approach, crucial in 2026, ensures that surrounding context outside the immediate diff is visible, helping catch bugs a line-by-line review would miss.

When reviewing a pull request in Terraform HCL, Atlas begins by using its VCS layer to fetch the relevant branch and generate a raw patch with the `bash` tool. Crucially, Atlas then employs its `read` tool to pull the complete content of the changed `.tf` files, rather than just the isolated diff hunks. This capability allows the agent to understand the full context of the modifications, providing a comprehensive view of how changes interact with existing Terraform HCL resources, variables, and outputs. By leaving the narrow scope of the diff, Atlas helps developers identify potential issues that might arise from changes in surrounding code, ensuring a more robust and thorough review process for your infrastructure as code.

How Atlas uses LSP to validate Terraform HCL changes

For every changed resource or variable signature in Terraform HCL, Atlas leverages its `lsp` tool to run `findReferences` operations. This critical step, especially important in 2026, identifies any callers that the diff never touched but might be broken by the change, preventing unexpected infrastructure failures.

Atlas enhances Terraform HCL pull request reviews by integrating its `lsp` tool to perform deep semantic analysis. For any modified resource, variable, or output signature within your `.tf` files, Atlas automatically executes `findReferences` operations. This process, powered by Atlas's AST declarations indexing using tree-sitter, goes beyond simple text matching to understand the structural relationships in your Terraform HCL code. It effectively checks whether a changed signature has inadvertently broken any callers or dependencies elsewhere in the codebase that were not directly part of the diff. This proactive validation helps catch subtle but critical bugs that could lead to broken infrastructure deployments, ensuring the integrity of your Terraform HCL modules and configurations.

Running Terraform HCL tests and formatting with Atlas

Atlas integrates directly with the Terraform HCL toolchain to run `terraform test` and `terraform fmt -recursive` as part of the pull request review process. In 2026, this ensures that all new or modified infrastructure code adheres to established testing standards and formatting conventions before merging.

As part of a comprehensive Terraform HCL pull request review, Atlas utilizes its `bash` tool to execute essential commands from the native Terraform HCL toolchain. This includes running `terraform test` within the `tests/` directory to validate the functionality and expected behavior of your infrastructure code. Atlas then reports any findings or failures from these tests as a `todowrite` list, ordered by severity, providing clear actionable feedback. Additionally, Atlas ensures code consistency by running `terraform fmt -recursive` across your project. This step automatically applies the standard Terraform HCL formatting, preventing style inconsistencies and making the codebase easier to read and maintain for all developers.

Safe Terraform HCL plan review and application with Atlas

Atlas prioritizes safety in Terraform HCL reviews by drafting a plan in a read-only agent and requiring explicit permission before executing any `terraform validate` or `terraform plan` commands. This permission-gated approach, vital in 2026, ensures you review the `plan diff` with Atlas before any infrastructure changes are applied.

The most dangerous part of Terraform HCL is not writing the resource block, but reading the plan it produces. Atlas addresses this by operating with a strong emphasis on safety and explicit permissions. Before any potentially destructive operations, Atlas drafts a plan in a read-only plan agent. Every Atlas tool call, including `terraform validate` and `terraform plan`, is permission-gated against allow, ask, and deny rules. You must explicitly grant permission for these commands to run. Once permitted, Atlas executes `terraform plan` and computes a unified diff for every file edit, surfacing it for your approval. This allows you to meticulously review the proposed infrastructure changes and their impact before Atlas switches to a build agent or writes anything, safeguarding your production environments.

Atlas's deep integration with the Terraform HCL ecosystem

Atlas is designed to operate within a root Terraform HCL module containing `.tf` files and a `.terraform.lock.hcl`, allowing it to read resources, variables, and pinned provider versions. This deep integration, essential for complex infrastructure in 2026, enables Atlas to suggest refactorings like extracting blocks into modules or adding `for_each` loops.

Atlas is built for Terraform HCL developers, understanding the nuances of the ecosystem. It expects to run in a root module containing `.tf` files and a `.terraform.lock.hcl`, which it uses to read your defined resources, variables, outputs, and the specific provider versions pinned in the lock file. This deep contextual awareness allows Atlas to not only review changes but also to offer intelligent suggestions. For instance, it can identify repeated blocks and ask to extract them into a reusable module, or suggest replacing counted resources with a more idiomatic `for_each` loop. Atlas also uses its `grep` tool to find patterns that should have been updated but were missed, such as old constant names or stale copies, ensuring comprehensive code hygiene within your Terraform HCL projects.

Step by step

  1. 01Use Atlas's VCS layer to fetch the pull request branch and generate the initial diff with `bash`.
  2. 02Instruct Atlas to `read` the full content of all changed `.tf` files, providing complete context beyond the diff hunks.
  3. 03For any modified resource or variable signatures, have Atlas's `lsp` tool run `findReferences` to detect breaking changes across the Terraform HCL codebase.
  4. 04Ask Atlas to `grep` for old constant names, stale copies, or feature flags that should have been updated but were missed in the Terraform HCL changes.
  5. 05Direct Atlas to execute `terraform test` using the `bash` tool within the `tests/` directory and report findings as a `todowrite` list.
  6. 06Allow Atlas to run `terraform validate` and `terraform plan` behind a permission prompt, then review the generated plan diff for potential infrastructure impacts.
  7. 07Finally, have Atlas run `terraform fmt -recursive` using `bash` to ensure all Terraform HCL files adhere to formatting standards.

Frequently asked questions

How does Atlas ensure I don't miss context in a Terraform HCL diff?
Atlas fetches the full changed `.tf` files using its `read` tool, rather than just showing diff hunks. This ensures you see all surrounding Terraform HCL code, helping identify subtle bugs that a line-by-line review might overlook.
Can Atlas check for breaking changes in Terraform HCL modules?
Yes, Atlas uses its `lsp` tool to perform `findReferences` operations on changed Terraform HCL resource or variable signatures. This identifies any callers in your codebase that might be broken, even if they weren't part of the original diff.
Does Atlas run `terraform test` automatically during a PR review?
Atlas can execute `terraform test` using its `bash` tool as part of the pull request review workflow. It reports any test failures or findings as a `todowrite` list, ensuring your Terraform HCL tests pass.
How does Atlas handle `terraform plan` reviews for safety?
Atlas runs `terraform plan` in a read-only agent and presents the plan diff for your approval. Every tool call is permission-gated, ensuring you explicitly allow `terraform validate` and `terraform plan` before any infrastructure changes are considered.
What Terraform HCL files does Atlas understand?
Atlas builds its code index using tree-sitter, understanding `.tf` files, variables, outputs, resources, and the provider versions pinned in your `.terraform.lock.hcl`. It operates effectively within a root Terraform HCL module.
Can Atlas help with Terraform HCL formatting?
Absolutely. Atlas integrates `terraform fmt -recursive` into its workflow using the `bash` tool, ensuring all your Terraform HCL code adheres to consistent formatting standards across the project.
How does Atlas integrate with the Terraform HCL module registry?
Atlas understands the module dependencies managed by `terraform init (module registry)`. It can suggest refactorings like extracting repeated blocks into new modules or using `for_each` for resource creation, leveraging its deep understanding of Terraform HCL.

Try Atlas in your terminal

The terminal-native AI coding agent. Free core, single binary.

Install Atlas

Related guides

Review a Pull Request with Atlas (2026 Workflow)

How to review a pull request with Atlas in 2026: bash produces the raw patch, read pulls whole files, the lsp tool's findReferences checks callers the diff never shows.

Add a Regression Test for a Terraform HCL Bug Fix with Atlas in 2026

Lock in Terraform HCL bug fixes with robust regression tests using Atlas. Learn how to write failing tests, apply fixes, and verify with `terraform test` and `terraform fmt`.

Research a Third-Party API Before Integrating it in Terraform HCL with Atlas in 2026

Terraform HCL developers in 2026 use Atlas to research third-party APIs, understand their shape, and safely integrate them. Atlas leverages websearch, webfetch, and guides you through writing, formatting with `terraform

Write Unit Tests for Untested Code in Terraform HCL with Atlas in 2026

In 2026, use Atlas to write robust unit tests for your Terraform HCL modules. Atlas leverages `terraform test` and existing repo conventions to ensure high-quality infrastructure code.

Upgrade a dependency and fix the breakage in Terraform HCL with Atlas in 2026

Effortlessly upgrade Terraform HCL module dependencies and resolve breaking changes with Atlas in 2026. Atlas drives `terraform init`, parses compiler output, and fixes code, ensuring your infrastructure code remains

Document a Terraform HCL Module with a README in 2026 using Atlas

In 2026, Atlas helps Terraform HCL developers generate accurate READMEs for modules, ensuring documentation reflects current code behavior, not outdated assumptions. Leverage `terraform init` and `terraform fmt` for a

Trace a runtime bug from a stack trace in Terraform HCL with Atlas in 2026

Pinpoint Terraform HCL runtime bugs from production stack traces using Atlas in 2026. Leverage Atlas's AI to navigate .tf files, terraform plan outputs, and terraform test to quickly identify and fix issues without a

Diagnose a hanging or long-running command in Terraform HCL with Atlas in 2026

In 2026, diagnose hanging or slow Terraform HCL commands with Atlas. Learn to identify if `terraform plan` or `terraform init` is blocked on input or genuinely slow, and get unstuck.

Browse this resource hub