costroid

package module
v1.0.0-alpha.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Costroid

Costroid is the cost check for pull requests. An agent's own cost figure is an estimate, so Costroid prices the run's tokens from a pinned, dated catalog and posts the figure, with its basis, on the pull request. A recorded run on 2026-11-07:

Within budget, by the job's own figures: this run cost USD 0.0391529 at list
(Measured) of the USD 5.00 run budget. Nothing outside the job checked the
figures, so the check is neutral.

The whole comment is one page.

Install

On Linux or macOS, with curl:

curl -fsSLO https://github.com/Costroid/costroid/releases/download/v1.0.0-alpha.29/costroid-install.sh
cat costroid-install.sh
sh costroid-install.sh

The script checks the release's signature and checksum, then puts one binary in $HOME/.local/bin. docs/install.md installs it by hand, with Go, or runs it from the image.

First commands

They need no key and spend nothing:

costroid demo                  # the whole comment a pull request gets, from a recorded run
costroid demo --state capped   # a run stopped at its cap; also failure and skipped
costroid demo --markdown       # the same comment as the Markdown the report posts

Try it on a pull request

You need a repository on GitHub, the GitHub CLI signed in, and an Anthropic API key. init prints the commands left, and --pr runs them:

costroid init github --agent claude
gh secret set ANTHROPIC_API_KEY
git switch -c try-costroid
git add .github/workflows/costroid.yml costroid.yml
git commit -m "Add the costroid check"
git push --set-upstream origin try-costroid
gh pr create --fill

Without installing anything

  1. Copy a recipe to .github/workflows/costroid.yml: github-claude-code-action.yml, capped at USD 5 a run, or github-codex-action.yml, uncapped.
  2. Set its one secret, ANTHROPIC_API_KEY or OPENAI_API_KEY.
  3. Open a pull request.

Costroid's action installs its own binary. On a private repository, harden-runner limits egress only with StepSecurity's subscription.

Add it to the workflow you have

Already on claude-code-action, or on openai/codex-action:

costroid lint                  # judges the agent workflows in .github/workflows
costroid init github --existing .github/workflows/claude.yml > costroid.patch
git apply costroid.patch

The patch adds a read step and a report job.

A run on your machine

With Claude Code installed and signed in:

costroid run --budget-usd 5 --out rows.jsonl -- claude -p "Fix the failing test."
costroid report --preview --rows rows.jsonl

run prints, for a recorded subscription run:

costroid: running claude-code under a cap of USD 5.00
costroid: claude-code, 4 requests
costroid: 19 rows in rows.jsonl, catalog 0.4.3
costroid: USD 0.001619725 at list (List-equivalent, not billed)
costroid: cap USD 5.00 (client-side estimate, can pass the cap)
costroid: note: BillingAccountId reads unknown: pass --billing-account or set COSTROID_BILLING_ACCOUNT

Each row is one request's token class, such as "SkuMeter":"input_uncached".

More

docs/ lists every task. In Claude Code, install the plugin:

/plugin marketplace add Costroid/costroid
/plugin install costroid@costroid

Licence

Apache-2.0. The CLI, the gate, the ledger schema, the plan schema, the FOCUS tag convention, the price catalog and the policy packs stay Apache-2.0 and are never relicensed. Contributions are under the Developer Certificate of Origin.

Documentation

Overview

Package costroid holds the published schema of costroid.yml.

Index

Constants

This section is empty.

Variables

View Source
var ConfigSchema []byte

ConfigSchema is the JSON Schema of costroid.yml.

View Source
var Recipes embed.FS

