Cost diff per pull request: showing the dollar delta of a change
A cost diff shows how much a pull request adds to or removes from your monthly bill, not just the total. Here is why the delta matters more than the absolute number, and how to compute and present it in CI.
Quick answer
A cost diff is the difference in monthly cost between a pull request and its base branch: it answers how much this change adds or saves, not what the whole stack costs. You compute it by pricing the plan for the base branch and the PR branch, then subtracting, and you present it in the PR comment as a signed delta broken down by resource. The delta is more useful than the total because reviewers can act on it: a plus 220 dollars a month line points straight at the resource that grew. The principle is review the change in dollars the same way you review the change in code.
When a reviewer reads a diff, they look at what changed, not the whole file. Cost should work the same way. A pull request that reports the stack costs 12,000 dollars a month tells a reviewer nothing about whether to approve. A pull request that reports this change adds 220 dollars a month, driven by a new read replica, is a decision they can make in seconds.
Delta versus total
| Signal | What it tells the reviewer |
|---|---|
| Total monthly cost | Size of the stack, not the change |
| Cost delta | What this PR adds or removes |
| Delta by resource | Which line drove the change |
The total is context; the delta is the decision. A large stack can absorb a small addition, and a small stack can be doubled by one careless line. Only the delta tells the reviewer which case they are in. So the primary number on a PR should be the signed monthly delta, with the total available as supporting context.
How to compute a cost diff
Price the base branch and the PR branch, then subtract. In practice CI checks out the base, runs a plan and prices it, checks out the PR, does the same, and reports the difference. A cost tool that understands the Terraform plan can do this in one step by comparing the two plans. Because pricing is static, driven by theplan JSON and a catalog, both estimates run without cloud credentials, so the whole diff computes in seconds inside the build.
Presenting the delta well
A good cost comment leads with the signed total delta, then lists the resources that changed with their individual deltas, so the reviewer sees plus 180 for the replica and plus 40 for the extra volume rather than a single opaque number. Sign matters: a PR that removes a NAT gateway should proudly show a negative delta. c3x posts exactly this breakdown on the GitHub or GitLab PR, so the dollar diff sits beside the code diff and reviewers weigh both together.
Using the delta in review
The delta turns cost into a normal review dimension. A reviewer who sees plus 500 a month on a change that was supposed to be a config tweak asks why, and usually finds an accidental instance-size bump or a duplicated resource. Over time the delta trains authors to check their own cost before pushing, because they know the number will appear. This is the same feedback loop that makesbudget guardrails effective, applied as information rather than a gate.
From diff to trend
Once every PR carries a delta, the sum of merged deltas over a sprint is a forecast of the bill's direction, earlier and more precise than the invoice. Teams that track merged cost deltas can see spend accelerating before it lands. Price your changes against theresource catalog so every delta a reviewer reads is grounded in real rates, not a guess.
FAQ
What is a cost diff for a pull request?
It is the difference in monthly cost between the pull request branch and its base branch, showing how much the change adds or removes rather than what the whole stack costs. Presented as a signed delta broken down by resource, it lets a reviewer see exactly which line drove the cost change and decide whether to approve, the same way they review the code diff.
Why is the cost delta better than the total?
Because the delta is the decision and the total is only context. A large stack can absorb a small addition while a small stack can be doubled by one line, and only the delta tells the reviewer which case they are in. Leading with the signed monthly delta, backed by a per-resource breakdown, points straight at the resource that changed.
How do I compute a cost diff in CI?
Price the base branch and the PR branch, then subtract. CI checks out the base, plans and prices it, checks out the PR, does the same, and reports the difference, or a cost tool compares the two Terraform plans in one step. Because pricing is static and driven by the plan JSON plus a catalog, both estimates run without cloud credentials in seconds.
How should a cost delta be presented on a PR?
Lead with the signed total delta, then list the resources that changed with their individual deltas, so a reviewer sees plus 180 for a replica and plus 40 for a volume rather than one opaque number. Show negative deltas proudly when a PR removes cost. Putting the delta inline on the PR sits it beside the code diff for review together.
How does C3X show cost diffs on pull requests?
C3X reads your Terraform, prices the base and PR branches statically against a live catalog with no cloud credentials, and posts the signed monthly delta with a per-resource breakdown as a comment on the GitHub or GitLab pull request. That places the dollar diff beside the code diff so reviewers weigh the cost of a change alongside its correctness before merge.
What to do next
Show the dollar delta on every infrastructure PR. C3X reads your Terraform and posts the cost diff on the pull request. Start with the quickstart.
Share this post
Try C3X on your own Terraform
Free and open source. No API key required. One command to install, one command to estimate.