diff --git a/CLAUDE.global.md b/CLAUDE.global.md index 813843a..fabc896 100644 --- a/CLAUDE.global.md +++ b/CLAUDE.global.md @@ -303,10 +303,6 @@ office-hours…) are gone: use the fallback above, else say so. Threshold: graphify from 200 tracked code files, never below (banner line `graphify? N code files ≥ 200, no graph` informs, the user decides; never -build or `graphify claude install` without that go). ALL rules below apply -only if `graphify-out/graph.json` exists — else read files directly. -- Codebase-wide question → `graphify query`; relationships → `path A B`; - concept → `explain`. Scoped subgraph beats raw grep. -- Known file / small task → read directly, no graphify. -- `wiki/index.md` → broad-nav entry; `GRAPH_REPORT.md` → whole-architecture. -- After editing code → `graphify update .` (AST-only, free). +build or `graphify claude install` without that go). With a graph +(`graphify-out/graph.json`): `graphify query` before raw grep, +`graphify update .` after code edits; the session banner prints the rest. diff --git a/hooks/session-start.sh b/hooks/session-start.sh index 6a2a340..b81d262 100644 --- a/hooks/session-start.sh +++ b/hooks/session-start.sh @@ -7,7 +7,7 @@ # ── Quick health check (filesystem only, no subprocesses) ── BROKEN=() -for f in CLAUDE.md settings.json agents skills; do +for f in CLAUDE.md settings.json agents skills rules; do [ ! -e "$HOME/.claude/$f" ] && BROKEN+=("$f") done @@ -254,9 +254,9 @@ if [ -n "$GRAPHIFY_HINT" ]; then printf "│ 🕸️ %-44s│\n" "${GRAPHIFY_HINT:0:44}" printf "│ %-40s│\n" "→ /graphify (AST, seconds) — you decide" fi -# CLAUDE.global.md line-count guard (anti-regression). BDR-062 supersedes -# BDR-031's 275 target: 305 is the assumed reality (extraction done at -# job1; further compression costs clarity > token gain) — warn past 320. +# CLAUDE.global.md line-count guard (anti-regression, BDR-062): warn past +# 320. BDR-125 phase 1 moved Design work, the graphify usage and the +# architecture defaults to their carriers (333 → ~285 lines). if [ -n "$REPO_DIR" ] && [ -f "$REPO_DIR/CLAUDE.global.md" ]; then _claude_lines=$(wc -l < "$REPO_DIR/CLAUDE.global.md") if [ "$_claude_lines" -gt 320 ]; then @@ -293,5 +293,20 @@ echo "│ 💡 /plugin-check before starting a new project │" echo "│ 🩺 make doctor full diagnostic │" echo "└───────────────────────────────────────────────────┘" [ -n "$EFFORT_WARN" ] && printf '%s\n' "$EFFORT_WARN" +# graphify usage (BDR-125 phase 1): the rules left CLAUDE.global.md, which +# keeps the 200-file threshold and a one-line reminder; they print where a +# graph exists. +_gx_root=$(git rev-parse --show-toplevel 2>/dev/null) +if [ -n "$_gx_root" ] && [ -f "$_gx_root/graphify-out/graph.json" ]; then + cat <<'EOF' +graphify (graphify-out/graph.json present): +- Codebase-wide question → `graphify query`; relationships → `path A B`; + concept → `explain`. Scoped subgraph beats raw grep. +- Known file / small task → read directly, no graphify. +- `wiki/index.md` → broad-nav entry; `GRAPH_REPORT.md` → whole-architecture. +- After editing code → `graphify update .` (AST-only, free). +EOF +fi +unset _gx_root echo "" unset TOKEN_WARN diff --git a/lib/tests/graphify-gate.test.sh b/lib/tests/graphify-gate.test.sh index 221d2fb..90bb50e 100644 --- a/lib/tests/graphify-gate.test.sh +++ b/lib/tests/graphify-gate.test.sh @@ -56,5 +56,21 @@ for i in $(seq 1 300); do echo "# $i" > "$d/doc$i.md"; done git -C "$d" add -A; git -C "$d" commit -q -m docs check T9-non-code-not-counted "$(gate "$d")" silent +# ── session-start prints the usage rules only where a graph exists +# (BDR-125 phase 1: the body left CLAUDE.global.md) ── +SS="$(cd "$(dirname "$0")/../.." && pwd)/hooks/session-start.sh" +banner() { (cd "$1" && SESSION_START_OFFLINE=1 bash "$SS" /dev/null); } +d=$(mkrepo ss 1) +out=$(banner "$d") +check S1-banner-control "$(grep -c 'Claude Code config' <<<"$out")" 1 +check S1b-no-graph-silent "$(grep -c 'graphify query' <<<"$out")" 0 +mkdir -p "$d/graphify-out" "$d/app/sub"; echo '{}' > "$d/graphify-out/graph.json" +out=$(banner "$d") +check S2-graph-prints "$(grep -c 'graphify query' <<<"$out")" 1 +check S2b-update-rule "$(grep -c 'graphify update \.' <<<"$out")" 1 +check S3-from-subdir "$(banner "$d/app/sub" | grep -c 'graphify query')" 1 +out=$(banner "$WORK/plain") +check S4-not-a-repo "$(grep -c 'graphify query' <<<"$out")/$(grep -c 'Claude Code config' <<<"$out")" 0/1 + echo "PASS=$pass FAIL=$fail" [ "$fail" -eq 0 ]