Skip to content

feat(usage): add usage-report, an opt-in plugin usage report - #137

Merged
mmaclay merged 6 commits into
mainfrom
feat/usage-report
Nov 16, 2026
Merged

mmaclay merged 6 commits into
mainfrom
feat/usage-report

Conversation

@mmaclay

@mmaclay mmaclay commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Origin: the maintainer's mine of their own Claude Code transcripts, 2026-11-09 and 10 (no issue)
Sandbox: new skill, so no current-plugin baseline; branch, Haiku, --check, counted after the two sandbox environment fixes (writes under ~/.claude, mktemp and TMPDIR): usage-report-payload 6/6, usage-report-standing-answer 4/4, usage-report-file 8/8, trigger-usage-report 2/2, tracker-gh-usage-report-standing-answer 6/6, tracker-gh-usage-report-since-last 8/8, tracker-gh-usage-report-collect 5/6 (the miss was wording, fixed, then 4/4)
Canary: not yet run

Why

What we know about how the plugin is used comes from one person. Mining the maintainer's
transcripts showed real use diverging from where the sandbox puts its weight: /work, the
workflow's entry point, ran 296 times in scenarios and never in real sessions, while pr-review,
the most-used skill, had a small share of the scenarios. The maintainer is also the plugin's
author, so that sample says little about the five or six colleagues who use it daily, and their
transcripts sit on their own machines. There was no way for them to share what they do without
sending code, prompts or project names. Once this merges, anyone can run one skill to see how
they have used the plugin and, on a yes, send the maintainer a report of numbers and fixed words
only, and the maintainer can merge everyone's reports into one table.

What changed

/lasp-dev:usage-report counts plugin use since the person's last report. It shows them
their own summary first, then the exact report, and asks for an optional note. It sends nothing
without a yes, and a yes counts only when given after the report is shown, so "send my usage
report" typed up front does not open the gate. The report goes to a usage-report issue here by
default, or to a file with file for anyone who wants to send it privately.

What a report holds:

  • skill and agent runs, typed or model-started, turns and tokens;
  • how each question was answered, by its header: recommended, another option, free text or
    declined;
  • plugin script exits, hook decisions and denial categories;
  • skill-to-skill chains;
  • what the person did after each run, labelled locally from six outcomes;
  • how many personal skills compete with each plugin skill.

/usage-report collect, for the maintainer, reads the report issues, adds file reports with
their sender, and runs scripts/usage_merge.py, showing its output verbatim. It posts nothing.

Docs: a GUIDE section, the README row, the two contracts in docs/contracts.md, and the
ROADMAP. The "Gate counts by hook" row is removed: the report's question counts answer it.

Design choices a reviewer may question

  • An allowlist, not redaction. Every string in a report comes from a fixed vocabulary:

    • the installed plugin's own skill, agent, script and hook names;
    • built-in tool names and known denial categories;
    • the plan's enums;
    • question headers only where the asking skill's own files contain the phrase.

    Anything else is written other. A redaction list fails open when it misses something; an
    allowlist cannot leak what it never copies, so a person can check a report in a minute. A test
    seeds a personal word into every free-text field and asserts it appears nowhere.

  • No state file. Claude Code's Bash sandbox refuses writes under ~/.claude by design, plugin
    data included. So the window starts at the end of the person's latest report issue, found
    through the server with a bounded lookup. With none, it starts 30 days back or at their since
    date. Temporary files go in a mktemp -d directory under $TMPDIR.

  • Reports are found by title, not label. GitHub silently drops a new issue's labels when the
    sender lacks push access, so the lookup and collect match the usage-report: title prefix;
    the label is still applied when it attaches.

  • A sha256 digest in each report. On the server path Claude retypes the report into the issue
    body. The skill reads the issue back and checks it at once, offering to correct or resend on a
    mismatch, and the merge refuses any body whose JSON does not match its digest, so a slip cannot
    become a wrong number.

  • The overlap read is frontmatter.awk, not inline. Claude Code replaces $0, $1 and so on
    in a skill body with the skill's arguments; inline, /usage-report file turned the program's
    $0 into file and read nothing. A test now fails on any $<digit> in the skill body.

  • The merge refuses rather than repairs. It refuses a wrong digest, another schema, a
    malformed or unfilled report, a duplicate, or two overlapping reports from one author, naming
    each file. Medians and p90s are kept per report, not averaged. No login or path enters the
    merged result.