Recipes holds the CI recipes as this release ships them, under recipes/. A recipe's Costroid pin can name an earlier release, or none, because the commit that pins a release follows its tag. costroid init rewrites each pin to the release the binary belongs to.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
Package catalogdata embeds the price sheets of each release the binary carries.
Package catalogdata embeds the price sheets of each release the binary carries.
cmd
costroid command
Command costroid is the cost check for pull requests.
Command costroid is the cost check for pull requests.
internal
accuracy
Package accuracy holds the record of Costroid's own accuracy test that a release carries: the lines of the accuracy page, docs/accuracy.md, for the page's last Window days, as the page stood when the release was built.
Package accuracy holds the record of Costroid's own accuracy test that a release carries: the lines of the accuracy page, docs/accuracy.md, for the page's last Window days, as the page stood when the release was built.
adapter
Package adapter holds what every agent adapter hands the wrapper.
Package adapter holds what every agent adapter hands the wrapper.
adapter/claudecode
Package claudecode reads Claude Code runs.
Package claudecode reads Claude Code runs.
adapter/codex
Package codex reads `codex exec --json` runs.
Package codex reads `codex exec --json` runs.
adapter/copilot
Package copilot reads `copilot -p --output-format json` runs of GitHub Copilot CLI.
Package copilot reads `copilot -p --output-format json` runs of GitHub Copilot CLI.
adapter/ghaw
Package ghaw reads what a GitHub Agentic Workflows (gh-aw) run spent, from the usage artifact its conclusion job uploads.
Package ghaw reads what a GitHub Agentic Workflows (gh-aw) run spent, from the usage artifact its conclusion job uploads.
adapter/opencode
Package opencode reads `opencode run --format json` runs.
Package opencode reads `opencode run --format json` runs.
agentcommand
Package agentcommand names the agent a command starts by the command's own name.
Package agentcommand names the agent a command starts by the command's own name.
agenttest
Package agenttest keeps a test from starting a real coding agent.
Package agenttest keeps a test from starting a real coding agent.
amounts
Package amounts decides whether what Costroid posts on a repository shows amounts.
Package amounts decides whether what Costroid posts on a repository shows amounts.
catalog
Package catalog prices token classes against the pinned sheets.
Package catalog prices token classes against the pinned sheets.
cicontext
Package cicontext reads what the CI system says about a run.
Package cicontext reads what the CI system says about a run.
cli
Package cli holds what every costroid command shares on the command line: the shape of a help page, what a mistake and an error print, and the codes a command exits with.
Package cli holds what every costroid command shares on the command line: the shape of a help page, what a mistake and an error print, and the codes a command exits with.
comment
Package comment turns FOCUS rows into the check output and the sticky pull request comment.
Package comment turns FOCUS rows into the check output and the sticky pull request comment.
config
Package config checks a costroid.yml against the published schema.
Package config checks a costroid.yml against the published schema.
decimal
Package decimal is an exact base-10 number for money and quantities.
Package decimal is an exact base-10 number for money and quantities.
docstest
Package docstest reads the fenced blocks of the README and of docs/, for the tests that hold a block to what a command prints.
Package docstest reads the fenced blocks of the README and of docs/, for the tests that hold a block to what a command prints.
egress
Package egress is the one way out of costroid serve.
Package egress is the one way out of costroid serve.
export
Package export writes a rows file in the import format of another cost tool: FOCUS 1.4 CSV, a Vantage custom provider's CSV, Datadog's Custom Costs CSV, Harness's custom cost CSV, a Cloudability FOCUS drop, Ternary's daily FOCUS 1.2 files, or FOCUS 1.5's candidate release.
Package export writes a rows file in the import format of another cost tool: FOCUS 1.4 CSV, a Vantage custom provider's CSV, Datadog's Custom Costs CSV, Harness's custom cost CSV, a Cloudability FOCUS drop, Ternary's daily FOCUS 1.2 files, or FOCUS 1.5's candidate release.
fanout
Package fanout runs CPU-bound work over a list on every core the process has.
Package fanout runs CPU-bound work over a list on every core the process has.
focus
Package focus holds the Costroid FOCUS row, version 0.3, and its writer.
Package focus holds the Costroid FOCUS row, version 0.3, and its writer.
focusfile
Package focusfile reads a FOCUS cost file that a step of the customer's own CI wrote, such as an infrastructure estimator's output, and turns each of its rows into one Costroid row with the basis estimate.
Package focusfile reads a FOCUS cost file that a step of the customer's own CI wrote, such as an infrastructure estimator's output, and turns each of its rows into one Costroid row with the basis estimate.
gateway
Package gateway gives one CI run its own key on a LiteLLM proxy.
Package gateway gives one CI run its own key on a LiteLLM proxy.
gateway/gatewaytest
Package gatewaytest serves the LiteLLM proxy routes costroid gateway calls, as LiteLLM v1.108.1 answered them on 2026-11-07, for tests.
Package gatewaytest serves the LiteLLM proxy routes costroid gateway calls, as LiteLLM v1.108.1 answered them on 2026-11-07, for tests.
history
Package history reads the result objects earlier reports posted on a pull request's commits, and adds their figures up with this run's.
Package history reads the result objects earlier reports posted on a pull request's commits, and adds their figures up with this run's.
mcpserver
Package mcpserver answers the Model Context Protocol over one connection, so an agent can ask what its run has cost while it works.
Package mcpserver answers the Model Context Protocol over one connection, so an agent can ask what its run has cost while it works.
oidc
Package oidc verifies CI OIDC ID tokens and reads a run's identity from them.
Package oidc verifies CI OIDC ID tokens and reads a run's identity from them.
oidc/oidctest
Package oidctest is a stub OIDC issuer for tests: an RSA key, a JWKS endpoint and a signer.
Package oidctest is a stub OIDC issuer for tests: an RSA key, a JWKS endpoint and a signer.
otlp
Package otlp reads OTLP/HTTP traces and logs into per-request usage.
Package otlp reads OTLP/HTTP traces and logs into per-request usage.
otlpemit
Package otlpemit sends a rows file to an OpenTelemetry backend as traces over OTLP/HTTP: one span per model request.
Package otlpemit sends a rows file to an OpenTelemetry backend as traces over OTLP/HTTP: one span per model request.
policy
Package policy decides the check's conclusion.
Package policy decides the check's conclusion.
reason
Package reason holds the words a run states about itself: why it wrote no rows, what to do about the error its agent ended in, and the reader's error line.
Package reason holds the words a run states about itself: why it wrote no rows, what to do about the error its agent ended in, and the reader's error line.
receipt
Package receipt holds the token counts of a developer's own agent sessions on one branch, as costroid receipt prints them for the developer to post on the pull request, and as a report reads, refuses and prices them.
Package receipt holds the token counts of a developer's own agent sessions on one branch, as costroid receipt prints them for the developer to post on the pull request, and as a report reads, refuses and prices them.
receipt/receipttest
Package receipttest writes synthetic Claude Code session files for the tests of costroid receipt.
Package receipttest writes synthetic Claude Code session files for the tests of costroid receipt.
recipelint
Package recipelint holds the shipped CI recipes to their security rules: no privileged trigger, every action pinned by SHA, and an agent's job that holds nothing but read access to the code.
Package recipelint holds the shipped CI recipes to their security rules: no privileged trigger, every action pinned by SHA, and an agent's job that holds nothing but read access to the code.
reconcile
Package reconcile compares the ledger with the provider's own reports, per credential per day.
Package reconcile compares the ledger with the provider's own reports, per credential per day.
reconcile/state
Package state names a reconciliation's verdict on its tokens.
Package state names a reconciliation's verdict on its tokens.
review
Package review renders the agent's own answer as a second pull request comment, apart from Costroid's report.
Package review renders the agent's own answer as a second pull request comment, apart from Costroid's report.
run
Package run launches an agent under a budget and turns its usage into rows.
Package run launches an agent under a budget and turns its usage into rows.
scm
Package scm reaches a source-code host through one interface.
Package scm reaches a source-code host through one interface.
scm/kmstest
Package kmstest stands in for AWS KMS in tests.
Package kmstest stands in for AWS KMS in tests.
scm/scmtest
Package scmtest holds stub GitHub and GitLab APIs for tests.
Package scmtest holds stub GitHub and GitLab APIs for tests.
server
Package server is the ingest service behind costroid serve: the result-stream and OTLP paths, pricing against the pinned catalog, and the per-PR view.
Package server is the ingest service behind costroid serve: the result-stream and OTLP paths, pricing against the pinned catalog, and the per-PR view.
status
Package status writes a run's status file: what the run has spent so far, its cap, what is left and what holds it, for the agent and the job to read while the agent works.
Package status writes a run's status file: what the run has spent so far, its cap, what is left and what holds it, for the agent and the job to read while the agent works.
store
Package store is the ledger: FOCUS rows in Postgres, one tenant at a time.
Package store is the ledger: FOCUS rows in Postgres, one tenant at a time.
store/storetest
Package storetest runs Postgres in Docker for the packages that need it.
Package storetest runs Postgres in Docker for the packages that need it.
vcs
Package vcs reads the names a version control system gives a commit.
Package vcs reads the names a version control system gives a commit.
Package migrations embeds the forward-only schema migrations.
Package migrations embeds the forward-only schema migrations.
scripts
accuracy command
Command accuracy keeps the inputs of one day's reconciliation, writes the accuracy page from every day kept, and checks the page against them.
Command accuracy keeps the inputs of one day's reconciliation, writes the accuracy page from every day kept, and checks the page against them.
notice command
Command notice writes NOTICE from the modules a release build of costroid links and the licence and notice files each holds in the module cache.
Command notice writes NOTICE from the modules a release build of costroid links and the licence and notice files each holds in the module cache.
pin command
Command pin moves the release that the README, the docs, the recipes, the Marketplace listing and the packaging name to another release, by version and commit.
Command pin moves the release that the README, the docs, the recipes, the Marketplace listing and the packaging name to another release, by version and commit.
record command
Command record turns an agent's run into a test fixture that holds no content: no prompt, no reply, no tool output, no path and no credential.
Command record turns an agent's run into a test fixture that holds no content: no prompt, no reply, no tool output, no path and no credential.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL