caiqianha

Claude Code Ledger — Security skill for Claude Code

Security community

Local-first cost & tool-call audit for Claude Code.

How to install Claude Code Ledger

This entry records only its repository, not the path inside it, so there is no exact command to give. Open caiqianha/claude-code-ledger and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Claude Code Ledger does

Local-first cost & tool-call audit for Claude Code. Finds wasted context: repeated reads, blind retries, huge tool outputs.

Alternatives in Security

  • ThinkWatch — Self-hosted AI API and MCP gateway for organizations: SSO and RBAC, per-user identity for MCP tool calls, PII 817 ★
  • Data Viz Audit — Audit a data visualization for chart type selection, accessible color palette, annotations, and anti-patterns 309 ★
  • Memory Self Review — Mine recent agent history (claude-mem + usage stats) for recurring failures and repeated patterns, audit MEMOR 297 ★

README

ccledger

[![npm](https://img.shields.io/npm/v/claude-code-ledger?color=cb3837)](https://www.npmjs.com/package/claude-code-ledger) [![license](https://img.shields.io/github/license/caiqianha/claude-code-ledger)](./LICENSE) [![node](https://img.shields.io/node/v/claude-code-ledger)](./package.json) ![deps](https://img.shields.io/badge/dependencies-0-success)

**Local-first cost & tool-call audit for [Claude Code](https://claude.com/claude-code).**

![ccledger demo](https://raw.githubusercontent.com/caiqianha/claude-code-ledger/main/assets/demo.gif)

[Open the demo HTML report](https://caiqianha.github.io/claude-code-ledger/) · Demo recorded on synthetic data from `scripts/demo-data.mjs`. No real session appears anywhere in this repo.

Reads the session logs Claude Code already writes to `~/.claude/projects/`, and tells you where the tokens went: per day, per project, per session, per model, per tool, plus the call patterns that burn context for nothing.

Why

Token dashboards tell you *how much* you spent. `ccledger` also tells you *on what*, at the tool-call level:

  • which tool is called most, fails most, and returns the most bytes into your context
  • the same file read 8 times in one session
  • an identical command re-run right after it failed
  • a 60 KB tool output that gets re-sent on every following turn
  • long sessions whose cache hit rate collapsed
  • what each tool result actually cost once it sat in the context window for the rest of the session

Each finding comes with a one-line hint, and `ccledger advise` turns the lot into a paste-ready `CLAUDE.md` block.

Install

npm install -g claude-code-ledger   # installs the `ccledger` command
npx claude-code-ledger              # or run it once without installing

Node 18+. Zero runtime dependencies. The npm package is `claude-code-ledger`; the CLI is `ccledger`.

Usage

ccledger [command] [options]

Reports
  summary          Totals, per-model split, top tools, top context