Add the Infracost GitHub Actions step using `uses: infracost/actions/setup@v3` to install the CLI, authenticating with `INFRACOST_API_KEY` stored as a GitHub Actions secret.
Run `infracost breakdown --path . --format json --out-file /tmp/infracost-base.json` on the base branch, and the same command on the PR branch, saving to separate JSON files.
Run `infracost diff --path . --compare-to /tmp/infracost-base.json --format json --out-file /tmp/infracost-diff.json` to compute the cost delta.
Post the diff as a PR comment with `infracost comment github --path /tmp/infracost-diff.json --repo $GITHUB_REPOSITORY --pull-request $PR_NUMBER --github-token $GITHUB_TOKEN`.
Alternatively, install the Infracost GitHub App for a simpler setup that requires no manual Actions configuration and handles the comment lifecycle automatically.
Use `infracost comment --behavior update` to update the existing comment on re-runs rather than posting duplicate comments.
Known gotchas
Infracost requires `terraform init` to have been run (or at least a `.terraform.lock.hcl` present) before `infracost breakdown` can resolve module dependencies and provider schemas.
Cost estimates are based on Infracost's cloud pricing database, which may not reflect negotiated enterprise discount rates or reserved instance pricing; treat estimates as list-price approximations.
The Infracost GitHub App requires installation at the organization level; if the org restricts third-party app installs, use the Actions-based integration with an API key instead.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp