Skip to content

feat: add /cfo skill — session cost + AI spend dashboard - #34

Closed
shivanipods wants to merge 3 commits into
garrytan:mainfrom
shivanipods:feature/cfo-skill
Closed

shivanipods wants to merge 3 commits into
garrytan:mainfrom
shivanipods:feature/cfo-skill

Conversation

@shivanipods

Copy link
Copy Markdown

Summary

Adds a /cfo skill that answers "what am I spending?" without leaving Claude Code.

  • Session banner — cost, elapsed time, and git line count for the current session
  • 30-day spend dashboard — daily spend, spend by project/branch, prompt repetition detection with waste estimates, personalized cost-saving tips
  • Multi-tool support — manually log spend from Cursor, Lovable, ChatGPT, etc. via ai_spend.py --add
  • Team/org views — share aggregated spend across a team via a shared directory (--export, --team, --org)

Reads token usage directly from ~/.claude/projects/ transcripts — no API keys, no third-party tracking.

What's included

  • cfo/SKILL.md — skill prompt (4 steps: find script, gather session metrics in one atomic bash call, run dashboard, print banner)
  • cfo/ai_spend.py — ~1000-line stdlib-only Python dashboard script, originally from @shivanipods/claude-session-skill

Notes for reviewer

  • README voice: The /cfo section is written in third-person to let you adapt it to your voice if you accept the PR
  • ai_spend.py authorship: This script was written by me (@shivanipods) and is MIT-licensed — happy to add a header comment if you'd prefer
  • New requirements: jq and python3 (3.10+) — added to the Requirements line in README; both are pre-installed or one brew install jq away on macOS
  • setup script: No changes needed — it auto-discovers any cfo/ subdirectory with a SKILL.md

Test plan

  • ./setup symlinks cfo alongside the other skills
  • /cfo runs and outputs session banner + spend dashboard
  • Works from a project with no prior spend history (shows empty dashboard gracefully)
  • python3 cfo/ai_spend.py --help runs without errors (stdlib only, no pip required)
  • jq is the only new system dependency

🤖 Generated with Claude Code

Shivani Poddar and others added 3 commits March 13, 2026 10:04
Adds a new `/cfo` skill that shows:
- Current session cost and elapsed time as a banner
- 30-day AI spend dashboard for the project (by day, by branch)
- Prompt repetition detection with waste estimates
- Personalized cost-saving tips based on usage patterns

Includes `ai_spend.py`, a ~1000-line stdlib-only Python script
(originally by @shivanipods) that reads token usage directly from
`~/.claude/projects/` — no API keys, no third-party tracking.
Also supports team/org aggregation and manual logging of spend
from other AI tools (Cursor, Lovable, ChatGPT, etc.).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Replace deprecated datetime.utcnow() with timezone-aware
datetime.now(timezone.utc) in build_export_payload.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@garrytan

Copy link
Copy Markdown
Owner

Python script in a Bun/TS project. Closing.

@garrytan garrytan closed this Mar 18, 2026
garrytan added a commit that referenced this pull request Oct 30, 2026
…n flags (GSTA-167)

Each build records its plan flags, --range, --plan-file and --fanout in the manifest.
build --like <dir> fills every flag not given from that record, --out-dir defaulting
to <dir>, and refuses (exit 2) a dir without one. The Red Team build, Step 11's
adversarial and outside-voice packets, PACKET_DEFERRED and collect's pending hint use it,
so a later build no longer misbuilds from hand-copied flags (#34, #36).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
garrytan added a commit that referenced this pull request Oct 30, 2026
…th origin skips gh; RUNTIME_LINES leaves data files out

/ship review of #3633 (security CRITICAL x2): gh pr list --head "$branch" ran through sh(), so a branch named x$(cmd) executed. Replay 3 of gstack-evals #34: a local bare origin under GH_HOST failed the carry check, and RUNTIME_LINES counted JSON. The fixture's origin is now a GitHub URL mapped to the bare repo by insteadOf. Failing-first tests.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
garrytan added a commit that referenced this pull request Oct 30, 2026
…very capped review-log start names its reservation

gstack-evals #34 round 3: close printed budget_check_skipped dispatches=3 for
the Step 9 and 11 rows, which ran in handoff child 1: the root's audit matched
review-log rows against its own ledger's reservations only. review-log --start
already refuses without --reservation under an active capped run. verify-handoff
now records each child ledger on the parent's handoff and close walks that tree.
Step 9 item 2 builds and checks its batch before REVIEW_START, the fix-check and
both Step 11 voices start on --reservation, and the pass program starts once
per logged row.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
garrytan added a commit that referenced this pull request Oct 30, 2026
…--finish settles it

gstack-evals #34 round 3: the pass program's start-once-per-role rule gave the
Red Team batch an extra --start review token that no row ever finished. A later
batch of the same Step 9 pass (the Red Team or an ADMIT remainder) now takes no
start, and --finish REVIEW_START settles the open later batches of the step
reserved after the started one, so none stays reserved at close.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
garrytan added a commit that referenced this pull request Oct 30, 2026
…spatch program's reading pair

gstack-evals #34 round 3: the docs-audit settle ran from a later program, so the
reader was unmeasured. Under a cap its dispatch is now one program: check on
build's BUDGET_NEXT, BEFORE right before the reader starts, the poll, AFTER, and
settle --dispatched-at <BEFORE> --reading <AFTER> --readers 1 in that program.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants