Skip to main content
All posts

Guide

Shift Left FinOps: How to Put Cost in the Pull Request

What shift left FinOps means, what changes at each stage of development, and how to put cost in the pull request, CI, and your coding agent.

Gabriel NielsenCo-founder and CPO
Published
Read time
7 min
Shift Left FinOps: How to Put Cost in the Pull Request
Ler em portuguêsShift left FinOps: como levar o custo para o pull request

Shift left FinOps moves the cost decision to the moment an engineer writes the change: an estimate on the pull request, a CI rule that can hold the merge, and cost in view of the coding agent, all before the resource exists. Next month's bill then confirms a decision your team already made. LevelFour, Infracost, HCP Terraform, Harness, and Stacklet each work on this at different stages.

We read each tool's documentation and pages in November 2026. We make LevelFour, so it gets the most room, and each claim about another tool links to that tool's page.

What is shift left FinOps?

The term comes from software testing. Draw the development lifecycle from left to right, and moving a test left means running it earlier. FinOps applies the same idea to cost, and the FinOps Foundation says so in its principles: technical teams must treat cost as a first-class metric from the start of the software development lifecycle.

The change is who decides, and when. Without shift left, someone in FinOps finds an expensive resource weeks after the deploy, files a ticket, and competes with the team's roadmap for priority. With shift left, the person writing the Terraform sees the cost beside the test results and changes one line before the merge.

Why are teams shifting FinOps left?

Fixing cost later takes more work. A resource in production needs a change window, a test, and someone who remembers why it exists. A line in a pull request needs a commit.

The State of FinOps 2026, the FinOps Foundation's survey of 1,192 respondents, lists shift left among the year's main themes. Pre-deployment architecture costing ranked second among the tool capabilities practitioners asked for, behind AI spend monitoring. The same report calls measurement unsolved, which How to measure it picks up.

Where cost enters at each stage

Design
What you see
The expected cost of the architecture
How it happens
l4 estimate on a draft of Terraform or CloudFormation
What you can still change
Almost everything: region, service, size
Editor and coding agent
What you see
The cost before the pull request opens
How it happens
l4 in the editor's terminal, the MCP server in the editor or agent
What you can still change
The code, before anyone reviews it
Pull request
What you see
Before and after for each resource
How it happens
The bot's comment and suggestions on the diff
What you can still change
One line, with one commit
CI
What you see
Pass or fail against your team's rule
How it happens
l4 diff --fail-above as a required check
What you can still change
The merge waits for the fix
Bill
What you see
The cost with usage and discounts
How it happens
Allocation, alerts, and Savings Audit
What you can still change
What already runs, with more work

How to put cost in the pull request

The LevelFour PR bot reads every pull request that changes your infrastructure code and posts the cost of the changed resources, before and after, with the monthly spend. It keeps one comment and edits it on each push, and cheaper settings arrive as suggestions on the lines of the diff. When a suggestion fits, reply:

Pull request comment
@levelfourai apply all

The bot writes the suggestions into one commit on the branch. If you disagree, @levelfourai dismiss <reason> puts your reason at the top of the comment for the next reviewer. How Terraform cost estimation works covers where the prices come from and what an estimate can't see.

A worked example with real prices

Say a pull request adds a new service in São Paulo on three m6i.2xlarge instances. AWS charges $0.612 an hour per instance on demand, on Linux, in sa-east-1. Over 730 hours, that comes to $446.76 an instance and $1,340.28 a month. An m7g.2xlarge has the same 8 vCPUs and 32 GiB, runs on Graviton (ARM), and saves $201.04 a month if your application runs on ARM.

m6i.2xlarge in sa-east-1
Price per hour
$0.612
Three instances, per month
$1,340.28
m7g.2xlarge in sa-east-1
Price per hour
$0.5202
Three instances, per month
$1,139.24
m6i.2xlarge in us-east-1
Price per hour
$0.384
Three instances, per month
$840.96

Linux on-demand prices from the AWS Price List API, read in November 2026, at 730 hours a month.

The third row is the trap for a team outside Virginia. With no region in the command, the config, or the provider block, l4 prices everything in us-east-1. The total looks plausible and here lands $499.32 below the São Paulo cost. Name the region:

Terminal
l4 diff --region sa-east-1 ./infra/

How to block a merge without stalling your team

The comment informs the reviewer. To hold the merge, run l4 in a CI job and mark that job as a required check:

Terminal
l4 diff --fail-above 100 -q ./infra/

If the change adds more than $100 a month, the command exits with code 2 and the job fails. Pick l4 diff over l4 estimate --fail-above: the first measures the change and the second the whole workspace, so a repository already above the line would fail every pull request. A read key is enough, and the job needs git history (fetch-depth: 0 on GitHub Actions, GIT_DEPTH: 0 on GitLab CI) to find the baseline.

