Repository navigation
Description
Problem
measure.mjs snapshot cannot measure anything on Claude Code 2.1.289 when the Agent SDK is not
installed. The SDK rung is skipped (not resolvable), and the cli-parse fallback throws because the
2.1.289 headless /context category table has a System tools (deferred) row but no System tools
row. The degradation ladder then exits 3 with measurement-unavailable, so the audit reports no
number at all, not even the categories it did parse.
On current main:
plugins/context-budget/skills/audit/scripts/measure.mjs:304-306refuses any table without a
System toolskey:throw new ParseError('category table parsed but carries no "System tools" row ...').measure.mjs:571-579(takeSnapshot) turns that ParseError intodegrade('measurement-unavailable', ...),
which exits 3 (measure.mjs:110-113).measure.mjs:413-418already documents the intended policy for a missing bucket: the SDK rung
zero-fills an omittedSystem toolsbucket because its vocabulary is known, while "cli-parse
absence stays genuinely ambiguous (format drift vs emptied bucket) and is deliberately not
zero-filled". The parser does not follow through on that: instead of recording the bucket as
unmeasured, it rejects the whole table.- Test coverage: the parser fixture
skills/audit/scripts/fixtures/context-sample.mdcarries both
system-tool rows, and the refusal test atskills/audit/scripts/measure.test.sh:153-157uses a
table with neither row. No test covers the 2.1.289 shape (deferred row present, prefix row absent).
A secondary documentation gotcha: from Git Bash, a hand-run claude -p "/context" is rewritten by
MSYS path conversion (the leading / of /context becomes a Git install path), and the session
answers in prose instead of printing the table. measure.mjs itself is not affected, because node's
spawnSync calls the binary directly without MSYS argument conversion (measure.mjs:198-201,
measure.mjs:478-480). The remediation strings at measure.mjs:567 and measure.mjs:577-578 tell the
operator to "verify claude -p "/context" prints the category table", which fails from Git Bash
unless the command is prefixed with MSYS_NO_PATHCONV=1.
Evidence
Labels follow the parent: E1 measured and attributed, E2 aggregate measured with cause inferred, E3
structural inference from code or docs, E4 suspicion.
- E1 (reported by the audit): on Claude Code 2.1.289, model claude-opus-5-5 (1M window), headless
claude -p "/context"from a directory with no project CLAUDE.md printed a category table with
System tools (deferred)at 14k and noSystem toolsrow.measure.mjs snapshotexited 3: SDK not
resolvable in the plugin datasdkdirectory, and cli-parse refused the table for the missing row.
The raw/contextcapture was not retained, so the exact 2.1.289 table is not available to this
issue; the implementer must capture one. - E1 (reported): from Git Bash without
MSYS_NO_PATHCONV=1,claude -p "/context"answered in prose
instead of the table. - E3 (verified this pass, code read at origin/main 5779559): the throw at
measure.mjs:304-306, the
exit-3 path atmeasure.mjs:571-579, the deliberate no-zero-fill policy comment at
measure.mjs:413-418, and the fixture and test shapes above. - E3 (verified this pass, docs): the
/contextrow on https://code.claude.com/docs/en/commands.md
says "Visualize current context usage as a colored grid ... Passallto expand it" and, unlike
sibling rows such as/config,/mcpand/model, does not say it is available in non-interactive
mode (-p). Headless/contextremains undocumented, asreference/engine.mdrow 2 already states.
Whether the prefixSystem toolsrow is now omitted because every built-in tool is deferred in
headless sessions, or because the format changed, is not documented: unverified (E4). - Not a defect: the missing SDK. Installing it under
${CLAUDE_PLUGIN_DATA}/sdkis the documented
operator step (skills/audit/SKILL.md:147-153,skills/setup/SKILL.md:104-110).
Proposed approach
Make the parser accept a table that carries at least one of the two system-tool buckets, and record
the absent one as unmeasured rather than refusing the whole measurement.
- In
parseContextMarkdown(measure.mjs), replace the hardSystem toolsrequirement with: throw
only when NEITHERSystem toolsnorSystem tools (deferred)is present (that still signals real
format drift, and keeps the existing test atmeasure.test.sh:153-157valid). When exactly one is
present, leave the other key absent (do not zero-fill, per the existing policy at
measure.mjs:413-418) and push a caveat naming the missing bucket and the binary version, for
examplecli-parse: "System tools" row absent at <version>; recorded as unmeasured, not zero. - Confirm the downstream paths treat the absent key as unmeasured:
compare,bucketAdditivity
(measure.mjs:715-760, which already skips a bucket absent from both runs and emits null with a
reason when absent from one), and the comparability gate that keys onSystem tools
(measure.mjs:604-620). Absent on both sides must yield no verdict row; absent on one side must
yield null with a reason, never 0. - Add a fixture shaped like the 2.1.289 output (a category table without the
System toolsrow) and
cases inmeasure.test.shfor: deferred-only table parses with a caveat; prefix-only table parses. - Documentation: in
reference/engine.md(cli-parse row) and the remediation strings at
measure.mjs:567andmeasure.mjs:577-578, say that from Git Bash the hand check must be run as
MSYS_NO_PATHCONV=1 claude -p "/context". Record the 2.1.289 observation (no prefix row in
headless) with a recheck trigger, per the repo's upstream-drift stamp convention.
Alternatives considered:
- Zero-fill the missing
System toolsbucket as the SDK rung does. Rejected: the engine's own policy
says cli-parse absence is ambiguous, and a fabricated zero would feed a wrong number into deny
differencing, which the plugin's contract forbids ("never a wrong number"). - Leave the parser strict and only improve the error. Rejected: it keeps the whole fallback rung dead
on current Claude Code for every user without the SDK.
Acceptance criteria
-
measure.mjs parse-contexton a fixture withSystem tools (deferred)and noSystem tools
row exits 0, reports every parsed category, omitsSystem tools(no zero), and carries a caveat
naming the missing row. - A table with neither system-tool row still exits 3 with a
context-budget.error/1record (the
existing test atmeasure.test.sh:153-157still passes). -
comparebetween two deferred-only snapshots yields noSystem toolsverdict row; between a
deferred-only and a full snapshot it yields null with a reason, never 0. -
measure.test.shcovers the cases above and passes. - The engine reference and both remediation strings name the
MSYS_NO_PATHCONV=1prefix for Git
Bash, and contain no claim that/contextis documented for-p. - A live
measure.mjs snapshotwithout the SDK on Claude Code 2.1.289 or later returns a
cli-parsesnapshot instead of exit 3 (operator-run check; record the binary version).
Constraints and gotchas
- Headless
/contextis undocumented for-p; the format can change again. Keep the "refuse when no
system-tool bucket at all" guard so real drift still fails loudly. - Running
claude -p "/context"fires every SessionStart hook on the machine and writes a transcript;
tests must use the hermetic fake binary and fixtures the suite already uses, not the real CLI. - Bump
plugins/context-budget/.claude-plugin/plugin.json(currently 0.9.5) and add a
plugins/context-budget/CHANGELOG.mdentry, per the repo's shared version bump and CHANGELOG rule. - Related: context-budget: two open measurements — interactive-session deferral eligibility; deferred-tool count_tokens billing #2954 (open measurements on interactive-session deferral eligibility), fix(context-budget): additivity verifier coerces null bucket delta to 0 — publishes combinedSaved:0 as comparable when the combined deny empties the System tools buckets #3197 and fix(context-budget): never coerce a vanished bucket's null delta to zero in attribution (0.6.6) #3236
(earlier null-versus-zero bucket fixes whose semantics this must preserve), feat(context-budget): add a measure-only audit mode for consumer skills #6093 (measure-only
audit mode, separate work).
Context
Part of the 2026-10-04 performance audit, parent #6244.
Source: local handoff item 20261004-152632-claude-perf-audit-tooling-bugs.md, bug 1 of 6 (retired
into this issue). Found by the 2026-10-04 Windows performance audit (parent #6244). Sibling issues
from the same item: #6261 (skill-quality listing
budget) and #6262 (audit-skill-visibility estimator).
Activity
github-actions commentedon Oct 4, 2026
Thanks for the detailed report. As I understand it: on Claude Code 2.1.289, headless
/contextnow emits aSystem tools (deferred)row instead ofSystem tools, andmeasure.mjs's cli-parse fallback treats that missing row as a hard error, sosnapshotexits 3 with no measurement at all when the Agent SDK isn't installed. You've proposed accepting a table with either system-tool row, recording the absent one as unmeasured (not zero-filled), plus a fixture/test for the 2.1.289 shape and anMSYS_NO_PATHCONV=1note for the Git Bash remediation strings.This is well-specified with exact line references, acceptance criteria, and considered alternatives, so nothing looks missing for someone to pick it up. One gap you already flagged yourselves: the raw 2.1.289
/contextcapture wasn't retained, so whoever implements this will need to capture a fresh one for the fixture.I didn't find any duplicate open issues; #3197, #3236, #6093, and #6244 are correctly cited as related rather than overlapping.
Automated triage. A maintainer reviews it.