diff --git a/lib/tests/effort-routing.test.sh b/lib/tests/effort-routing.test.sh index c2370ea..7408801 100755 --- a/lib/tests/effort-routing.test.sh +++ b/lib/tests/effort-routing.test.sh @@ -138,7 +138,7 @@ while read -r _ p tier effort; do done < <(echo "$RD" | grep '^phases ') # ── (b) tracked skills: row exists, frontmatter effort equals the row ──── -NO_ROW_SKILLS=" find-docs graphify impeccable model-router " +NO_ROW_SKILLS=" find-docs graphify impeccable model-router modern-web-guidance " check_skill() { local f="$1" name phase name="$(basename "$(dirname "$f")")" diff --git a/lib/tests/mwg-skill.test.sh b/lib/tests/mwg-skill.test.sh new file mode 100755 index 0000000..7fbc889 --- /dev/null +++ b/lib/tests/mwg-skill.test.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# lib/tests/mwg-skill.test.sh — skills/modern-web-guidance: Read is the +# only pre-approved tool, no effort pin and no routing.json row (a row +# reroutes the main loop on load), no npx or network command in a fenced +# block, the relative link into skills-external/mwg, the disclosure +# format, a description within the listing budget. +set -u +ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +S="$ROOT/skills/modern-web-guidance" +pass=0; fail=0 +check() { if [ "$2" = 1 ]; then pass=$((pass+1)); echo "PASS $1"; else fail=$((fail+1)); echo "FAIL $1"; fi; } +fm() { awk '/^---$/{n++; next} n==1' "$S/SKILL.md"; } +check exists "$([ -f "$S/SKILL.md" ] && echo 1)" +check tools "$(fm | grep -qx 'allowed-tools: Read' && echo 1)" +check no-effort "$(fm | grep -q '^effort:' || echo 1)" +desc_len="$(fm | awk '/^description:/{f=1; next} /^[a-z-]+:/{f=0} f' | tr -s ' \n' ' ' | wc -c)" +check desc-budget "$([ "$desc_len" -gt 100 ] && [ "$desc_len" -le 400 ] && echo 1)" +fenced="$(awk '/^```/{f=!f; next} f' "$S/SKILL.md" | grep -c 'npx\|pnpx\|curl\|wget')" +check no-fenced-network "$([ "$fenced" -eq 0 ] && echo 1)" +check never-run "$(grep -q 'Never run npx' "$S/SKILL.md" && echo 1)" +check read-index "$(grep -q 'Read `mwg/INDEX.md` whole' "$S/SKILL.md" && echo 1)" +check search-root "$(grep -q '~/.claude/skills/modern-web-guidance/mwg/guides/' "$S/SKILL.md" && echo 1)" +check disclosure "$(grep -q '`Modern Web Guidance: , `' "$S/SKILL.md" && echo 1)" +check link-mwg "$([ -L "$S/mwg" ] && [ "$(readlink "$S/mwg")" = ../../skills-external/mwg ] && echo 1)" +check tracked-link "$([ "$(cd "$ROOT" && git ls-files skills/modern-web-guidance/mwg | wc -l)" -eq 1 ] && echo 1)" +check no-routing-row "$(grep -q '"modern-web-guidance"\|"chrome-extensions"' "$ROOT/mods/model-router/routing.json" || echo 1)" +check prompts "$(python3 -c "import json,sys;d=json.load(open(sys.argv[1]));sys.exit(0 if len(d)>=3 else 1)" "$S/test-prompts.json" && echo 1)" +echo "mwg-skill: $pass pass, $fail fail" +[ "$fail" -eq 0 ] diff --git a/skills/modern-web-guidance/SKILL.md b/skills/modern-web-guidance/SKILL.md new file mode 100644 index 0000000..7a964e4 --- /dev/null +++ b/skills/modern-web-guidance/SKILL.md @@ -0,0 +1,51 @@ +--- +name: modern-web-guidance +description: >- + Current web-platform practice from Google's Modern Web Guidance, read + from a pinned local copy. Use FIRST, before writing or changing + front-end code: HTML, CSS, client-side JS, UI components, forms, + dialogs, layout, motion, Core Web Vitals, images, accessibility. Not + for backend, infra, build tooling or tests. +allowed-tools: Read +--- + +# Modern Web Guidance (local, pinned) + +This folder is `~/.claude/skills/modern-web-guidance/`. Its `mwg/` holds +`INDEX.md`, one line per guide (`- | | `), and the +guides at `mwg/guides//.md`. They are a copy of +GoogleChrome/modern-web-guidance pinned in `plugins.lock.json`; +`mwg/NOTICE.md` names the commit and the licenses. Read is the only tool +needed, nothing here touches the network. + +## Steps + +1. Pick: Read `mwg/INDEX.md` whole (about 210 lines) and choose the + guides whose summary matches a platform feature or UI pattern the + task uses (a modal is `dialog`, an accordion animates to intrinsic + sizes, a slow first paint is LCP). No summary fits a feature: search + `~/.claude/skills/modern-web-guidance/mwg/guides/` once with the + text-search tool at hand, else go on without a guide. +2. Read each chosen guide. Read a discipline guide (the one whose id + equals its category: `html`, `css`, `js`, `forms`, `accessibility`, + `performance`, `security`, `privacy`) only when building a new + component or page, or when no specific guide matched; they are long. +3. Cross-references: a guide line `npx -y modern-web-guidance@latest + retrieve ""` names another guide. Find `` in `mwg/INDEX.md` + for its category and Read `mwg/guides//.md`. + Never run npx, the guidance CLI or any network command for this skill. +4. Apply: follow the guide, its fallbacks and its Baseline notes, without + adding features the task did not ask for. Where a guide and a rule of + `rules/web-building.md` disagree on how to use the platform, the guide + wins. An executor whose closed plan contradicts a guide reports it as + an open choice, never overrides the plan silently. +5. Disclose: the answer that delivers the front-end change (a sub-agent: + its report) ends with one line, `Modern Web Guidance: , `. + Guides checked and none applied: `Modern Web Guidance: checked , + none applied`. No quotes. + +## Missing copy + +`mwg/INDEX.md` unreadable (the link dangles on a machine that never ran +the install): say once "Modern Web Guidance not installed, run +`make update`" and continue without it. diff --git a/skills/modern-web-guidance/mwg b/skills/modern-web-guidance/mwg new file mode 120000 index 0000000..55f24f6 --- /dev/null +++ b/skills/modern-web-guidance/mwg @@ -0,0 +1 @@ +../../skills-external/mwg \ No newline at end of file diff --git a/skills/modern-web-guidance/test-prompts.json b/skills/modern-web-guidance/test-prompts.json new file mode 100644 index 0000000..8205d72 --- /dev/null +++ b/skills/modern-web-guidance/test-prompts.json @@ -0,0 +1,6 @@ +[ + {"id": 1, "prompt": "Add a confirmation modal before deleting an item", "expected": "Read mwg/INDEX.md, pick dialog, Read the dialog guide, build on per the guide, end with `Modern Web Guidance: `"}, + {"id": 2, "prompt": "Make this accordion open smoothly", "expected": "Pick animate-to-intrinsic-sizes from its summary, Read it, apply its technique and fallback, disclosure line"}, + {"id": 3, "prompt": "Améliore le LCP de la page d'accueil", "expected": "FR trigger: pick the LCP guides, Read them, apply fetchpriority/image guidance, disclosure line"}, + {"id": 4, "prompt": "Write a SQL migration for the orders table", "expected": "Does not trigger: backend task"} +]