From 629e00d6d7a83ade3fee0dcb90d6adbd58a66159 Mon Sep 17 00:00:00 2001 From: ChesnoTech <263363000+ChesnoTech@users.noreply.github.com> Date: Wed, 6 May 2026 00:08:22 +0300 Subject: [PATCH] Integrate graphify knowledge graph into project workflow Wire up the graphify skill (~/.claude/skills/graphify) so it's enforced project-wide, with auto-rebuild on commits and code edits. Changes: - .claude/settings.json: PreToolUse hook for grep/find tools now points to FINAL_PRODUCTION_SYSTEM/graphify-out/ (the actual graph location). - Added PostToolUse hook that tracks Edit/Write/MultiEdit on code files and a Stop hook that triggers `graphify update FINAL_PRODUCTION_SYSTEM` in background when changes touched FINAL_PRODUCTION_SYSTEM/. - CLAUDE.md: graphify rules now reference FINAL_PRODUCTION_SYSTEM/graphify-out/ with correct commands. - .gitignore: ignore graphify-out/ artifacts (12MB+ graph.json + 25MB cache), rebuilt locally by post-commit hook. - Git hooks (post-commit + post-checkout) installed via `graphify hook install`. Initial graph state: 13,138 nodes, 19,511 edges, 1,260 communities, AST-only extraction. --- .claude/settings.json | 33 +++++++++++++++++++++++++++++++++ .gitignore | 4 ++++ CLAUDE.md | 11 +++++++++++ 3 files changed, 48 insertions(+) diff --git a/.claude/settings.json b/.claude/settings.json index 9787a30..eef9d0d 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -11,6 +11,39 @@ "statusMessage": "Checking branding consistency..." } ] + }, + { + "matcher": "Edit|Write|MultiEdit|NotebookEdit", + "hooks": [ + { + "type": "command", + "command": "FP=$(jq -r '.tool_input.file_path // \"\"' 2>/dev/null); case \"$FP\" in *FINAL_PRODUCTION_SYSTEM*) echo \"$FP\" >> /tmp/keygate_graph_dirty 2>/dev/null ;; esac; true", + "timeout": 5 + } + ] + } + ], + "Stop": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "if [ -s /tmp/keygate_graph_dirty ]; then COUNT=$(wc -l < /tmp/keygate_graph_dirty); rm -f /tmp/keygate_graph_dirty; (cd \"$PWD\" && command -v graphify >/dev/null 2>&1 && graphify update FINAL_PRODUCTION_SYSTEM > /tmp/keygate_graph.log 2>&1 &) ; echo \"{\\\"systemMessage\\\":\\\"\\ud83d\\udd04 graphify: $COUNT code file(s) changed \\u2014 graph rebuild started in background.\\\"}\"; fi; true", + "timeout": 5 + } + ] + } + ], + "PreToolUse": [ + { + "matcher": "Bash", + "hooks": [ + { + "type": "command", + "command": "CMD=$(python3 -c \"import json,sys; d=json.load(sys.stdin); print(d.get('tool_input',d).get('command',''))\" 2>/dev/null || true); case \"$CMD\" in *grep*|*rg\\ *|*ripgrep*|*find\\ *|*fd\\ *|*ack\\ *|*ag\\ *) [ -f FINAL_PRODUCTION_SYSTEM/graphify-out/graph.json ] && echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"additionalContext\":\"graphify: Knowledge graph exists at FINAL_PRODUCTION_SYSTEM/graphify-out/. Read GRAPH_REPORT.md for god nodes and community structure before searching raw files. Or run: graphify query \\\"\\\" / graphify explain \\\"\\\" / graphify path \\\"\\\" \\\"\\\".\"}}' || true ;; esac" + } + ] } ] } diff --git a/.gitignore b/.gitignore index c255ad8..8cb5ce7 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,10 @@ ssl/*.pem logs/ *.log +# ── graphify output (auto-rebuilt by post-commit hook, AST-only, no LLM) ─ +# Don't commit 12MB+ artifacts — every dev rebuilds locally on first commit. +**/graphify-out/ + # ── PHP Dependencies (managed by Composer) ──────────────── FINAL_PRODUCTION_SYSTEM/vendor/ diff --git a/CLAUDE.md b/CLAUDE.md index 0d9bed8..c9a60a6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -434,3 +434,14 @@ DocumentRoot is `/var/www/html/activate` — API URLs are `/api/...` from inside | `App.tsx` | React router with 24 routes | | `app-sidebar.tsx` | Navigation with 5 groups, 30 items | | `api-contracts.test.ts` | Backend action registry validation | + +## graphify + +KeyGate has a graphify knowledge graph at `FINAL_PRODUCTION_SYSTEM/graphify-out/` (13,138 nodes, 19,511 edges, 1,260 communities — AST-only). + +Rules: +- Before answering architecture or codebase questions, read `FINAL_PRODUCTION_SYSTEM/graphify-out/GRAPH_REPORT.md` for god nodes and community structure +- If `FINAL_PRODUCTION_SYSTEM/graphify-out/wiki/index.md` exists, navigate it instead of reading raw files +- For cross-module "how does X relate to Y" questions, prefer `graphify query ""`, `graphify path "" ""`, or `graphify explain ""` over grep — these traverse the graph's EXTRACTED + INFERRED edges instead of scanning files +- After modifying code files in this session, run `graphify update FINAL_PRODUCTION_SYSTEM` to keep the graph current (AST-only, no API cost) +- Git post-commit + post-checkout hooks auto-rebuild graph on commits / branch switches