From 9c038fd22b0bf370c6202df068696af8b3beabb5 Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 13 Nov 2026 10:13:04 +0100 Subject: [PATCH] chore(hooks): retire the design-toolchain reminder hook 59 fires, 0 Reads of web-building.md (2026-10-31); the path rule and the CLAUDE.global.md pointer carry design routing. Hook, its test and its UserPromptSubmit entry removed; doctrine-citers T7c becomes T8i on a synthetic one-line fixture (quoted label kept whole). --- hooks/design-toolchain-reminder.sh | 82 --------------------- lib/tests/design-toolchain-reminder.test.sh | 58 --------------- lib/tests/doctrine-citers.test.sh | 10 +-- rules/web-building.md | 2 +- settings.json | 6 -- 5 files changed, 6 insertions(+), 152 deletions(-) delete mode 100755 hooks/design-toolchain-reminder.sh delete mode 100644 lib/tests/design-toolchain-reminder.test.sh diff --git a/hooks/design-toolchain-reminder.sh b/hooks/design-toolchain-reminder.sh deleted file mode 100755 index 165b822..0000000 --- a/hooks/design-toolchain-reminder.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env bash -# design-toolchain-reminder.sh -# -# UserPromptSubmit hook. When the prompt carries a UI/design signal, point the -# model at the design toolchain section (tiered by scope). Since BDR-125 -# phase 1 it lives in rules/web-building.md § "Design work — full toolchain", -# not in CLAUDE.global.md: it loads by itself on a UI file Read, and a -# chat-only design request needs this pointer. A UserPromptSubmit hook's -# stdout is appended to the model's context. -# -# This is a soft nudge: the tiered rule itself says trivial work uses NO -# toolchain, so a false positive (e.g. "API design") costs only a reminder the -# model can disregard. Always exits 0 so it never blocks prompt submission. -# -# Every fire appends one line (time, matched token, prompt excerpt) to -# ~/.claude/logs/design-toolchain-fires.log — a counter so the next "is it -# over-firing?" decision is measured, not anecdotal. - -set -euo pipefail - -input="$(cat)" - -# Extract the user's prompt from the hook JSON; fall back to the raw stdin if -# python or the expected field is unavailable. -prompt="$(printf '%s' "$input" \ - | python3 -c 'import sys, json; print(json.load(sys.stdin).get("prompt", ""))' \ - 2>/dev/null || true)" -[ -z "$prompt" ] && prompt="$input" - -# Harness-generated turns (task notifications, sub-agent hand-backs: 857 of -# 2,779 logged fires on 2026-10-28) are not user requests — never fire on -# them (the Design work trigger = a design/UI *request*). -case "$prompt" in - ''*|' \bdashboard\b -# so a filename like ecc_dashboard.py no longer matches while "admin dashboard" -# still does. animation kept (rarely non-UI). -# Tightened 2026-07-30 (3rd pass): dropped \bux\b — bare "ux" matched inside -# French prose ("changement ux vu…"; 2 logged FPs, both FR). \bui\b KEPT -# (zero logged FP, one logged true positive). NB: the log records only the -# FIRST match per fire (head -1), so per-token FP rates aren't derivable. -pattern='redesign|refonte|refont|ui/ux|ux/ui|\bui\b|ui kit|design system' -pattern+='|design-system|front-?end design|\bnavbar\b|\bsidebar\b|\bmodal\b' -pattern+='|\bbouton\b|\bbutton\b|formulaire|\bhero\b|\bheader\b|\bfooter\b' -pattern+='|dropdown|tooltip|\bbadge\b|\bchart\b|graphique|accordion|carousel' -pattern+='|\bslider\b|landing|\bdashboard\b|homepage|home page|\baccueil\b' -pattern+='|\bécran\b|\becran\b|portfolio|maquette|mockup|wireframe|prototype' -pattern+='|\bjoli\b|\bjolie\b|\bbeau\b|\bbelle\b|esth[eé]tique|aesthetic' -pattern+='|\bvisuel\b|\bvisual\b|embellir|fignol|peaufin|polish|styliser' -pattern+='|styling|stylesheet|\bskin\b|charte graphique|\bbrand\b|branding' -pattern+='|\blogo\b|favicon|ic[oô]ne|\bicon\b|\bcss\b|tailwind|shadcn|couleur' -pattern+='|gradient|d[eé]grad[eé]|\bombre\b|spacing|espacement|\bmarge\b' -pattern+='|\bpadding\b|\bmargin\b|\bradius\b|arrondi|\bhover\b|dark mode' -pattern+='|light mode|typograph|\bfont\b|\bfonts\b|font pairing|\bpolice\b' -pattern+='|animation|\bmotion\b|micro-interaction|keyframe|glassmorph|neumorph' -pattern+='|claymorph|skeuomorph|brutalis|bento|minimalis|responsive|figma' - -if printf '%s' "$lc" | grep -Eq "$pattern"; then - # Counter: log the fire (time, matched token, excerpt) — best-effort, never blocks. - logf="${HOME}/.claude/logs/design-toolchain-fires.log" - mkdir -p "$(dirname "$logf")" 2>/dev/null || true - printf '%s\t%s\t%s\n' "$(date -Iseconds)" \ - "$(printf '%s' "$lc" | grep -oiE "$pattern" | head -1 || true)" \ - "$(printf '%s' "$prompt" | tr '\n\t' ' ' | cut -c1-100)" >> "$logf" 2>/dev/null || true - cat <<'EOF' -Design work detected → Read ~/.claude/rules/web-building.md § "Design work — full toolchain" first. Trivial (≤2 files, cosmetic) → /hotfix. -EOF -fi - -exit 0 diff --git a/lib/tests/design-toolchain-reminder.test.sh b/lib/tests/design-toolchain-reminder.test.sh deleted file mode 100644 index 69df979..0000000 --- a/lib/tests/design-toolchain-reminder.test.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash -# lib/tests/design-toolchain-reminder.test.sh -set -u -H="$(cd "$(dirname "$0")/../.." && pwd)/hooks/design-toolchain-reminder.sh" -# Every hook call runs under a throwaway HOME (the fire log is -# $HOME/.claude/logs/design-toolchain-fires.log): the suite never writes the -# real one (1,770 of 2,779 logged fires were this suite's prompts, 2026-10-28). -T="$(mktemp -d)"; trap 'rm -rf "$T"' EXIT -export HOME="$T" -LINE='Design work detected → Read ~/.claude/rules/web-building.md § "Design work — full toolchain" first. Trivial (≤2 files, cosmetic) → /hotfix.' -pass=0; fail=0 -check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1)); - printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; } -# fire() -> "fire" if the hook emits the reminder, else "quiet". -fire() { if printf '{"prompt":"%s"}' "$1" | bash "$H" | grep -q 'full toolchain'; then - echo fire; else echo quiet; fi; } - -# --- Dropped/neutralized tokens must be QUIET (non-UI senses) --- -check D1-design "$(fire 'a design decision for the API')" quiet -check D2-component "$(fire 'this system component')" quiet -check D3-composant "$(fire 'le composant backend')" quiet -check D4-theme "$(fire 'the theme of the audit')" quiet -check D5-transition "$(fire 'state transition to develop')" quiet -check D6-frontend "$(fire 'frontend architecture')" quiet -check D7-palette "$(fire 'a palette of options')" quiet -check D8-dash-file "$(fire 'ecc_dashboard.py')" quiet - -# --- Harness-generated inputs must be QUIET even with UI tokens --- -check D9-tasknotif "$(fire ' x add css header fonts')" quiet -check D10-notif-file "$(fire ' design-motion-principles keyframe done')" quiet -check D11-bare-ux "$(fire 'changement ux vu de tes trouvailles')" quiet -check D12-agent-msg "$(fire ' [Subagent hand-back] add css header fonts')" quiet - -# --- Real UI signals must still FIRE --- -check F1-button "$(fire 'add a button')" fire -check F2-navbar "$(fire 'the navbar layout')" fire -check F3-landing "$(fire 'build a landing page')" fire -check F4-glass "$(fire 'a glassmorphism card')" fire -check F5-redesign "$(fire 'redesign the app')" fire -check F6-frontdesign "$(fire 'frontend design work')" fire -check F7-admin-dash "$(fire 'admin dashboard screen')" fire -check F8-animation "$(fire 'add an animation')" fire -check F9-designsys "$(fire 'our design system')" fire -check F10-bare-ui "$(fire 'revois l'\''ui du panneau admin')" fire -check F11-pasted "$(fire ' add a button')" fire - -# --- The one-liner is a contract (LRN-104): exact text --- -check O1-exact-line "$(printf '{"prompt":"add a button"}' | bash "$H")" "$LINE" -# the fires above landed in the throwaway HOME, positively (not a global count) -check G1-fires-in-temp-home "$([ -s "$T/.claude/logs/design-toolchain-fires.log" ] && echo yes)" yes - -# --- Fire is logged (time + token + excerpt) --- -tmp="$(mktemp -d)" -printf '{"prompt":"a glassmorphism card"}' | HOME="$tmp" bash "$H" >/dev/null 2>&1 -check L1-logged "$(grep -c 'glassmorph' "$tmp/.claude/logs/design-toolchain-fires.log" 2>/dev/null)" 1 -rm -rf "$tmp" - -printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ] diff --git a/lib/tests/doctrine-citers.test.sh b/lib/tests/doctrine-citers.test.sh index 688d763..d8546e7 100644 --- a/lib/tests/doctrine-citers.test.sh +++ b/lib/tests/doctrine-citers.test.sh @@ -140,8 +140,8 @@ check T5d-quoted-label-whole "$(printf '%s\n' "$out" | grep -c 'full kit')" 1 check T5b-missing-file-named "$(printf '%s\n' "$out" | grep -c 'rules/none.md')" 1 check T5c-prefix-not-a-heading "$(printf '%s\n' "$out" | grep -c '"Version"')" 1 -# T8a-T8h: blind spots of the file-citation census (nested dirs, project -# rules, home prefixes, left boundary, templates) +# T8a-T8i: blind spots of the file-citation census (nested dirs, project +# rules, home prefixes, left boundary, templates, quoted label kept whole) mkdir -p "$FIX/lib/sub" "$FIX/.claude/rules" "$FIX/templates/project-rules" printf '## Alpha\n' > "$FIX/lib/sub/x.md" printf 'nested: lib/sub/x.md § Alpha\n' > "$FIX/n1.md" @@ -184,6 +184,9 @@ printf 'tpl: templates/project-rules/t.md § Zeta.\n' > "$FIX/t2.md" citers_check_files "$FIX" "$FIX/t1.md" >/dev/null; rc1=$? citers_check_files "$FIX" "$FIX/t2.md" >/dev/null check T8h-template-rules-path "$rc1|$?" "0|1" +# the retired design hook's pointer shape: ~ prefix + quoted label +printf '%s\n' ' ~/.claude/rules/web-building.md § "Design work — full toolchain"' > "$FIX/pointer.sh" +check T8i-tilde-quoted-label-whole "$(_citers_extract_files "$FIX/pointer.sh" | cut -d: -f3-)" 'rules/web-building.md:Design work — full toolchain' # ── real census: the repo's own citers against CLAUDE.global.md ────────────── # (`impeccabl[e]` is a glob: the pack census must not read it as a citer.) @@ -222,9 +225,6 @@ sed 's/^## Versioning$/## Version policy/' "$ROOT/rules/rest-api.md" > "$FIX/cop (cd "$ROOT" && citers_check_files "$FIX/copy" lib/architecture-defaults.md \ lib/project-archetypes/rest-api-node.md) >/dev/null check T7b-real-rename-bites "$?" 2 -# the hook's pointer is checked whole, not as its "Design work" prefix -check T7c-hook-label-whole "$(cd "$ROOT" && _citers_extract_files hooks/design-toolchain-reminder.sh \ - | grep -c ':rules/web-building.md:Design work — full toolchain$')" 2 echo "PASS=$pass FAIL=$fail" [ "$fail" -eq 0 ] diff --git a/rules/web-building.md b/rules/web-building.md index cab3783..bf9dd6a 100644 --- a/rules/web-building.md +++ b/rules/web-building.md @@ -47,7 +47,7 @@ with /seo, /harden, /web-validate. ## Design work — full toolchain (tiered by scope) Trigger = UI work: editing a component/style file (.tsx/.vue/.svelte/.css…) or a design/UI request, not the word "design" alone. Single source for -design routing; the design-toolchain hook reinforces it. +design routing. - Trivial (≤2 files, one cosmetic value) → /hotfix, no toolchain. - Build UI (component, page, redesign) → impeccable (build path: init, shape, new-work, craft floor, fresh finish reviewer) + ui-ux-pro-max + diff --git a/settings.json b/settings.json index 77fda30..365b2b0 100644 --- a/settings.json +++ b/settings.json @@ -511,12 +511,6 @@ "UserPromptSubmit": [ { "hooks": [ - { - "type": "command", - "command": "bash ~/.claude/hooks/design-toolchain-reminder.sh", - "timeout": 5, - "statusMessage": "Checking design signals..." - }, { "type": "command", "command": "bash ~/.claude/hooks/ctx7-reminder.sh",