cost-guard
Skill16 starsChanged 5 months agoMITView on GitHub
Track per-project spend against a budget cap. Set a cap, check an estimate before an expensive run, record actual cost after each generation, and report the running total. Use whenever the user mentions budget, cost, how much, spend, cap, or before any expensive batch. Keywords - budget, cost, cap, spend, how much, afford, remaining.
- Reads credentials
In this repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- analyze-videoSkill
- content-preflightSkill
- content-reviewSkill
- create-workflowSkill
- generate-brand-assetsSkill
- generate-imageSkill
- generate-musicSkill
- generate-videoSkill
- generate-voiceoverSkill
- localize-contentSkill
- onboard-brandSkill
- package-contentSkill
- plan-contentSkill
- preview-pickSkill
- produce-contentSkill
- qa-reviewSkill
- repurpose-contentSkill
- revise-contentSkill
- write-copySkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Every function is exposed as a CLI command: node workflows/cli.cjs <command> '<json-args>' (loads .env, prints the JSON result, exits …
- Distinctive: line 20
Ask the user early — ideally during pre-flight:
- Very specific: line 49
If c.ok === false → tell the user it would exceed the cap, show by how much, and offer: use a cheaper model (Veo Lite), shorten, drop …
- Very specific: line 73
Every workflow returns result.data.cost.totalCost.
- Very specific: line 100
Prefer the preview-pick skill to keep estimates (and waste) low.
- Very specific: line 106
Blocks before spending: if spent >= cap → BUDGET_EXCEEDED, exit 1, nothing generated.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cost Guard (budget + per-project cap)
Generation costs real money. This keeps a per-project ledger and a hard cap so a run never
silently overspends. Ledger lives at projects/{name}/config/budget.yaml.
Every function is exposed as a CLI command: node workflows/cli.cjs <command> '<json-args>'
(loads .env, prints the JSON result, exits non-zero on failure; node workflows/cli.cjs list
shows all commands).
STEP 1: Set a cap (once per project)
Ask the user early — ideally during pre-flight:
"What's your budget for this project? I'll stop before going over."
node workflows/cli.cjs setBudgetCap '["{name}",50]' # $50; pass null for no capSTEP 2: Estimate + CHECK before any expensive run
Estimate the run, then gate on the cap. Never start an over-cap run without confirming.
Rough rates: image 512 ≈ $0.045 · 1K ≈ $0.067 · 2K ≈ $0.101 · 4K ≈ $0.15 · lite model ≈ $0.0336 flat · video ≈ $0.40/s (lite $0.05/s) · TTS ≈ $0.001/sentence · music ≈ $0.04–0.08 · text ≈ ~$0.
node workflows/cli.cjs checkBudget '["{name}",12.40]' # est ~31s of video
# → { ok, spent, cap, remaining, projected, wouldExceed }Show it:
💰 BUDGET CHECK — {name}
Spent so far: $12.50 / $50.00 (remaining $37.50)
This run: ~$12.40
After run: $24.90 / $50.00
→ OK to proceedIf c.ok === false → tell the user it would exceed the cap, show by how much, and offer:
use a cheaper model (Veo Lite), shorten, drop scenes, or raise the cap. Do not run.
OpenRouter models — get the number, don't recall it (RULES 3b)
The rough rates above are Gemini's. For anything on OpenRouter, ask the catalog
(free, local, no API call) and feed its answer into checkBudget:
node workflows/cli.cjs estimateOpenRouterCost \
'{"model":"google/veo-3.1-fast","durationSeconds":8,"resolution":"720p","withAudio":false}'
# → { cost: 0.64, formatted: "$0.6400 USD (est.)", source: "estimate", issues: [] }issuesnon-empty → the parameters are unsupported; fix them before spending.formatted: "cost unknown"/source: "unknown"→ the model bills per video token (Seedance 2.x, Sora 2 Pro) and cannot be estimated. Say so plainly, budget with a worst-case placeholder the user agrees to, and reconcile from the returnedusage.costafter the render.Unknown model→ refresh the catalog:node openrouter/scripts/sync-pricing.mjs.
STEP 3: Record actual cost after each generation
Every workflow returns result.data.cost.totalCost. Record it so the ledger stays accurate:
node workflows/cli.cjs recordCost '["{name}",{"label":"hero video 31s","type":"video","amount":12.40}]'
# amount = result.data.cost.totalCost; types: 'text' | 'image' | 'video' | 'audio' | 'music' | 'other'STEP 4: Report on request
node workflows/cli.cjs budgetSummary '["{name}"]'
# → { spent, cap, remaining, byType, entryCount }💰 SPEND — {name}
Total: $24.90 / $50.00 (remaining $25.10, 12 items)
video $22.80 · image $1.90 · audio $0.20The rule
Estimate →
checkBudget→ (confirm if over) → generate →recordCost.
For a planned batch (e.g. a 30-day calendar), sum the per-piece estimates and checkBudget
the whole plan up front: "This calendar is ~$240 — your cap is $200. Trim or raise?"
Prefer the preview-pick skill to keep estimates (and waste) low.
Enforcement (built into the CLI — 2026-07-03)
The cap is not advisory. For any paid command whose args reference
projects/{name}/, workflows/cli.cjs:
- Blocks before spending if
spent >= cap→BUDGET_EXCEEDED, exit 1, nothing generated. Warns on stderr at ≥80% of cap. - Auto-records the actual returned cost to the ledger (
auto:<command>).
So: checkBudget remains the polite pre-estimate for the conversation, but the
hard stop and the ledger are guaranteed even if an agent skips this skill.
Manual recordCost is only for out-of-band spend. Raising the cap or
BUDGET_OVERRIDE=1 requires explicit user consent — never set it yourself.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

