Skip to content

pr-cost: annotate GitHub PRs with session AI cost - #31

Open
ideogram-fredtran wants to merge 5 commits into
cheshirecode:mainfrom
ideogram-fredtran:fred/pr-cost-hook
Open

pr-cost: annotate GitHub PRs with session AI cost#31
ideogram-fredtran wants to merge 5 commits into
cheshirecode:mainfrom
ideogram-fredtran:fred/pr-cost-hook

Conversation

@ideogram-fredtran

Copy link
Copy Markdown
Contributor

Summary

  • Adds a small local tool that, when you open a GitHub PR from Cursor, Claude Code, or Codex, can record how much that agent session cost and optionally leave the number on the PR as a comment.
  • Cursor and Claude hooks are already installed on this machine. Codex needs an opt-in gh wrapper (not on PATH by default). Comments stay off unless PR_COST_HOOK_LIVE=1.
  • Includes a paste-ready Claude handover (skills/pr-cost/handovers/claude-comment-pr-cost.md) so a fresh Claude session can comment its own cost on this PR.

Test plan

  • python3 -m unittest discover -s skills/pr-cost/tests -q (7 tests)
  • Confirm this PR gets a Codex cost comment after open (dogfood, live annotate).
  • Paste skills/pr-cost/handovers/claude-comment-pr-cost.md into Claude Code and confirm a second comment for Claude cost.
  • Confirm no prompt text or file contents appear in either comment.

Create a stdlib-only pr-cost skill that emits a typed payload, records local ledger entries, and only posts GitHub PR comments when live writes are explicitly enabled.
Thin harness wrappers call the shared collector after gh pr create.
Codex is an opt-in gh wrapper because it has no native PR hook.
Prove Cursor, Claude, and Codex wrappers write a ledger on gh pr create
without invoking GitHub while live writes stay off.
Paste the Claude handover into a fresh session to comment Claude cost on
an open PR. Codex token_count JSONL can be read the same way.
@ideogram-fredtran

Copy link
Copy Markdown
Contributor Author

AI cost payload for the session that created this PR:

{
  "confidence": "estimated",
  "generated_at": "2026-08-20T20:17:07+00:00",
  "harness": "codex",
  "model": "gpt-5.6-sol",
  "notes": "Dogfood live annotate --harness codex. Tokens from the latest local Codex JSONL token_count (session 01a0207b, cwd was a ui worktree, not this repo). USD estimated at gpt-5.6-sol catalog rates $5/$30 per MTok without a cache discount. This PR was opened from Cursor via the ideogram-fredtran fork.",
  "pr_url": "https://github.com/cheshirecode/dotfiles/pull/31",
  "schema_version": "pr-cost/v1",
  "session_id": "01a0207b-1898-7240-bc55-9968ab569b57",
  "tokens_in": 924232,
  "tokens_out": 5942,
  "usd": 4.7994,
  "window_end": "2026-08-20T18:44:52.141Z",
  "window_start": "2026-08-20T18:42:13.335Z"
}

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