How to bring cost into your editor and coding agent

With Claude Code, Cursor, and other agents writing Terraform, the leftmost stage now sits before the pull request. An agent with terminal access can run l4 itself, and one instruction in the repository's agent file covers it:

CLAUDE.md
When you change anything under infra/, run `l4 diff --region sa-east-1 ./infra/`
and put the monthly cost change in the pull request description.

That covers the cost of the change. For what the service costs today, the LevelFour MCP server answers in the same chat: spend by service, what grew most, and the open savings. In Claude Code, one command adds it, and Cursor, VS Code, Windsurf, and any other MCP client connect the same way:

Terminal
claude mcp add --transport http levelfour https://mcp.levelfour.ai/mcp

Which tools do shift left FinOps?

LevelFour
Where it acts
Editor and coding agent (MCP and CLI), pull request, CI, and the bill
What it covers
The bot works on GitHub, GitLab, Bitbucket, and Azure DevOps, for Terraform, CloudFormation, CDK, Pulumi, and Kubernetes manifests; the platform reads Cloud, SaaS, and AI spend
Best fit
Teams that want the estimate, the fix, and the savings in one place
Where it acts
Editor, pull request, and CI
What it covers
Open source CLI for Terraform, Terragrunt, and CloudFormation, with extensions for VS Code, Cursor, and JetBrains IDEs
Best fit
Teams that want an open source CLI in any pipeline
Where it acts
The run, with Sentinel policy
What it covers
Estimates for AWS, Azure, and Google Cloud
Best fit
Teams already running Terraform in HCP Terraform
Where it acts
Terraform plan, CI/CD, and policy
What it covers
Cost policies in OPA; the platform covers AWS, Azure, Google Cloud, and Kubernetes
Best fit
Teams already on the Harness delivery platform
Where it acts
Workstation, code review, CI, and deploy
What it covers
Declarative policies and cost guardrails over IaC
Best fit
Teams that want governance as code
Where it acts
Rules over your cloud accounts
What it covers
Open source CNCF project (Apache 2.0) for AWS, Azure, and Google Cloud, with policies in YAML
Best fit
Teams that prefer to write rules in an open project

Sources: each tool's own documentation and pages, read in November 2026.

For a closer look at the estimate tools, read the best Infracost alternatives.

Common mistakes

  • Blocking merges on day one. Run with the comment alone for a few weeks, see which changes would cross the line, and turn on the required check after that.
  • Using one threshold for every repository. $100 a month is noise on a large production service and a strong signal in a test environment.
  • Forgetting the region. The example above misses by $499.32 a month because of one missing flag.
  • Reading the estimate as a bill forecast. It shows the size and direction of a change, and usage, traffic, and discounts arrive after the deploy.
  • Leaving the check without an owner. Agree on who can grant an exception before an urgent change gets stuck on a Friday.

How to measure whether it works

Avoided cost never shows on a bill, which is why measurement stays hard. Three numbers help: how many pull requests changed after the estimate, the monthly cost proposed against the cost that reached the merge, and the share of repositories with the check on. On the bill, track cost by service with allocation by team and confirm what stuck.

How to get started

  • Connect the repository and let the bot comment for two weeks, with nothing blocked.
  • Set the region with --region, or with region_override in .levelfour/config.yml.
  • Turn on l4 diff --fail-above as a required check in your highest-spend repositories.
  • Add the l4 instruction to the repository's agent file and connect the MCP server.

LevelFour estimates each change, suggests the fix, and then confirms the saving on the bill, across Cloud, SaaS, and AI spend. See what LevelFour can save you in 5 minutes, with read-only access.

Frequently asked questions

What is shift left FinOps?

Shift left FinOps moves the cost decision to the moment an engineer writes the change, with an estimate on the pull request, a CI rule, and cost in view of the coding agent, before the resource exists. See the glossary term.

What are the best shift left FinOps tools?

LevelFour for the estimate, the fix, and the savings in one place, Infracost for an open source CLI in any pipeline, HCP Terraform if you already run Terraform there, Harness if you already use its delivery platform, and Stacklet or Cloud Custodian for governance as code.

Does shift left FinOps slow engineers down?

A pull request comment slows nobody, because it only informs. Delays come from a badly set block, so start with the comment alone and turn on the required check once you see which changes would cross the line.

How is shift left FinOps different from traditional FinOps?

Traditional FinOps reads the bill after the spend and asks whoever created the resource to fix it. Shift left shows the cost while the change is still a line of code, and the bill confirms the result.

Do I need to run terraform plan to estimate cost?

With l4 estimate, no. The command reads your .tf files on your machine and sends only the resources to the LevelFour API, with no terraform plan and no deployed stack.

Try LevelFour free for 14 days

See what it saves on your cloud, SaaS, and AI bills. No credit card required.

Start free trial

See what LevelFour can save you