# HCP Terraform: speculative plans and cost estimation on every PR

## Why

A PR that changes Terraform without a plan is a PR nobody actually reviewed. VCS-connected workspaces run speculative plans automatically: full plans against the PR branch that never touch state and never apply. With cost estimation enabled, the PR also shows the projected cost delta.

## How

1. Connect the workspace to the VCS repo. Set the Terraform working directory if the config is not at the repo root.
2. Enable speculative plans on pull requests in the workspace VCS settings. Every PR gets a plan run linked as a status check.
3. Enable cost estimation if the plan includes supported resources. The run shows added/changed cost per resource.
4. Require the plan status check to pass before merge, the same way you require CI.

## Rules for agents

1. Speculative plans cannot apply and cannot write state. If a PR plan shows "would create" for resources that already exist, the config drifted from reality; fix the config or import, do not force-apply.
2. A speculative plan that fails to even plan is a broken PR. Do not merge around it.
3. Cost estimates cover supported resource types only. "No cost change shown" is not "free"; it can mean "unsupported resource".
4. Keep the working directory setting accurate. A workspace pointed at the wrong directory plans the wrong config and the PR check is meaningless.
