perf: reduce context duplication in WebPerf skills (-16.6% lines)#67
Merged
perf: reduce context duplication in WebPerf skills (-16.6% lines)#67
Conversation
Bugs fixed: - LCP-Video-Candidate: apply activationStart correction in both non-video and video return paths (bfcache navigations were returning wrong values) - LCP + LCP-Trail: use getComputedStyle for background-image detection instead of el.style, which only reads inline styles - CLS: add message and getDataFn to synchronous return so agents know they can call getCLS() after interactions for an updated value - INP: remove misleading rating: "good" from getINP() error case when no interactions recorded; add getDataFn: "getINP" so agents can retry Inconsistencies resolved: - LCP-Sub-Parts: align internal SUB_PARTS keys with schema output keys (loadDelay → resourceLoadDelay, loadTime → resourceLoadTime, etc.) - LCP-Sub-Parts + LCP-Trail: preserve hostname in URL for cross-origin resources (cdn.example.com/…/hero.jpg instead of just hero.jpg) - LCP-Image-Entropy: add LCP element highlighting, consistent with all other LCP scripts SKILL.md / schema improvements: - WORKFLOWS: add Error Recovery section to decision tree - WORKFLOWS: mark cross-skill scripts not yet available as (pending) - WORKFLOWS: clarify cross-skill triggers require reporting to parent agent (context: fork — subagent cannot invoke other skills directly) - WORKFLOWS: document getINPDetails() usage in INP debugging workflow - SCHEMA: update CLS schema to include message and getDataFn fields - SCHEMA: document getINPDetails() return shape and when to use it
Remove redundant sections from WORKFLOWS.md sources and the skill generator that duplicated information already present in Decision Trees. Changes in generate-skills.js: - Remove inline `references/snippets.md` pointer after script list (already listed in ## References section) - Remove duplicate execution footer (already in intro paragraph) - Merge "Skills by Category" and "Quick Reference" tables in meta-skill into a single "Quick Reference" table (Skill | Snippets | Trigger phrases) Changes in WORKFLOWS.md sources: - Interaction: remove ### Cross-Skill Triggers (30 lines); preserve unique webperf-core-web-vitals:INP.js trigger inline in Decision Tree - Loading: remove ### Image Loading Audit (9 lines); image queries route through webperf-media which already cross-references these scripts - Media: remove ### Cross-Skill Triggers (38 lines) and ### Common Issues and Resolutions (38 lines); both were 1:1 summaries of the Decision Tree; unique trigger (images competing with critical resources) moved inline to After Image-Element-Audit.js node - Resources: remove ### Cross-Skill Triggers (29 lines), ### Real-World Scenarios (25 lines), and ### Testing Adaptive Loading (18 lines); unique triggers (TTFB-Sub-Parts, Service-Worker-Analysis for high RTT; LCP.js/INP.js for slow connections) moved inline to DT; reformat ### Adaptive Loading Implementation Guide from fenced javascript blocks to bullet lists (-8 lines) No actionable information lost: every removed item was already covered by an inline Decision Tree node or has been incorporated into one. SKILL.md line counts (before → after): webperf-core-web-vitals 238 → 235 (-1.3%) webperf-interaction 271 → 238 (-12.2%) webperf-loading 228 → 216 (-5.3%) webperf-media 292 → 217 (-25.7%) webperf-resources 288 → 198 (-31.3%) webperf (meta) 51 → 37 (-27.5%) total 1368 → 1141 (-16.6%, -227 lines)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Add buildReadableScript() to generate-skills.js, producing a
skills/{category}/scripts-readable/ directory alongside the existing
minified scripts/ output.
Readable scripts are intended for contribution to external repos (e.g.
chrome-devtools-mcp) where minified code is not appropriate. They differ
from the minified build in three ways:
- No header comment (file path / sha256 / GitHub URL)
- No console.* output code (removed via Terser drop_console)
- Readable formatting (beautify, 2-space indent, mangle disabled)
Terser options used: defaults:false to suppress all transforms except
drop_console + unused DCE + dead_code removal. Post-processing restores
number literals shortened by the output generator (1e4 → 10000, .1 → 0.1)
and removes void 0 placeholders left by drop_console.
Note: display-only infrastructure (RATING constants, logXxx helpers) that
served only console output remains as inert stubs after console removal.
The scripts are functionally correct — stubs execute but have no effect.
scripts-readable/ was generated inside skills/{category}/, causing it to
be included in the skills distribution package (npx install-from-release,
install-skills, install-global). These scripts are build artifacts for
external repo contribution, not part of the skill consumed by agents.
Move output to dist/{skill}/ at repo root. The dist/ directory is never
copied to .claude/skills/ nor included in the release zip.
Output structure:
skills/{skill}/scripts/ — minified, for Claude Code skill loading
dist/{skill}/ — readable, no headers/console, for external repos
copyRecursive was additive — subdirectories removed from skills/ (like scripts-readable/) were never deleted from .claude/skills/. Fix: remove each destination subdirectory before copying, keeping stale files out while preserving unmanaged files (e.g. evals/) at the top level.
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.
Summary
WebPerf skills contained redundant information — the same content appeared in multiple places within each
SKILL.md, consuming unnecessary context tokens without adding value. This PR removes those duplications while preserving all actionable information.Net result: 1,368 → 1,141 lines across all SKILL.md files (-227 lines, -16.6%), without losing any information that wasn't already covered by the Decision Tree.
What was duplicated and how it was fixed
generate-skills.js— structural fixes (affects all skills)references/snippets.mdpointer appeared twice per skill (inline after script list + in## References)mcp__chrome-devtools__evaluate_script) appeared in intro paragraph AND as a footer## Skills by Categoryand## Quick Reference## Quick Referencetable with columnsSkill | Snippets | Trigger phrasesWORKFLOWS.mdsources — per-categoryInteraction (
-33 linesin SKILL.md,-12.2%)### Cross-Skill Triggers— all triggers already present inline in the Decision Treewebperf-core-web-vitals:INP.jsmoved inline toAfter Interactions.jsDT nodeLoading (
-12 linesin SKILL.md,-5.3%)### Image Loading Audit— image queries route throughwebperf-media, which already cross-references these loading scripts in its own workflowsMedia (
-75 linesin SKILL.md,-25.7%)### Cross-Skill Triggers— every trigger mapped 1:1 to an existing DT node### Common Issues and Resolutions— each "issue" was a prose rewrite of a DT node (e.g. "LCP slow + image" =After Image-Element-Audit.js → LCP lacks fetchpriority)Find-render-blocking-resources.js+TTFB-Resources.js" moved inline toAfter Image-Element-Audit.jsResources (
-90 linesin SKILL.md,-31.3%)### Cross-Skill Triggers— duplicated DT nodes verbatim### Real-World Scenarios— four scenarios were narrative rewrites of DT nodes (e.g. "User on 3G" = theeffectiveType: "3g"node as a story)### Testing Adaptive Loading— described a manual Chrome DevTools workflow, not executable via MCP, referenced no skill scripts### Adaptive Loading Implementation Guidefrom fencedjavascriptblocks (containing plain text strategies, not executable code) to bullet lists — same content, ~8 fewer linesTTFB-Sub-Parts.js+Service-Worker-Analysis.jsadded toRTT > 300msDT node;LCP.js+INP.jsadded to2gand3gDT nodesImpact by skill
webperf-core-web-vitalswebperf-interactionwebperf-loadingwebperf-mediawebperf-resourceswebperf(meta)Design principle
The fix applies a single source of truth rule: the Decision Tree is the authoritative place for "what to do next" logic. Supporting sections (
Cross-Skill Triggers,Common Issues,Real-World Scenarios) that summarize or restate DT nodes are redundant by definition. Where those sections contained genuinely unique information not already in the DT, it was moved inline before removing the section.Test plan
node scripts/generate-skills.jsruns without errors.claude/skills/correctlyCross-Skill Triggers,Common Issues,Real-World Scenarios, orTesting Adaptive Loadingsections in generated SKILL.md filesreferences/snippets.mdpointer appears exactly once per skill (in## References)