← ~/pillars / cost-engineering/

Cost engineering

Cost observability as an engineering discipline, same as performance monitoring or error tracking: measuring what agents actually cost, attributing it to people and outcomes, and optimising with evidence.

by Paul Grycuk

updated 2026-07-06 6 artifacts 7 patterns

~/playbook/cost-engineering stage · optimise

Where is your p99 for spend, and what does a merged PR cost?

standard
Every cost figure is traceable to its layer and attributed to an owner.
check
Cost telemetry instrumented at source: OTel cost and token events, IAM-principal attribution on Bedrock.
skill
Session hygiene and context budgeting; prompt-cache economics measured, not assumed.
metric
Cost per merged PR: cost per outcome, not per token.
failure mode
Spend is a number someone discovers in the finance report.
~/pillars/cost-engineering/artifacts 6
settings-otel-cost-telemetry.mdx settings

Claude Code OTel cost telemetry kit

Managed settings that force cost telemetry on for a fleet, an OTel collector config that receives it, and a starter Grafana dashboard for spend by user, model, and token type.

✓ verified 2026-07-07

statusline-cost.mdx settings

Status line: live cost, quota, and cache share

A status line script showing the session's API-equivalent dollars, context usage, cache-read share of the last request, and Pro/Max quota windows: the numbers that steer spend, always in view.

✓ verified 2026-07-09

terraform-bedrock-budget-alerts.mdx terraform

Terraform: Bedrock budget alerts

An AWS Budgets configuration scoped to Bedrock spend with actual and forecasted alerts to SNS, so agent-driven inference cost gets a tripwire before it becomes a bill surprise.

✓ verified 2026-07-18

terraform-bedrock-cost-attribution.mdx terraform

Terraform: Bedrock cost attribution by IAM principal

Federated developer role with session-tag passthrough, principal tags as fallback, cost allocation tag activation, and the Athena queries that read spend by person from CUR 2.0.

✓ verified 2026-07-08

workflow-cost-per-pr-report.mdx workflow

Workflow: weekly cost-per-merged-PR report

A GitHub Actions job that joins Claude Code Analytics API spend to merged PRs, classifies agent-assisted PRs by commit trailer, and posts the weekly ratio to the run summary.

✓ verified 2026-07-11

workflow-usage-cost-report.mdx workflow

Workflow: weekly usage and cost report

A scheduled GitHub Actions workflow that pulls the week's token usage and spend from the Usage and Cost Admin API, grouped by model and workspace, and files the digest where the team will read it.

✓ verified 2026-07-18

Copy-paste-complete files, each verified against the primary docs on the date shown.

// patterns

The reading behind the artifacts, one pattern per page.

❯ read the full guide ~3 min · why this pillar exists and how the pieces fit →