↑ ↓ 移动 · Enter 打开 · Esc 关闭点按一个结果

架构
skill · observer 类 · sonnet

audit-usage

跨多次运行读取执行轨迹:每个 skill 和智能体的可计费 token、耗时、失败、权限,以及接下来该打开哪份报告。

skill · observersonneteffort low不写任何文件随生成的项目导出
§ skill 的定义

audit-usage,逐节说明

skill 自己的 SKILL.md 的各个章节,节选。悬停或点击一个章节,查看它引用的项目规则、模板和 references/ 文件。章节也是标签:点击即可跳转。

nerviz/.claude/skills/audit-usage/SKILL.md

## Consolidated trail

!java "${CLAUDE_PROJECT_DIR:-.}/.claude/hooks/ArchHook.java" audit summary 2>&1

Everything below reads. This skill never writes into .claude/audit-usage/ and never edits project code — the trail is written by ArchHook.java audit, at Stop, and by nothing else.

Answer in English, the language of the reports themselves, so the consolidated view and the per-run report read as one document. Reports and ledger rows written by an older hook are in Portuguese (✅ sucesso); quote them as they are, never translate a number or a status out of them. Reports written before decision 0134 also carry a cost in USD; quote it only from that report, never as a figure of the trail.

## When the block came back empty

The trail is off: .claude/audit-usage/ does not exist, and audit summary prints nothing at all. That is the switch, not a failure. Say so, and give the two commands that turn it on — creating the directory is enough, the hook is already wired in .claude/settings.json:

mkdir -p .claude/audit-usage
printf '.claude/audit-usage/.state/\n' >> .gitignore

Then stop. Do not create the directory yourself: switching a versioned audit trail on is the user's decision, not a side effect of asking what it holds.

If the block says closed runs: 0, no run has finished yet. Any report listed under ⏳ No ledger line is from a run in progress — report it as such and say the ledger line is written only when the run closes.

## What the block already did

ArchHook.java audit summary reads history.jsonl (one line per top-level run) and nodes.jsonl (one line per skill or agent that run chained) and does the arithmetic: totals, spend per piece without double counting, failure rate, and the reports worth opening. The aggregation is Java on purpose — the ledgers grow without bound, and injecting them raw would cost tokens on every read and leave the sums to you.

Never recompute a number the block printed, and never read the .jsonl files to re-derive one. Your job is rendering and judgment, not arithmetic.

What the block's vocabulary means:

… 此处截断,其余见文件

### 1 · Route on the argument

ArgumentDo this
empty§ 2 — consolidated view
last / último§ 3 for the most recent report the block names
a skill or agent name (new-feature, java-spring-boot-developer, …)§ 2 reduced to that piece's line, then § 3 for its newest report: ls -1t .claude/audit-usage/*--<name>.md when it ran as a root; otherwise the newest run of its line in grep '"skill":"<name>"' .claude/audit-usage/nodes.jsonl — a chained piece's report is its parent's
any other texttreat it as a fragment of a report filename (ls -1t .claude/audit-usage); § 3 for the single match. Two or more matches: list them and ask which

### 2 · Consolidated view

Present the block, in its order, keeping its tables and the text bar chart intact — bars are proportional to billable tokens, not to duration, which is wall-clock and includes time the user spent thinking. Then add what the block can't:

  1. One line of reading above the tables — where the tokens went, in words.
  2. Where it went — from the Where the pieces spent block, the piece whose calls
  3. Health — name the piece with the worst failure ratio. A piece that fails
  4. What to read next — the single most relevant report, and the exact

If the plan windows say not configured, say so and point at .claude/audit-usage/plan-limits.json, set with /project-config or java -jar .claude/hooks/ArchHook.jar config set plan-limits pro.five_hour_tokens <n> (and pro.weekly_tokens) — never by editing the JSON, which guard refuses — the billable tokens the person saw a Pro window hold (the audit's total when /usage reached 100%). Never suggest a budget: Anthropic publishes none, and one written from memory looks as authoritative as a measured one. Never convert anything to a currency either: the trail prices nothing, and a rate written from memory is wrong the day after it changes.

### 3 · Single run

Read the .md file. It is already a finished, icon-rich report — do not re-render it and do not paste it back in full. Summarize in at most six lines: what was run, the outcome, its billable tokens, the longest step, where it spent (from 🔎 Where the run spent: the dominant tool, the costliest turn, the peak context), and anything that deserves attention (⏳ in progress, compaction incidents, permissions added, repeated tool failures — quote the error's first line the report already redacted, never more). Then give the path so the user can open the whole thing.

Point out ⏳ in progress when you see it: it means the run never closed — the session was killed, or it is still open right now.

## What this skill will not do

  • Never edits or deletes anything under .claude/audit-usage/. Pruning old reports
  • Never prices the trail. The numbers come from audit summary, in tokens; a cost
  • Never reads .state/. Those are the hook's open append-only logs; the rendered
  • Never quotes a redacted value. The reports blank credential-shaped text on the way

## Why this is a skill, and why the hook ignores it

The hook already answers "what happened in this run", and audit summary does the sums across runs. Nothing turns that into "which piece is eating the budget, and which report should I open" — judgment over data, routed by an argument, which is a procedure, not a norm and not enforcement.

audit-usage is one of the skills the trail does not record — the observers: its class, observer in skill_classes of .claude/schemas/extensions.json, declares audited: false, and arch-doctor sits in the same class. Without that, reading the trail would append a report about reading the trail, and every later read would be mostly reads.

Invoking it still closes whatever run is open, and that is the useful half: within a single session a report stays stamped ⏳ in progress until something ends the run, so asking for the report is what finalizes it.

arch-adopt is never recorded either — fixed in its own class override. Any other piece can be switched per project in .claude/audit-usage/audited.json, one of the files of .claude/ the project owns and /arch-adopt never overwrites — through /project-config or java -jar .claude/hooks/ArchHook.jar config set audited skills.<name> false, the only writer; doctor's Audit overrides line validates it.

Runs on sonnet with effort: low: audit summary already did the sums, and what is left is ranking and rendering (@.claude/decisions/0080-procedural-skills-on-sonnet.md).

在 GitHub 上打开完整文件 →
§ 行为

它读什么、写什么、拒绝什么

skill 自己的契约,取自 SKILL.md,保留原文。

来源:SKILL.md § Contract(nerviz e4cae27)。

§ guard 与 hook

guard 如何处理它

observer 是这个 skill 的类别,左侧的列表就是它的领地。skill 在自己的提示上运行时阶段打开,ArchHook 对照这份列表判断每一次写入。右侧的文字是 hook 自己输出的。

audit-usage 的 write_allow

  • 任何文件:领地为空

拒绝以退出码 2 结束,消息回到模型。

> /audit-usage …
UserPromptSubmit
  guard prompt                     exit 0
# phase opened: audit-usage (class observer)
# write_allow: [] — this class writes no file
§ 如何被调用

由谁调用

它不是某条链上的步骤。它由自己的提示 /audit-usage 启动,guard 像对待其他 skill 一样对待它:阶段打开,其类别的领地生效。

← 返回链路