Incidental changes

  • scripts/transcript_excerpt.py reads the standard only when it redacts, so importing it reads
    none. skill-feedback's output is unchanged; its tests pass with no assertion changed.
  • The sandbox names its sessions lasp-dev-sandbox (sbx-claude, run.py, rule_cases.py), so
    a report skips them.
  • The sandbox passes a scenario's .sbx-env as CLAUDE_ENV_FILE, and its settings template allows
    Edit(//tmp/usage-report-sbx-*/**). Both are sandbox-only.
  • scripts/coupling.json gains an upper-case LASP pattern. The report reads it to write a
    header naming a project as other, and check_static now fails a bare LASP in the generic
    files. No file matches today.

Limits

  • After the public flip, a report sent as an issue is public under the sender's GitHub name. The
    skill says so before asking; file is the private route. Revisit the default with the flip.
  • An issue is created only through the stub in the sandbox, so the send and its read-back check
    have no scenario. No real report issue has been filed yet; the canary will be the first.
  • The lookup reads the 300 newest issues of any kind. If a person's last report is older than
    that, the window opens 30 days back and the summary says why.
  • Sessions recorded before the sandbox marker existed still count in the maintainer's own
    reports until they age out of the window.

Testing

bash tests/checks.sh --all before review. tests/test_usage_report.py and
tests/test_usage_merge.py guard the vocabulary and the merge refusals; each refusal test was
checked to fail with its check removed.

🤖 Generated with Claude Code. AI assistance level: 5/5 (not read by a person).

mmaclay and others added 5 commits November 10, 2026 21:30
- Add scripts/usage_report.py: reads the person's main and agent
  transcripts since the last report (30 days without one) and writes a
  JSON payload of plugin use only, with every string drawn from a fixed
  vocabulary; anything else is written `other`
- Count skill runs, typed or model-triggered, turns, tokens and reruns;
  question answers by type; plugin script exits; hook decisions;
  denials by category; skill transitions; plugin agent runs
- Write the next message after each run to a separate pending file for
  local classification; it never enters the payload
- Count a resumed or forked session's copied history once, and refuse a
  payload over its size cap
- Add the payload contract, version 1, to docs/contracts.md
- Read the standard in transcript_excerpt.py only when redacting, so
  importing it reads no standard
- Add an upper-case LASP pattern to scripts/coupling.json, which the
  report also reads to write a header naming a project as `other`
- Name sandbox sessions lasp-dev-sandbox in sbx-claude, run.py and
  rule_cases.py so the report leaves them out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add skills/usage-report: counts plugin use with usage_report.py,
  labels what followed each run from a fixed set of six, judges
  overlap of personal skills from their descriptions, shows the
  summary and the whole report, and sends only on a yes given after
  the report is shown
- Send to a usage-report issue on the plugin's repository by default,
  or write a file with the `file` argument
- Start the window at the window end of the person's latest
  usage-report issue, or 30 days back, or a given `since` date; no
  state file is kept
- Keep the report, pending messages and notes in a mktemp directory
  under $TMPDIR, nothing under ~/.claude or .review/
- Add --fill to usage_report.py, which checks labels and overlap
  against the vocabulary and prints the report's sha256 digest
- Require --since, a date or UTC time before now
- Add five usage-report scenarios with a transcript fixture; the
  tracker-github stub orders list_issues by created_at when asked and
  replays seeded issues by another login
- Pass a scenario's .sbx-env to sandboxed sessions as CLAUDE_ENV_FILE
- Add the skill's README row, .github/skills link and contract entries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	sandbox/triggers/coverage.yaml
#	tests/test_sandbox.py
- Add scripts/usage_merge.py: merges usage reports given as issue
  bodies or payload files, summing counts and keeping medians and p90s
  per report; no login or path enters the result
- Refuse, naming each file, a digest that does not match, a schema
  other than 1, a malformed or unfilled report, the same report twice,
  and two reports from one author with overlapping windows; an invalid
  author exits 2
- Add `/usage-report collect` in skills/usage-report/collect.md: lists
  usage-report issues through the server, reads the 5 newest (50 with
  gh), adds file reports with their sender, runs the merge and shows
  its output verbatim; it posts nothing
- Add the merged-reports contract and the issue body's form to
  docs/contracts.md
- Add a GUIDE section on usage reports, update the README rows and
  ROADMAP, and remove the "Gate counts by hook" row
- Add the tracker-gh-usage-report-collect scenario with `reports` and
  `merged` fixture checks, and an Edit allow for the scenarios' /tmp
  run directories in the sandbox settings template

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	README.md
#	tests/test_sandbox.py
@mmaclay mmaclay self-assigned this Nov 16, 2026
…roject skills

- Find usage reports by their `usage-report:` title prefix instead of
  the label, in the window lookup and in collect; GitHub drops a new
  issue's labels when the sender lacks push access
- Read the sent issue back and run usage_merge.py on its body; on a
  digest mismatch, offer to correct the issue or close and resend,
  showing the text either would write
- End a plugin skill run on a typed project skill or command under the
  session's .claude/, and stop on a typed command with no cwd
- Move the overlap read's awk program to frontmatter.awk; Claude Code
  replaced its `$0` with the skill's first argument, so
  `/usage-report file` read no frontmatter
- Test that the skill body holds no `$<digit>` token
- Make the stub's list_issues declare the real server's `fields` and
  seed the person's report issues unlabeled

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mmaclay
mmaclay marked this pull request as ready for review November 16, 2026 23:00
@mmaclay
mmaclay merged commit d169e01 into main Nov 16, 2026
1 check passed
@mmaclay
mmaclay deleted the feat/usage-report branch November 16, 2026 23:00
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.

1 participant