runcap
Open source · MIT · Local-first

Control AI coding spend. Require proof before merge.

Runcap is a local-first control layer for AI coding agents. It caps AI requests routed through Runcap and uses a pinned GitHub Action to replay base-pinned verification before an AI-generated pull request earns merge eligibility.

Spend controls apply only to requests routed through Runcap. The Proof Gate verifies pull-request changes; it does not independently meter all AI usage.

Runcap terminal: a mission run is estimated, capped, and verified to PASS, then a tampered run is graded BLOCKED on the pull request.
One run estimated, capped, verified PASS - then a tampered run graded BLOCKED on the PR.
Proof before merge

A green CI check is not proof when the same agent can edit the test, workflow, policy, or verifier that defines success.

Runcap adds a required PR check that does not trust the agent or the receipt it hands you. It re-derives the merge decision in a clean CI job, reading the policy and verifier from the pull request's base commit, then replays the permitted change from scratch.

1 AI-generated PR
2 Policy and verifier read from the PR base commit
3 Raw diff checked against allowed scope and protected paths
4 Permitted change replayed in a clean base checkout
5 PASS / BLOCKED / HUMAN_APPROVAL_REQUIRED

Pinned Runcap GitHub Action
→ reads base-commit policy and verifier
→ replays permitted changes
→ returns an adjudicated verdict

PASS

The verifier fails on the base commit and passes after an allowed in-scope replay.

BLOCKED

The pull request goes outside allowed scope, uses an unsafe diff type, or does not reproduce the intended verifier result.

HUMAN_APPROVAL_REQUIRED

The pull request changes policy, workflow, verifier, dependency surface, or another protected path. A human must decide.

What the verdict is, honestly. It is a CI-attested replay under a documented hardened GitHub profile. It is not "unspoofable," not "fully independent," and it is not independent budget enforcement. It raises the cost of a tampered merge and records exactly what was checked.

Read the technical explanation: Why a green CI check is not proof.

The public runcap-proof-gate-demo repository on GitHub, the live demo where each verdict can be inspected.
The public demo repo - inspect each verdict on a real pull request.

See real verdicts

The second pillar

Control spend on routed AI calls

Runcap can estimate a cost range and stop routed AI requests once they reach a configured cap. Calls made directly to providers, subscriptions, invoices, cards, or unrelated tools are outside this control path. Multi-agent coding runs can consume far more tokens than a single chat: agents can loop on the same error, rewrite plans, and keep working after the useful change is already complete. For calls routed through the local gateway, Runcap blocks a request before it is sent when that request would exceed the configured cap.

1. Estimate a cost range before the run starts
2. Cap routed calls with a hard ceiling
3. Compress wasted tokens out of routed calls
4. Rescue with a copyable prompt when stuck

Scope: the cap applies to AI requests routed through the Runcap gateway. It does not meter or stop direct provider calls, subscriptions, invoices, cards, or unrelated tools.

See it in 60 seconds

No API key required. Runcap catches a too-broad request before it spends a cent, then hands back a rescue prompt the moment a run gets stuck.

$ runcap preflight -- claude "build the full app with auth, payments, deploy"

Scope risk: high
Recommendation: Do not launch as one broad mission.
  Split into one vertical slice with a verification command.

$ runcap run --label demo -- npm run build

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@/components'

Runcap mission: 20260601T221531-demo
Status: stuck (medium confidence)
Changed files: 0   Parsed errors: 1
Primary recommendation: Resolve missing import before continuing

Rescue prompt: Do not continue broad implementation. Diagnose this
  missing module first: Cannot find package '@/components'. Check
  package.json, tsconfig paths, and the latest git diff. Make the
  smallest change that resolves the import, then run the command again.

Trim re-read tokens with delta encoding

Coding agents read a file, change one line, then re-read it. The two copies are almost identical. Runcap can send a lossless line-diff against the version the model already saw, and the model reconstructs the current file from it. Same answer, fewer prompt tokens on that call.

Real OpenAI call, same question, same correct answer
compression off
1,186 prompt tokens
delta compression on
737 prompt tokens
37.9% saved

In one measured OpenAI call, an edited-file re-read dropped from 1,186 to 737 prompt tokens - 37.9% fewer prompt tokens - while the model still answered correctly about the changed line. This is a single measured result, not a universal or guaranteed saving. Lossless by construction: Runcap refuses to emit a delta unless it reconstructs the original byte for byte.

See the proof and reproduce it

Who this is for

Built for technical founders and engineering teams using Claude Code, Codex, Cursor, or custom coding agents with GitHub pull-request workflows. Runcap is a developer tool: a local gateway for spend control, and a pinned GitHub Action for the Proof Gate.

Current Proof Gate scope: GitHub Actions + Node/npm repositories.

Your own API key

An OpenAI or Anthropic key. Runcap never sells or supplies model access, it only caps the spend on routed calls using the key you already have.

Your own agent

Claude Code, Codex, Cursor, or any script that calls the OpenAI or Anthropic API. Runcap wraps it, it does not replace it.

A GitHub + Node/npm repo

For the Proof Gate: a GitHub repository with Actions and a Node/npm verification command. Spend control alone needs only a CLI and your key.

Two ways to install

Start with local spend control, or wire the Proof Gate into a GitHub repository. They are independent: you can run either on its own.

Path A · Try local spend control
# run the demo with zero setup
git clone https://github.com/kirder24-code/ai-agent-manager.git
cd ai-agent-manager
npm run setup
npm run demo

# or install the CLI globally
npm install -g runcap

# put a hard daily ceiling on routed Claude or OpenAI calls
ANTHROPIC_API_KEY=sk-ant-... AIM_DAILY_BUDGET_USD=5 runcap gateway
# routed calls are stopped once spend crosses your ceiling
Path B · Protect AI-generated pull requests

Make the Proof Gate a required PR check in your own GitHub + Node/npm repo. The adjudicator runs from a pinned, immutable Runcap release commit that lives outside the candidate PR, so a pull request cannot rewrite its own judge.

  1. Add .runcap/mission.yaml with your scope, protected paths, and verification command.
  2. Copy examples/runcap-adjudicate.yml into .github/workflows/ (pinned to the Runcap v0.6.0 release commit).
  3. Configure the hardened GitHub branch profile (protected branch, required check, CODEOWNERS for workflow/policy/verifier/protected paths).
  4. Make Runcap adjudicate a required status check, so it must pass before merge.

The honest claim

Runcap does not promise an exact cost oracle. Agent runs are stochastic and nobody can predict the exact token count. So it gives you a range plus a hard cap: "this build is roughly $3 to $7, cap it at $10." The range is the headline. The hard cap is the product. Every output carries a truth label (observed, calculated, provider_usage, unknown). If Runcap can't prove something, it says so.

Available today

Free and open source local CLI controls

MIT-licensed, runs on your machine. No account, no card.

Hard caps for routed AI calls

A configured ceiling on requests routed through the gateway.

GitHub Proof Gate

For supported Node/npm pull-request workflows on GitHub Actions.

Hosted sync, team pools, organization reporting, and paid plans are not available for purchase today.