Repository navigation
ck 0.1.19: a small cost script - #50
Merged
Merged
Conversation
scripts/cost.py prints "<session name> cost summary": a row per lane (main, each subagent by type, Claude Code's background calls) and a column per kind of token, each cell in tokens and dollars. Prices come from Anthropic's pricing page, fetched at most once a day; an unlisted model is ?, never $0. The total is checked against Claude Code's own cost record. /ck:cost shows it; a Stop hook prints the cost so far once the session has a pull request; a PostToolUse hook posts the table to the pull request after gh pr merge and logs it for /ck:cost history. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it adds
scripts/cost.py(standard library): one session's cost as " cost summary", a row per lane (main session, each subagent by type, and background: what Claude Code's own cost record counts beyond the transcripts) and a column per kind of token (input, output, cache write, cache read), each cell in tokens and dollars.platform.claude.com/docs/en/about-claude/pricing.md), fetched at most once a day into~/.cache/ck/pricing.md. A model the page does not list is priced as ?, never $0. Each request is priced on its own (5-minute and 1-hour cache writes at their own rates, Haiku 5.5's higher price over 100K tokens)./ck:cost [history | <session id>], typed only.gh pr mergeand logs a line to~/.claude/ck-cost.jsonl, which/ck:cost historylists.Tested
bash tests/run.sh: 485 passed, 0 failed. Section 22 uses a made-up fixture session and a stubgh.🤖 Generated with Claude Code