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).
This commit is contained in:
1 parent
97780b5f46
commit
9c038fd22b
5 files changed
+6
-152
No files matched your search
@@ -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
|
|
||||||
'<task-notification>'*|'<agent-message'*) exit 0 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
lc="$(printf '%s' "$prompt" | tr '[:upper:]' '[:lower:]')"
|
|
||||||
|
|
||||||
# UI/design build and review signals (FR + EN). Word boundaries (\b) avoid
|
|
||||||
# substring false matches like perform/platform/information.
|
|
||||||
# Tightened 2026-07-02: dropped ultra-generic tokens (page, form, menu, card,
|
|
||||||
# style, look, screen, interface, color) that fired on non-UI prompts.
|
|
||||||
# Tightened again 2026-07-03: dropped bare design|component|composant|theme|
|
|
||||||
# thème|transition|frontend|front-end|palette — all common in non-UI technical
|
|
||||||
# talk (a design decision, a system component, the theme of a discussion, a
|
|
||||||
# state transition, frontend architecture). Kept as UI-specific compounds:
|
|
||||||
# "design system", "redesign", "front-?end design". dashboard -> \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
|
|
||||||
@@ -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 '<task-notification> <task-id>x</task-id> add css header fonts')" quiet
|
|
||||||
check D10-notif-file "$(fire '<task-notification> design-motion-principles keyframe done')" quiet
|
|
||||||
check D11-bare-ux "$(fire 'changement ux vu de tes trouvailles')" quiet
|
|
||||||
check D12-agent-msg "$(fire '<agent-message from=a1> [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 '<pasted_content> 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 ]
|
|
||||||
@@ -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 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
|
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
|
# T8a-T8i: blind spots of the file-citation census (nested dirs, project
|
||||||
# rules, home prefixes, left boundary, templates)
|
# rules, home prefixes, left boundary, templates, quoted label kept whole)
|
||||||
mkdir -p "$FIX/lib/sub" "$FIX/.claude/rules" "$FIX/templates/project-rules"
|
mkdir -p "$FIX/lib/sub" "$FIX/.claude/rules" "$FIX/templates/project-rules"
|
||||||
printf '## Alpha\n' > "$FIX/lib/sub/x.md"
|
printf '## Alpha\n' > "$FIX/lib/sub/x.md"
|
||||||
printf 'nested: lib/sub/x.md § Alpha\n' > "$FIX/n1.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/t1.md" >/dev/null; rc1=$?
|
||||||
citers_check_files "$FIX" "$FIX/t2.md" >/dev/null
|
citers_check_files "$FIX" "$FIX/t2.md" >/dev/null
|
||||||
check T8h-template-rules-path "$rc1|$?" "0|1"
|
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 ──────────────
|
# ── 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.)
|
# (`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 \
|
(cd "$ROOT" && citers_check_files "$FIX/copy" lib/architecture-defaults.md \
|
||||||
lib/project-archetypes/rest-api-node.md) >/dev/null
|
lib/project-archetypes/rest-api-node.md) >/dev/null
|
||||||
check T7b-real-rename-bites "$?" 2
|
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"
|
echo "PASS=$pass FAIL=$fail"
|
||||||
[ "$fail" -eq 0 ]
|
[ "$fail" -eq 0 ]
|
||||||
@@ -47,7 +47,7 @@ with /seo, /harden, /web-validate.
|
|||||||
## Design work — full toolchain (tiered by scope)
|
## Design work — full toolchain (tiered by scope)
|
||||||
Trigger = UI work: editing a component/style file (.tsx/.vue/.svelte/.css…)
|
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
|
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.
|
- Trivial (≤2 files, one cosmetic value) → /hotfix, no toolchain.
|
||||||
- Build UI (component, page, redesign) → impeccable (build path: init,
|
- Build UI (component, page, redesign) → impeccable (build path: init,
|
||||||
shape, new-work, craft floor, fresh finish reviewer) + ui-ux-pro-max +
|
shape, new-work, craft floor, fresh finish reviewer) + ui-ux-pro-max +
|
||||||
|
|||||||
@@ -511,12 +511,6 @@
|
|||||||
"UserPromptSubmit": [
|
"UserPromptSubmit": [
|
||||||
{
|
{
|
||||||
"hooks": [
|
"hooks": [
|
||||||
{
|
|
||||||
"type": "command",
|
|
||||||
"command": "bash ~/.claude/hooks/design-toolchain-reminder.sh",
|
|
||||||
"timeout": 5,
|
|
||||||
"statusMessage": "Checking design signals..."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "command",
|
"type": "command",
|
||||||
"command": "bash ~/.claude/hooks/ctx7-reminder.sh",
|
"command": "bash ~/.claude/hooks/ctx7-reminder.sh",
|
||||||
|
|||||||
Reference in new issue
Block a user