convez.ai
SkillDevOps & InfraestruturaIntermediário
LDoubleU28

Claude Session Log

LDoubleU28/claude-session-log

Registra sessões Claude, rastreia custos e correções com visibilidade total

Ver no GitHub
InicialPluginScore · de 0 a 100

Skill e pipeline para capturar o que cada sessão Claude Code realizou, com precificação automática de transcripts locais. Fornece visibilidade de custo por sessão, registra correções e falhas, e estrutura dados para análise de desempenho de agentes.

Instalação

$npx convez-ai LDoubleU28/claude-session-log

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
2
Forks
1
Acompanhando
0
Saúde
42%
Último commit
há 5 meses
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Rastrear custo real por sessão de Claude Code
  • Documentar correções e iterações para criar conjuntos de avaliação
  • Analisar taxa de acerto na primeira tentativa e padrões de erro
  • Atribuir gastos de IA entre projetos, skills e modelos

Veredito

Solução pragmática para o problema real de invisibilidade de custos em sessões Claude Code. O design centrado em correções como dado valioso diferencia esta ferramenta; recomendada para equipes que precisam governança de IA e rastreamento de gastos granular.

README

A tradução para o português deste README ainda está na fila.

claude-session-log

I kept finding that sessions where my agent did real work disappeared the moment the conversation ended. No record of what was tried, what failed, what was reusable. Worse, my per-session cost was invisible: the Anthropic Admin API does not attribute Claude Code usage to individuals, and the per-user view in claude.ai Analytics is capped at the top 20. So I built two small things that together solve the problem.

The first is a Claude Code skill called /session-log that captures a structured JSON record of what each session did: what shipped, what the agent got wrong, what the corrections were, which subagents got dispatched and on which model. The second is a script that walks the local Claude Code transcripts on disk and prices them against the published Anthropic rate card. Joining the two gives you the unit you actually want: "this session cost $X, did Y work, made Z corrections, produced these assets."

The schema is opinionated about one thing: corrections. The most valuable field in a session record is where the agent went back and forth. A zero-correction session is a first-try win; a three-correction session is a learning source. Log them honestly. Over time they become a labeled training set for evals, and the patterns surface where the skill or SOP is broken.

How it works

Three files matter:

  • .claude/commands/session-log.md — the skill. Drop it into ~/.claude/commands/ (or a project's .claude/commands/). It reconstructs the session from conversation context, presents a compact summary in chat, and writes the JSON record to sessions/<project>/YYYY-MM-DD-<slug>.json.

  • scripts/build_sessions.py — aggregator. Walks sessions/*/*.json, computes rollups (total minutes, build-vs-run split, first-try accuracy rate, fixes shipped count), writes data/sessions.json.

  • scripts/build_claude_usage.py — the cost pipeline. Walks ~/.claude/projects/*/*.jsonl (every local Claude Code transcript on your machine), extracts model + token usage from each assistant message, prices each against the rate card baked into the script, aggregates by day, project, model, skill, customer, activity. Writes data/claude-usage.json.

The dashboard part is up to you. Records are JSON; render them however you want. I built a private dashboard for myself; you might just want a folder of markdown files, or a Notion sync, or nothing at all.

Quick start

git clone https://github.com/LDoubleU28/claude-session-log.git
cd claude-session-log
ln -s "$(pwd)/.claude/commands/session-log.md" ~/.claude/commands/session-log.md

In any substantive Claude Code session:

/session-log [optional-project-name]

To price your transcripts:

python3 scripts/build_claude_usage.py

Design choices

  • Records are data, not HTML. The schema is what compounds. The renderer is the easy part and deliberately not included. Store records wherever you already work.

  • Corrections are the point. Most logs capture what shipped. The valuable half is what the agent got wrong, what it should have done, and what fix landed. That field seeds eval regression cases.

  • Five attribution axes. Every message gets attributed to project, skill, customer, activity, and model family. The five together let you slice your AI spend the way Finance slices anything else.

  • The agents field. Every subagent dispatch gets recorded with name, model, task, and rationale. Over time the data tells you which task shapes warrant which tier. See docs/MODEL_SELECTION.md for the framework.

Configuration

Two heuristics in scripts/build_claude_usage.py need your input:

  • CUSTOMER_DEFS — list of (customer-name, regex-patterns) tuples to match prompt text and file paths. Empty by default.
  • classify_tool_use — path heuristics for activity bucketing. Has generic examples; replace with your repo patterns.

Pricing rates live at the top of the script. Update when Anthropic changes pricing.

Read more

  • sessions/README.md — the full per-record JSON schema.
  • docs/ARCHITECTURE.md — why corrections, why per-session cost, why five axes.
  • docs/MODEL_SELECTION.md — when to use Haiku vs Sonnet vs Opus, and the flex pattern within a single skill.

License

MIT.

Ver o original no GitHub

Bom para

Relacionados