Repository navigation
feat(usage): add usage-report, an opt-in plugin usage report - #137
Merged
Merged
Conversation
- 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
…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>
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.
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,mktempandTMPDIR): 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, theworkflow'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-reportcounts plugin use since the person's last report. It shows themtheir 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-reportissue here bydefault, or to a file with
filefor anyone who wants to send it privately.What a report holds:
declined;
/usage-report collect, for the maintainer, reads the report issues, adds file reports withtheir 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 theROADMAP. 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:
Anything else is written
other. A redaction list fails open when it misses something; anallowlist 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
~/.claudeby design, plugindata 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
sincedate. Temporary files go in a
mktemp -ddirectory 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
collectmatch theusage-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,$1and so onin a skill body with the skill's arguments; inline,
/usage-report fileturned the program's$0intofileand 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.pyreads the standard only when it redacts, so importing it readsnone.
skill-feedback's output is unchanged; its tests pass with no assertion changed.lasp-dev-sandbox(sbx-claude,run.py,rule_cases.py), soa report skips them.
.sbx-envasCLAUDE_ENV_FILE, and its settings template allowsEdit(//tmp/usage-report-sbx-*/**). Both are sandbox-only.scripts/coupling.jsongains an upper-caseLASPpattern. The report reads it to write aheader naming a project as
other, andcheck_staticnow fails a bareLASPin the genericfiles. No file matches today.
Limits
skill says so before asking;
fileis the private route. Revisit the default with the flip.have no scenario. No real report issue has been filed yet; the canary will be the first.
that, the window opens 30 days back and the summary says why.
reports until they age out of the window.
Testing
bash tests/checks.sh --allbefore review.tests/test_usage_report.pyandtests/test_usage_merge.pyguard the vocabulary and the merge refusals; each refusal test waschecked to fail with its check removed.
🤖 Generated with Claude Code. AI assistance level: 5/5 (not read by a person).