Context
AI agents (Copilot, Claude Code, Codex) consume this toolkit's output as input tokens: they run perf-check ... --insights / --json and then read the result to propose fixes. --json emits the near-raw PageSpeed Insights payload, so each agent turn pays tens of thousands of input tokens before reasoning about a single opportunity.
This issue tracks reducing that footprint without losing the signal an agent needs. Full write-up: docs/token-efficiency-analysis.md (companion analysis doc).
Key framing (from a review of the caveman tool's honest numbers): the lever here is the input an agent reads, not shortening replies. Output-style compression gives no benefit on Copilot's per-message billing, so it is out of scope. We optimize the data we emit.
Proposed work (prioritized)
P1 — Token-lean agent output mode (--llm / --compact)
Emit only decision-relevant data in a compact, stable shape:
- Scores: performance only unless others requested.
- Core Web Vitals as
{ metric, ms, rating } (numeric + Good/NI/Poor); no display strings or histograms.
- Top N opportunities (default 3-5) as
{ title, savingsMs, wastedBytes, attribution }, sorted by impact; drop long descriptions and audit boilerplate.
- LCP breakdown: TTFB, load delay, load time, render delay + LCP element selector.
- Third-party: total blocking ms + top offenders only.
- Omit passing audits and null metrics.
Prefer compact JSON (deterministic to parse) with an optional minimal-Markdown variant. Keys short but real words (no invented abbreviations such as cfg/impl, which the tokenizer splits the same as the full word for zero saving).
Why P1: cuts agent input by roughly an order of magnitude vs raw --json, and benefits every agent including Copilot (smaller context = better answer).
P2 — Tokenizer hygiene in embedded prompts/skills
Sweep the .md assets shipped by perf-prompts: replace Unicode arrow glyphs with words (to/then/becomes), expand invented abbreviations, drop filler/hedging while preserving code/paths/commands verbatim. Add a short "LLM-facing writing" note to the contributor docs to prevent regressions. Low effort, permanent, cross-agent.
P3 — Align --insights with the lean contract
Fold --insights into the --llm contract (or add an --llm flavor) so the "for AI agents" framing maps to a token-economical shape rather than terminal formatting.
P4 — Document per-mode token cost
Add a README table with approximate token counts of --json vs --insights vs --actionable vs --llm for a representative URL, so users pick the right mode deliberately.
Acceptance criteria
Non-goals
- No caveman-style "terse persona" output.
- No conflating output savings with input savings.
- No micro-optimizing for Copilot per-message billing.
- Never drop a field an agent needs to propose a correct fix; when in doubt, keep it and measure.
Context
AI agents (Copilot, Claude Code, Codex) consume this toolkit's output as input tokens: they run
perf-check ... --insights/--jsonand then read the result to propose fixes.--jsonemits the near-raw PageSpeed Insights payload, so each agent turn pays tens of thousands of input tokens before reasoning about a single opportunity.This issue tracks reducing that footprint without losing the signal an agent needs. Full write-up:
docs/token-efficiency-analysis.md(companion analysis doc).Key framing (from a review of the caveman tool's honest numbers): the lever here is the input an agent reads, not shortening replies. Output-style compression gives no benefit on Copilot's per-message billing, so it is out of scope. We optimize the data we emit.
Proposed work (prioritized)
P1 — Token-lean agent output mode (
--llm/--compact)Emit only decision-relevant data in a compact, stable shape:
{ metric, ms, rating }(numeric + Good/NI/Poor); no display strings or histograms.{ title, savingsMs, wastedBytes, attribution }, sorted by impact; drop long descriptions and audit boilerplate.Prefer compact JSON (deterministic to parse) with an optional minimal-Markdown variant. Keys short but real words (no invented abbreviations such as
cfg/impl, which the tokenizer splits the same as the full word for zero saving).Why P1: cuts agent input by roughly an order of magnitude vs raw
--json, and benefits every agent including Copilot (smaller context = better answer).P2 — Tokenizer hygiene in embedded prompts/skills
Sweep the
.mdassets shipped byperf-prompts: replace Unicode arrow glyphs with words (to/then/becomes), expand invented abbreviations, drop filler/hedging while preserving code/paths/commands verbatim. Add a short "LLM-facing writing" note to the contributor docs to prevent regressions. Low effort, permanent, cross-agent.P3 — Align
--insightswith the lean contractFold
--insightsinto the--llmcontract (or add an--llmflavor) so the "for AI agents" framing maps to a token-economical shape rather than terminal formatting.P4 — Document per-mode token cost
Add a README table with approximate token counts of
--jsonvs--insightsvs--actionablevs--llmfor a representative URL, so users pick the right mode deliberately.Acceptance criteria
--llm(or--compact) mode implemented forperf-check, covered by tests.--llmvs--jsonon a representative URL, documented (tokenizer such astiktoken/gpt-tokenizer).Non-goals