/cfo:cfo-booksfrom cfo
Check, append to and summarize the CFO's private books (ledger, projects, budgets, renewals, questions). Checks find schema errors, forbidden content such as card numbers, account IDs and API keys, and rewritten ledger history. Use before committing or opening a PR against the books, to add ledger rows, to book sealed agent-ledger runs (estimate beside actual), to get a month's spend numbers, when a books CI check fails, or when asked to "check the books", "validate the ledger" or "summarize the month".
Ships in cfo. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Run the checker before you commit anything to the books. The other cfo skills do this before they commit.
The books. The CFO keeps its data in a private git repo, "the books", never in this skill or any public repo. Find it in this order: the CFO_BOOKS environment variable, then a git repo named finances inside the current working directory or next to it (a sibling folder), then ask the user where it is. If there are no books yet, offer to create them with this layout:
| File | Holds |
|---|---|
ledger/charges.csv | One row per charge: charge_date, period_start, period_end, provider, service, charge_type, billed_cost, currency, api_equivalent_cost, project, status, source, evidence (FOCUS-style) |
ledger/runs.csv | One row per sealed agent-ledger run, written by books.py runs: the charter's estimate and budget beside the run's recorded spend. API-equivalent, never cash. Created on the first import |
projects.yaml | Which project each provider resource belongs to; new ones are state: proposed until confirmed |
budgets.yaml | The monthly envelope and alert rules; status: proposed until the user confirms |
renewals.yaml | Upcoming renewals and vendor changes to watch |
questions.md | What the CFO needs from the user, each with a best guess |
briefs/ | One brief per weekly run |
inbox/ | Files the user drops in (invoice PDFs, statement CSVs); git-ignored |
Rules that always apply:
billed_cost empty with status: unknown and add a question with your best guess.charge_type: adjustment.books.py summary BOOKS_DIR --month YYYY-MM --json, and ledger writes only from books.py append BOOKS_DIR ROWS_CSV. Never add, average, total or round amounts by hand or in prose, and never write the ledger CSV by hand. Quote each number exactly as summary prints it. Run the script with uv run --python 3.12 <cfo-books skill dir>/scripts/books.py (or with any Python 3.10 or later if uv is not installed); cfo-books is a sibling skill in this plugin, so look for its directory next to this skill's directory.uv run --python 3.12 <skill dir>/scripts/books.py check BOOKS_DIR [--base REF]
It needs Python 3.10 or later and the standard library only. Run it through uv; any Python 3.10+ works if uv is not installed. Each problem prints as path:line: message, with the path relative to BOOKS_DIR. The last line is ok, N rows, 0 problems (exit 0) or N problems (exit 1). A missing directory or bad arguments exit 2.
Stale pricing prints path:line: warning: ... lines and a trailing , 1 warning; warnings never change the exit code.
Use --base origin/main (or any ref) on a branch or PR. Leave it off for a quick local check.
| Problem | Meaning and fix |
|---|---|
header does not match the schema | The first ledger line must be the 13 columns above, in order. |
| a row field message | charge_date and period_start need YYYY-MM-DD; period_end is empty or a date on or after period_start; charge_type, status and currency take known values; billed_cost is empty exactly when status is unknown; evidence is never empty; project is a key in projects.yaml or unassigned. |
questions.md problem | Each question is - **Q<n> (YYYY-MM-DD) <title>.** text, under ## Open or ## Answered. Ids are unique across both sections. An answered one carries **Answered YYYY-MM-DD:**. An Answer: line under an Open question is fine; it means answered, not yet moved. |
missing top-level key or unsupported YAML | The YAML files use a small subset (block maps, lists, flow maps, quoted strings, >-). Rewrite the named line in that style. |
forbidden content | A card number (Luhn-valid, 13 to 19 digits), a 12-digit account ID, or a secret-shaped token. The message gives the kind, never the value. Remove it from the file. If it is already committed, tell the user, because history needs cleaning. A 12-digit receipt number is fine in the evidence column. Under .audit/ (agent-ledger run records), sha256 and git hashes are not flagged, and session archives (.audit/runs/<run>/sessions/*.jsonl.gz) are skipped: they are gzip, quote hashes and test fixtures, and agent-ledger's ledger scan checks them for secrets in its ledger-verify CI check. |
changed since REF or removed since REF | A ledger line (in charges.csv or runs.csv) that exists at REF was edited or deleted. Restore it and add an adjustment row instead. |
a ledger/runs.csv message | The header is the 17 columns under "Book agent runs"; sealed_date is a date; source is a repo name; run_id is an agent-ledger run id; a run row has non-negative amounts and whole-number counts, and a source and run id appear in one run row only; an adjustment row follows its run's row, sets actual_usd (and optionally actual_tokens) and leaves the other run columns empty. |
uv run --python 3.12 <skill dir>/scripts/books.py append BOOKS_DIR ROWS_CSV
ROWS_CSV has a header with any of the 13 ledger columns in any order, and at least evidence. With --book runs it takes ledger/runs.csv's columns instead and appends there, for an adjustment row (see "Book agent runs"). A column you leave out stays empty; nothing is filled in for you. An unknown column is an error (exit 2).
A row whose evidence is already in the ledger, or repeats an earlier row in ROWS_CSV, is skipped. Before writing, the whole check runs on the ledger as it would be after the append. If the books already had a problem, or the new rows add one, it prints the problems and refused, ledger unchanged (exit 1) and the file is byte-identical. Otherwise it writes atomically and prints added N, skipped M (evidence already in the ledger). With nothing to add it does not touch the file.
uv run --python 3.12 <skill dir>/scripts/books.py summary BOOKS_DIR --month YYYY-MM [--as-of YYYY-MM-DD] [--json]
It runs the checks first and prints the problems (exit 1) instead of numbers if the books are not clean. --as-of defaults to today and sets the renewals window, so briefs and tests are repeatable. Text output has sections in this order: Cash, Envelope, Monthly equivalent, Renewals, Unknown amounts, API-equivalent, Agent runs.
Rules behind the numbers:
verified rows with a charge_date in the month, adjustments included. usage-equivalent rows never count. A yearly charge is cash in its month only.billed_cost divided by round(days / 30.4375) months. The latest row per provider and service counts, so a plan renewed mid-month is not doubled. lines lists only the multi-month ones (a $100 yearly plan shows as $8.33).budgets.yaml. over_warning means past envelope_warning_pct; exactly at it is not over. null when no envelope is set.renewals.yaml entries due 0 to 30 days after --as-of. Entries without a date go to renewals_undated.unknown row in the whole ledger, with its line number, until it is resolved.api_equivalent_cost for the month and is never added to cash. claude_code_latest_week is the newest week of claude-code rows anywhere in the ledger, so a brief can say how old the Claude Code numbers are.ledger/runs.csv runs whose sealed_date is in the month, each actual with every adjustment for that run applied. actual_total adds their actuals; compared adds estimate and actual over only the runs that have both. Runs are never added to cash or to API-equivalent: the weekly Claude Code rows already price the same sessions.--json money values are strings with two decimals (exact, no floats). Other skills read these keys:
month, as_of, currency
cash: total, by_provider{}, by_project{}, rows
envelope: usd, status, spent, pct, warning_pct, over_warning, over_envelope (or null)
monthly_equivalent: total, lines[{provider, service, billed_cost, period_start, period_end, months, monthly}]
renewals[{vendor, plan, amount_usd, cadence, next, days}]
renewals_undated[{vendor, plan}]
unknown[{line, charge_date, provider, service, evidence}]
api_equivalent: total, by_project{}, claude_code_latest_week (e.g. "2026-W43", or null)
runs: count, actual_total, compared{runs, estimate, actual},
rows[{source, run_id, sealed_date, tier, estimate_usd, actual_usd, estimate_tokens, actual_tokens,
spend_entries, estimated_entries, adjustments, line}] (missing figures are null)
uv run --python 3.12 <skill dir>/scripts/books.py claude-code BOOKS_DIR --since YYYY-MM-DD [--until YYYY-MM-DD] [--logs DIR] [--dry-run] [--json]
Runs only on the machine that holds the Claude Code session logs (~/.claude/projects, read recursively), so never in the scheduled cloud run. Python 3.10 or later, standard library only, run through uv. Run --dry-run first.
--since rounds down to its Monday. A week is written only once its Sunday is before --until (today in UTC by default), so a week is never partial. Run on a Sunday, the newest week is the one that ended a week earlier.claude-code row is skipped, so a later paths: change never counts a week twice under new project names. To re-split a recorded week, add adjustment rows.usage-equivalent row per project per week: billed_cost 0, api_equivalent_cost priced from scripts/pricing.json, evidence claude-code:2026-W43:project. Rows go through the same path as append, so a rerun adds nothing and the full check runs first.paths: entry (in projects.yaml, ~ allowed) is its longest directory prefix; no match is unassigned. Add paths: [~/code/x] to a project to claim its sessions.pricing.json is never guessed. The output lists its tokens as unpriced and leaves its cost out of every total. Add it to the table with the price from the source URL.fast_multiplier when the table has one; otherwise they are priced at standard rates and counted.pricing.json carries its source and as_of. check warns when as_of is more than 90 days old. Refresh the table from the source, then update as_of.vercel api /v1/billing/charges ... > focus.jsonl # FOCUS v1.3, one JSON object per line
uv run --python 3.12 <skill dir>/scripts/books.py vercel BOOKS_DIR FOCUS_JSONL [--through YYYY-MM-DD] [--dry-run] [--json]
Run --dry-run first. Standard library only; Python 3.10 or later, through uv.
ChargePeriodStart and ChargePeriodEnd, so a 07:00Z start and an 08:00Z start (DST) both fall on the right date. Weeks are ISO weeks (Monday to Sunday).--through (today in UTC by default), because Sunday Pacific ends on Monday 07:00Z or 08:00Z. And it is complete: Vercel sends one row per series per day, even at $0, where a series is a (ServiceName, SkuId, RegionId, Tags) combination (the real file has 815 of them over 75 services, and a missing field counts as empty). Every series seen anywhere in the input must have a row on each of the week's 7 days. A project that first appears mid-file therefore leaves the earlier weeks incomplete unless Vercel zero-fills it, which it does today. A closed week the input only partly covers (it starts or stops mid-week) is incomplete too, so fetch from a Monday. An input with no JSON rows, or only Purchase rows, is an error, since the fetch usually failed.incomplete_weeks, and the command exits 1 after writing the complete weeks. This is how a truncated or failed fetch shows up, so the weekly run must check the exit status and refetch. The rule cannot see a file cut exactly at a service boundary: the lost services leave no row to miss, and the weeks look complete. Exit status 0 does not prove the fetch was whole.Purchase rows (the plan fee) are skipped and counted; the Pro fee comes from Gmail receipts.projects.yaml whose resources: lists vercel:<ProjectName> (a name under two projects is an error). Rows with no ProjectName go to shared; a name that is not listed goes to unassigned and the report names it, so you can add it to projects.yaml as proposed.shared, so the books show the week was read. A project whose week is not zero but rounds to under $0.01 is listed in the report (below_one_cent, with its exact cost), not booked. A week total of -$0.01 or less (a credit) is booked as usage with a negative billed_cost; the books check allows it.usage, verified, source vercel-focus, evidence vercel-focus:2026-W44:project. They go through the same path as append, so the full check runs first. A week that already has any vercel-focus row is skipped whole: a rerun adds nothing, and a late change never splits a recorded week. To correct one, add adjustment rows.uv run --python 3.12 <skill dir>/scripts/books.py runs BOOKS_DIR REPO_DIR [--run RUN_ID ...] [--source NAME] [--ledger PATH] [--dry-run] [--json]
Reads the agent-ledger runs in REPO_DIR/.audit/ and books one row per sealed run in ledger/runs.csv: what the run's charter estimated beside what its spend entries recorded, linked by run id. Run --dry-run first. It needs the ledger CLI (--ledger names another path).
sealed_date, source, run_id, row_type, tier, staffing, estimate_usd, estimate_tokens, estimate_wall_clock, budget_usd, budget_tokens, actual_usd, actual_tokens, actual_wall_s, spend_entries, estimated_entries, evidence. row_type is run or adjustment.ledger verify --root REPO_DIR first. If that fails, it prints the last lines of verify's output and refused: ..., books nothing and exits 1. A broken chain anywhere in the repo stops the whole import.seal and .audit/INDEX.jsonl lists it. An open run is listed as refused ... not sealed and booked on a later import. Naming an unsealed run with --run exits 1.charter.md): estimate.usd, estimate.tokens, estimate.wall_clock, budget.usd, budget.tokens, tier and staffing. A run with no charter has empty estimate cells; nothing is guessed.spend entries the way ledger spend does: each entry is spend since the previous one, and an entry without a whole, non-negative usd_micros is left out and named by seq in the report. Micros become dollars rounded half up to the cent. actual_tokens and actual_wall_s add tokens and wall_s where present. spend_entries counts every spend entry and estimated_entries those with estimate: true, so a reader can see that the actual is itself an estimate.no_spend and not booked.ledger-run:<source>:<run id>. source is the name of REPO_DIR's origin remote (or its folder name); --source overrides it. A run already in the book is skipped, so a rerun adds nothing. Rows go through the same path as append, so the full check runs first.adjustment row with books.py append BOOKS_DIR ROWS_CSV --book runs. It names the source and run_id, a sealed_date (the day of the correction), actual_usd as the change (negative lowers it), optionally actual_tokens, and evidence saying why. Summary applies it to the run's actual.The scheduled cloud brief can't read the Mac's logs, and the Vercel CLI is logged in only on the Mac, so scripts/weekly-claude-code.sh runs claude-code and vercel there and hands the rows to the weekly brief PR:
<skill dir>/scripts/weekly-claude-code.sh --repo OWNER/BOOKS [--quality-repo OWNER/QUALITY] [--agentfiles-lock FILE] [--dry-run]
cfo/brief- or claude/cfo-brief- branch is open, it adds a commit to the oldest one's branch. Otherwise it uses cfo/brief-<next Sunday> (the Sunday after, if today's brief is already on main): it builds on that branch if it exists unmerged, else creates it from main, and opens the PR. The cloud run adds its commit to an open brief PR, so the week still ends in one PR. Dates are America/Denver (CFO_TZ).cleanupPeriodDays in ~/.claude/settings.json, default 30; it refuses a value under 9). Older logs may be partly deleted, and a partial week would be written as a verified total. A value set only in managed or local settings is not read.vercel books it as closed; both Mondays are midnight Pacific (07:00Z in summer time, 08:00Z in winter time). It runs vercel api '/v1/billing/charges?from=...&to=...&teamId=...' --method GET into its temp directory, with the team from vercel teams ls (the only team, or the current one of several), then vercel on the books. A missing or logged-out vercel CLI skips this part and logs it. A failed fetch imports nothing, and an exit 1 from vercel (an incomplete week) books nothing; either fails the job after the Claude Code rows are pushed, so the week is refetched, never booked by hand. Team and project ids stay in the temp directory; failure output is shown with ids redacted. A missed week is not caught up: the cloud brief names it, and you import it by hand.ledger/charges.csv, runs check --base origin/main first, and never pushes to main, merges or force-pushes. Nothing new means no commit and no PR. If the push is rejected because the cloud run pushed first, it refetches and retries once. Pushes authenticate through gh.--quality-repo (default: the GitHub remote of the checkout in QUALITY_BOOKS; with neither, this step is skipped and the job runs as before), a second pass runs after the cfo rows are pushed. It clones the quality books and picks a quality/brief- branch by the same rule as step 2 (an open PR's branch from this repo, else an unmerged quality/brief-<Sunday>, else a new one from main). It then runs bstack's quality.py book-skills (QUALITY_PY overrides the path; without bstack installed the pass is skipped) to book one row per skill invocation in the Claude Code and Cursor transcripts for each closed ISO week, from the same start date as step 3. The quality books must already hold books/skill-uses.csv (header only is fine); without it the pass logs that and stops. Skill versions come from --agentfiles-lock FILE, which defaults to AGENTFILES_LOCK, else $AGENTFILES_HOME/agentfiles.lock; with none, versions stay empty. --install writes the path into the launch agent, because the agent's environment has neither variable. It commits only that file as "Skill uses for ", runs the quality check --base origin/main first, pushes and opens a "Quality brief : skill uses (brief pending)" PR when none was open, and a rerun books nothing new. Its log lines hold counts and week names, never a skill or project name. A failure in this pass never holds back the cfo rows: the job fails at the end, naming it alongside any Vercel problem. --dry-run runs book-skills --dry-run and pushes nothing.Install it once; the agent starts the job every hour, and the job (--scheduled) does work only from Sunday 06:00 to Monday 23:59 local time, until one run of that window finishes without a failure:
<skill dir>/scripts/weekly-claude-code.sh --install # carries --quality-repo and --agentfiles-lock when given or defaulted; also: --status, --run-now, --uninstall
--install checks that git, gh (logged in) and uv are reachable (vercel is optional; log it in with vercel login), writes the launch agent, loads it, and raises Claude Code's cleanupPeriodDays to 120 if it is lower (the old settings file is kept as settings.json.bak). Rerun it after moving agent-kit. The books repo comes from the GitHub remote of the checkout in CFO_BOOKS; pass --repo OWNER/NAME instead when CFO_BOOKS isn't set. A books repo can wrap these in a Makefile (make install, make status, make run, make uninstall).
A Mac that is asleep on Sunday morning runs the job at its first full wake. A brief dark wake (no display, network may drop) is skipped with one log line, and the next hour tries again. A failed run is retried every hour until Monday night, then the window closes; a Mac that is off the whole window skips the week, and the Claude Code and skill-use passes pick it up on the next run while their logs are still kept (the Vercel week is not caught up). The finished window's Sunday date is kept in ~/Library/Application Support/agent-kit/cfo-claude-code.done (CFO_STATE_DIR moves it); delete the file to rerun a finished week. The log is ~/Library/Logs/cfo-claude-code.log (a few lines a week, never rotated).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub lyddonb/agent-kit --plugin cfoOther plugins' skills for the same job
4 skills in this plugin
/cfo-briefThe CFO's weekly routine. Collects new receipts, invoices, vendor notices and billing data into the private books, checks spend against the budget, finds waste and renewals, writes a brief, and sends it with decisions and questions for the user to approve. Proposes; never acts. Use for "CFO brief", "weekly finance review", "check my spending this week", or from a weekly scheduled task./estimate-runEstimate what an agent run, a charter or a whole project will cost before it starts, in both cash and API-equivalent terms, with a typical and a high figure based on past runs where the books have them. Fills a run charter's estimate and budget. Use for "what will this cost", "estimate this run", "price this charter", "is this worth running", or when writing a run charter./