[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M786ES368JGMB6DD6BSB3QD2":3,"skill-same:01M786ES368JGMB6DD6BSB3QD2":91},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":6,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":33,"install":34,"resources":46},"01M786ES368JGMB6DD6BSB3QD2","graphify-protocol",null,"Use for any question about a codebase, its architecture, file relationships, or project content — especially when graphify-out\u002F exists, where the question should be treated as a graphify query first. Turns any input (code, docs, papers, images, videos) into a persistent knowledge graph with god nodes, community detection, and query\u002Fpath\u002Fexplain tools.","kalaverin\u002Fskills","kalaverin","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6841312?v=4","01M786EMXK5R6A138KWFAS33T1","Alex Kalaverin","01M786EMYBQEDP3548REZHRX2Q",1,"BSD-3-Clause","https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: graphify-protocol\ndescription: \"Use for any question about a codebase, its architecture, file relationships, or project content — especially when graphify-out\u002F exists, where the question should be treated as a graphify query first. Turns any input (code, docs, papers, images, videos) into a persistent knowledge graph with god nodes, community detection, and query\u002Fpath\u002Fexplain tools.\"\ndraft: true\ntriggers:\n  files: \"test -d graphify-out\"\n---\n\n# \u002Fgraphify\n\nTurn any folder of files into a navigable knowledge graph with community detection, an honest audit trail, and three outputs: interactive HTML, GraphRAG-ready JSON, and a plain-language GRAPH_REPORT.md.\n\n## Usage\n\n```\n\u002Fgraphify                                             # full pipeline on current directory → Obsidian vault\n\u002Fgraphify \u003Cpath>                                      # full pipeline on specific path\n\u002Fgraphify https:\u002F\u002Fgithub.com\u002F\u003Cowner>\u002F\u003Crepo>           # clone repo then run full pipeline on it\n\u002Fgraphify https:\u002F\u002Fgithub.com\u002F\u003Cowner>\u002F\u003Crepo> --branch \u003Cbranch>  # clone a specific branch\n\u002Fgraphify \u003Curl1> \u003Curl2> ...                           # clone multiple repos, build each, merge into one cross-repo graph\n\u002Fgraphify \u003Cpath> --mode deep                          # thorough extraction, richer INFERRED edges\n\u002Fgraphify \u003Cpath> --update                             # incremental - re-extract only new\u002Fchanged files\n\u002Fgraphify \u003Cpath> --directed                            # build directed graph (preserves edge direction: source→target)\n\u002Fgraphify \u003Cpath> --whisper-model medium                # use a larger Whisper model for better transcription accuracy\n\u002Fgraphify \u003Cpath> --cluster-only                       # rerun clustering on existing graph\n\u002Fgraphify \u003Cpath> --no-viz                             # skip visualization, just report + JSON\n\u002Fgraphify \u003Cpath> --html                               # (HTML is generated by default - this flag is a no-op)\n\u002Fgraphify \u003Cpath> --svg                                # also export graph.svg (embeds in Notion, GitHub)\n\u002Fgraphify \u003Cpath> --graphml                            # export graph.graphml (Gephi, yEd)\n\u002Fgraphify \u003Cpath> --neo4j                              # generate graphify-out\u002Fcypher.txt for Neo4j\n\u002Fgraphify \u003Cpath> --neo4j-push bolt:\u002F\u002Flocalhost:7687   # push directly to Neo4j\n\u002Fgraphify \u003Cpath> --falkordb                           # generate graphify-out\u002Fcypher.txt for FalkorDB\n\u002Fgraphify \u003Cpath> --falkordb-push falkordb:\u002F\u002Flocalhost:6379   # push directly to FalkorDB\n\u002Fgraphify \u003Cpath> --mcp                                # start MCP stdio server for agent access\n\u002Fgraphify \u003Cpath> --watch                              # watch folder, auto-rebuild on code changes (no LLM needed)\n\u002Fgraphify \u003Cpath> --wiki                               # build agent-crawlable wiki (index.md + one article per community)\n\u002Fgraphify \u003Cpath> --obsidian --obsidian-dir ~\u002Fvaults\u002Fmy-project  # write vault to custom path (e.g. existing vault)\"\n\u002Fgraphify add \u003Curl>                                   # fetch URL, save to .\u002Fraw, update graph\"\n\u002Fgraphify add \u003Curl> --author \"Name\"                   # tag who wrote it\n\u002Fgraphify add \u003Curl> --contributor \"Name\"              # tag who added it to the corpus\n\u002Fgraphify query \"\u003Cquestion>\"                          # BFS traversal - broad context\n\u002Fgraphify query \"\u003Cquestion>\" --dfs                    # DFS - trace a specific path\n\u002Fgraphify query \"\u003Cquestion>\" --budget 1500            # cap answer at N tokens\n\u002Fgraphify path \"AuthModule\" \"Database\"                # shortest path between two concepts\n\u002Fgraphify explain \"SwinTransformer\"                   # plain-language explanation of a node\n```\n\n## What graphify is for\n\nDrop any folder of code, docs, papers, images, or video into graphify and get a queryable knowledge graph. Persistent across sessions, honest audit trail (EXTRACTED\u002FINFERRED\u002FAMBIGUOUS), community detection surfaces cross-document connections you wouldn't think to ask about.\n\n## What You Must Do When Invoked\n\nIf the user invoked `\u002Fgraphify --help` or `\u002Fgraphify -h` (with no other arguments), print the contents of the `## Usage` section above verbatim and stop. Do not run any commands, do not detect files, do not default the path to `.`. Just print the Usage block and return.\n\n**Fast path — existing graph:** Before doing anything else, check whether `graphify-out\u002Fgraph.json` exists. The expected location is `graphify-out\u002Fgraph.json` relative to the **current working directory** (i.e. the project root where you are running commands). If it exists AND the user's request is a natural-language question about the codebase (e.g. \"How does X work?\", \"What calls Y?\", \"Trace the data flow through Z\") and NOT an explicit rebuild command (`--update`, `--cluster-only`, or a bare path\u002FURL that implies fresh extraction): **skip Steps 1–5 entirely and jump straight to `## For \u002Fgraphify query`.** Run `graphify query \"\u003Cquestion>\"` immediately. Do not run detect. Do not check corpus size. Do not ask the user to narrow. The graph is already built — use it.\n\nIf no path was given, use `.` (current directory). Do not ask the user for a path.\n\nIf the path argument starts with `https:\u002F\u002Fgithub.com\u002F` or `http:\u002F\u002Fgithub.com\u002F`, treat it as a GitHub URL - run Step 0 before anything else, then continue with the resolved local path.\n\nFollow these steps in order. Do not skip steps.\n\n### Step 0 - GitHub repos and multi-path merge (only if a URL or several paths)\n\nOnly when the path is one or more `https:\u002F\u002Fgithub.com\u002F...` URLs, or several local subfolders to merge. See `references\u002Fgithub-and-merge.md` for the clone, cross-repo merge, and monorepo flow, then continue with the resolved local path. A plain local path skips this step.\n\n### Step 1 - Ensure graphify is installed\n\n```bash\n# Detect the correct Python interpreter (handles uv tool, pipx, venv, system installs)\nPYTHON=\"\"\nGRAPHIFY_BIN=$(which graphify 2>\u002Fdev\u002Fnull)\n# 1. uv tool installs — most reliable on modern Mac\u002FLinux\nif [ -z \"$PYTHON\" ] && command -v uv >\u002Fdev\u002Fnull 2>&1; then\n    _UV_PY=$(uv tool run graphifyy python -c \"import sys; print(sys.executable)\" 2>\u002Fdev\u002Fnull)\n    if [ -n \"$_UV_PY\" ]; then PYTHON=\"$_UV_PY\"; fi\nfi\n# 2. Read shebang from graphify binary (pipx and direct pip installs)\nif [ -z \"$PYTHON\" ] && [ -n \"$GRAPHIFY_BIN\" ]; then\n    _SHEBANG=$(head -1 \"$GRAPHIFY_BIN\" | tr -d '#!')\n    case \"$_SHEBANG\" in\n        *[!a-zA-Z0-9\u002F_.-]*) ;;\n        *) \"$_SHEBANG\" -c \"import graphify\" 2>\u002Fdev\u002Fnull && PYTHON=\"$_SHEBANG\" ;;\n    esac\nfi\n# 3. Fall back to python3\nif [ -z \"$PYTHON\" ]; then PYTHON=\"python3\"; fi\nif ! \"$PYTHON\" -c \"import graphify\" 2>\u002Fdev\u002Fnull; then\n    if command -v uv >\u002Fdev\u002Fnull 2>&1; then\n        uv tool install --upgrade graphifyy -q 2>&1 | tail -3\n        _UV_PY=$(uv tool run graphifyy python -c \"import sys; print(sys.executable)\" 2>\u002Fdev\u002Fnull)\n        if [ -n \"$_UV_PY\" ]; then PYTHON=\"$_UV_PY\"; fi\n    else\n        \"$PYTHON\" -m pip install graphifyy -q 2>\u002Fdev\u002Fnull \\\n          || \"$PYTHON\" -m pip install graphifyy -q --break-system-packages 2>&1 | tail -3\n    fi\nfi\n# Write interpreter path for all subsequent steps (persists across invocations)\nmkdir -p graphify-out\n\"$PYTHON\" -c \"import sys; open('graphify-out\u002F.graphify_python', 'w', encoding='utf-8').write(sys.executable)\"\n# Save scan root so `graphify update` (no args) knows where to look next time\necho \"$(cd INPUT_PATH && pwd)\" > graphify-out\u002F.graphify_root\n```\n\nIf the import succeeds, print nothing and move straight to Step 2.\n\n**In every subsequent bash block, replace `python3` with `$(cat graphify-out\u002F.graphify_python)` to use the correct interpreter.**\n\n### Step 2 - Detect files\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.detect import detect\nfrom pathlib import Path\nresult = detect(Path('INPUT_PATH'))\nprint(json.dumps(result, ensure_ascii=False))\n\" > graphify-out\u002F.graphify_detect.json\n```\n\nReplace INPUT_PATH with the actual path the user provided. Do NOT cat or print the JSON - read it silently and present a clean summary instead:\n\n```\nCorpus: X files · ~Y words\n  code:     N files (.py .ts .go ...)\n  docs:     N files (.md .txt ...)\n  papers:   N files (.pdf ...)\n  images:   N files\n  video:    N files (.mp4 .mp3 ...)\n```\n\nOmit any category with 0 files from the summary.\n\nThen act on it:\n- If `total_files` is 0: stop with \"No supported files found in [path].\"\n- If `skipped_sensitive` is non-empty: mention file count skipped, not the file names.\n- If `total_words` > 2,000,000 OR `total_files` > 500: show the warning. Then compute the top 5 first-level subdirectories by file count:\n  - Read `scan_root` from the detect JSON (always an absolute path to the resolved INPUT_PATH).\n  - Concatenate all file lists across all types (`code`, `document`, `paper`, `image`, `video`).\n  - Filter out any path that starts with `scan_root + \"\u002Fgraphify-out\u002F\"` to exclude converted sidecars.\n  - For each file, strip the `scan_root` prefix and take the first path component. Files directly in `scan_root` with no subdirectory count as `(root)`.\n  - If all files are in `(root)` with no subdirectories, do not ask to narrow — no subfolders exist. Instead suggest `--no-cluster` to skip the expensive clustering step and proceed.\n  - Otherwise rank by count, show the top 5 with file counts, then ask which subfolder to run on. Wait for the user's answer before proceeding.\n- Otherwise: proceed directly to Step 2.5 if video files were detected, or Step 3 if not.\n\n### Step 2.5 - Video and audio (only if video files detected)\n\nSkip this step entirely if `detect` returned zero `video` files. When the corpus has video or audio, see `references\u002Ftranscribe.md` to transcribe them to text first, then treat the transcripts as doc files in Step 3.\n\n### Step 3 - Extract entities and relationships\n\n**Before starting:** note whether `--mode deep` was given. You must pass `DEEP_MODE=true` to every subagent in Step B2 if it was. Track this from the original invocation - do not lose it.\n\nThis step has two parts: **structural extraction** (deterministic, free) and **semantic extraction** (LLM, costs tokens).\n\n**Before dispatching subagents:** check whether `GEMINI_API_KEY` or `GOOGLE_API_KEY` is set. If neither is set, print this one-liner to the user:\n> Tip: set `GEMINI_API_KEY` or `GOOGLE_API_KEY` to use Gemini for semantic extraction (`pip install 'graphifyy[gemini]'`).\n\nPrint it once, then continue. If `GEMINI_API_KEY` or `GOOGLE_API_KEY` IS set, use `graphify.llm.extract_corpus_parallel(files, backend=\"gemini\")` for semantic extraction instead of dispatching Claude subagents. The default Gemini model is `gemini-3-flash-preview`; set `GRAPHIFY_GEMINI_MODEL` or pass `--model` in headless CLI flows to override it.\n\n> **No other API keys are read.** If `GEMINI_API_KEY`\u002F`GOOGLE_API_KEY` are unset, fall straight through to Claude Code subagent dispatch (Part B below) — the host session itself is the LLM. graphify does **not** read `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, or any other provider key from the environment. If a host agent prompts the user for `ANTHROPIC_API_KEY` to run extraction, that prompt is a misread of this skill — ignore it and dispatch subagents as written.\n\n**Run Part A (AST) and Part B (semantic) in parallel. Dispatch all semantic subagents AND start AST extraction in the same message. Both can run simultaneously since they operate on different file types. Merge results in Part C as before.**\n\nNote: Parallelizing AST + semantic saves 5-15s on large corpora. AST is deterministic and fast; start it while subagents are processing docs\u002Fpapers.\n\n#### Part A - Structural extraction for code files\n\nFor any code files detected, run AST extraction in parallel with Part B subagents:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.extract import collect_files, extract\nfrom pathlib import Path\nimport json\n\ncode_files = []\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\nfor f in detect.get('files', {}).get('code', []):\n    code_files.extend(collect_files(Path(f)) if Path(f).is_dir() else [Path(f)])\n\nif code_files:\n    result = extract(code_files, cache_root=Path('.'))\n    Path('graphify-out\u002F.graphify_ast.json').write_text(json.dumps(result, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\n    print(f'AST: {len(result[\\\"nodes\\\"])} nodes, {len(result[\\\"edges\\\"])} edges')\nelse:\n    Path('graphify-out\u002F.graphify_ast.json').write_text(json.dumps({'nodes':[],'edges':[],'input_tokens':0,'output_tokens':0}, ensure_ascii=False), encoding=\\\"utf-8\\\")\n    print('No code files - skipping AST extraction')\n\"\n```\n\n#### Part B - Semantic extraction (parallel subagents)\n\n**Fast path:** If detection found zero docs, papers, and images (code-only corpus), skip Part B entirely and go straight to Part C. AST handles code - there is nothing for semantic subagents to do.\n\n**MANDATORY: You MUST use the Agent tool here. Reading files yourself one-by-one is forbidden - it is 5-10x slower. If you do not use the Agent tool you are doing this wrong.**\n\nBefore dispatching subagents, print a timing estimate:\n- Load `total_words` and file counts from `graphify-out\u002F.graphify_detect.json`\n- Estimate agents needed: `ceil(uncached_non_code_files \u002F 22)` (chunk size is 20-25)\n- Estimate time: ~45s per agent batch (they run in parallel, so total ≈ 45s × ceil(agents\u002Fparallel_limit))\n- Print: \"Semantic extraction: ~N files → X agents, estimated ~Ys\"\n\n**Step B0 - Check extraction cache first**\n\nBefore dispatching any subagents, check which files already have cached extraction results:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.cache import check_semantic_cache\nfrom pathlib import Path\n\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\nall_files = [f for files in detect['files'].values() for f in files]\n\ncached_nodes, cached_edges, cached_hyperedges, uncached = check_semantic_cache(all_files)\n\nif cached_nodes or cached_edges or cached_hyperedges:\n    Path('graphify-out\u002F.graphify_cached.json').write_text(json.dumps({'nodes': cached_nodes, 'edges': cached_edges, 'hyperedges': cached_hyperedges}, ensure_ascii=False), encoding=\\\"utf-8\\\")\nPath('graphify-out\u002F.graphify_uncached.txt').write_text('\\n'.join(uncached), encoding=\\\"utf-8\\\")\nprint(f'Cache: {len(all_files)-len(uncached)} files hit, {len(uncached)} files need extraction')\n\"\n```\n\nOnly dispatch subagents for files listed in `graphify-out\u002F.graphify_uncached.txt`. If all files are cached, skip to Part C directly.\n\n**Step B1 - Split into chunks**\n\nLoad files from `graphify-out\u002F.graphify_uncached.txt`. Split into chunks of 20-25 files each. Each image gets its own chunk (vision needs separate context). When splitting, group files from the same directory together so related artifacts land in the same chunk and cross-file relationships are more likely to be extracted.\n\n**Step B2 - Dispatch ALL subagents in a single message**\n\nCall the Agent tool multiple times IN THE SAME RESPONSE - one call per chunk. This is the only way they run in parallel. If you make one Agent call, wait, then make another, you are doing it sequentially and defeating the purpose.\n\n**IMPORTANT - subagent type:** Always use `subagent_type=\"general-purpose\"`. Do NOT use `Explore` - it is read-only and cannot write chunk files to disk, which silently drops extraction results. General-purpose has Write and Bash access which the subagent needs.\n\nConcrete example for 3 chunks:\n```\n[Agent tool call 1: files 1-15, subagent_type=\"general-purpose\"]\n[Agent tool call 2: files 16-30, subagent_type=\"general-purpose\"]\n[Agent tool call 3: files 31-45, subagent_type=\"general-purpose\"]\n```\nAll three in one message. Not three separate messages.\n\nEach subagent receives this exact prompt (substitute FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, DEEP_MODE, and CHUNK_PATH).\n\nCHUNK_PATH must be an **absolute** path — derive it before dispatching:\n```bash\nPROJECT_ROOT=$(cat graphify-out\u002F.graphify_root)\n# Then for chunk N: CHUNK_PATH=\"${PROJECT_ROOT}\u002Fgraphify-out\u002F.graphify_chunk_0N.json\"\n```\n\nSubagent prompt template:\n\nSee `references\u002Fextraction-spec.md` for the exact subagent prompt (JSON schema, node-ID rules, confidence rubric, frontmatter, hyperedge, and vision rules). Load it only here, only when at least one chunk holds a doc, paper, or image; a pure-code corpus has skipped Part B and never reads it. Pass each subagent that prompt verbatim with FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, DEEP_MODE, and CHUNK_PATH substituted, and have it write the result to CHUNK_PATH.\n\n**Step B3 - Collect, cache, and merge**\n\nWait for all subagents. For each result:\n- Check that `graphify-out\u002F.graphify_chunk_NN.json` exists on disk — this is the success signal\n- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache\n- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: \"chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent.\" Do not silently skip.\n- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort\n\nIf more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type=\"general-purpose\"` is used.\n\nMerge all chunk files into `.graphify_semantic_new.json`. **After each Agent call completes, read the real token counts from the Agent tool result's `usage` field and write them back into the chunk JSON before merging** — the chunk JSON itself always has placeholder zeros. Then run:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json, glob\nfrom pathlib import Path\n\nchunks = sorted(glob.glob('graphify-out\u002F.graphify_chunk_*.json'))\nall_nodes, all_edges, all_hyperedges = [], [], []\ntotal_in, total_out = 0, 0\nfor c in chunks:\n    d = json.loads(Path(c).read_text(encoding=\\\"utf-8\\\"))\n    all_nodes += d.get('nodes', [])\n    all_edges += d.get('edges', [])\n    all_hyperedges += d.get('hyperedges', [])\n    total_in += d.get('input_tokens', 0)\n    total_out += d.get('output_tokens', 0)\nPath('graphify-out\u002F.graphify_semantic_new.json').write_text(json.dumps({\n    'nodes': all_nodes, 'edges': all_edges, 'hyperedges': all_hyperedges,\n    'input_tokens': total_in, 'output_tokens': total_out,\n}, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\nprint(f'Merged {len(chunks)} chunks: {total_in:,} in \u002F {total_out:,} out tokens')\n\"\n```\n\nSave new results to cache:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.cache import save_semantic_cache\nfrom pathlib import Path\n\nnew = json.loads(Path('graphify-out\u002F.graphify_semantic_new.json').read_text(encoding=\\\"utf-8\\\")) if Path('graphify-out\u002F.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\nsaved = save_semantic_cache(new.get('nodes', []), new.get('edges', []), new.get('hyperedges', []))\nprint(f'Cached {saved} files')\n\"\n```\n\nMerge cached + new results into `graphify-out\u002F.graphify_semantic.json`:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom pathlib import Path\n\ncached = json.loads(Path('graphify-out\u002F.graphify_cached.json').read_text(encoding=\\\"utf-8\\\")) if Path('graphify-out\u002F.graphify_cached.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\nnew = json.loads(Path('graphify-out\u002F.graphify_semantic_new.json').read_text(encoding=\\\"utf-8\\\")) if Path('graphify-out\u002F.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\n\nall_nodes = cached['nodes'] + new.get('nodes', [])\nall_edges = cached['edges'] + new.get('edges', [])\nall_hyperedges = cached.get('hyperedges', []) + new.get('hyperedges', [])\nseen = set()\ndeduped = []\nfor n in all_nodes:\n    if n['id'] not in seen:\n        seen.add(n['id'])\n        deduped.append(n)\n\nmerged = {\n    'nodes': deduped,\n    'edges': all_edges,\n    'hyperedges': all_hyperedges,\n    'input_tokens': new.get('input_tokens', 0),\n    'output_tokens': new.get('output_tokens', 0),\n}\nPath('graphify-out\u002F.graphify_semantic.json').write_text(json.dumps(merged, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\nprint(f'Extraction complete - {len(deduped)} nodes, {len(all_edges)} edges ({len(cached[\\\"nodes\\\"])} from cache, {len(new.get(\\\"nodes\\\",[]))} new)')\n\"\n```\nClean up temp files: `rm -f graphify-out\u002F.graphify_cached.json graphify-out\u002F.graphify_uncached.txt graphify-out\u002F.graphify_semantic_new.json`\n\n#### Part C - Merge AST + semantic into final extraction\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom pathlib import Path\n\nast = json.loads(Path('graphify-out\u002F.graphify_ast.json').read_text(encoding=\\\"utf-8\\\"))\nsem = json.loads(Path('graphify-out\u002F.graphify_semantic.json').read_text(encoding=\\\"utf-8\\\"))\n\n# Merge: AST nodes first, semantic nodes deduplicated by id\nseen = {n['id'] for n in ast['nodes']}\nmerged_nodes = list(ast['nodes'])\nfor n in sem['nodes']:\n    if n['id'] not in seen:\n        merged_nodes.append(n)\n        seen.add(n['id'])\n\nmerged_edges = ast['edges'] + sem['edges']\nmerged_hyperedges = sem.get('hyperedges', [])\nmerged = {\n    'nodes': merged_nodes,\n    'edges': merged_edges,\n    'hyperedges': merged_hyperedges,\n    'input_tokens': sem.get('input_tokens', 0),\n    'output_tokens': sem.get('output_tokens', 0),\n}\nPath('graphify-out\u002F.graphify_extract.json').write_text(json.dumps(merged, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\ntotal = len(merged_nodes)\nedges = len(merged_edges)\nprint(f'Merged: {total} nodes, {edges} edges ({len(ast[\\\"nodes\\\"])} AST + {len(sem[\\\"nodes\\\"])} semantic)')\n\"\n```\n\n### Step 4 - Build graph, cluster, analyze, generate outputs\n\n**Before starting:** note whether `--directed` was given. If so, pass `directed=True` to `build_from_json()` in the code block below. This builds a `DiGraph` that preserves edge direction (source→target) instead of the default undirected `Graph`.\n\n```bash\nmkdir -p graphify-out\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.cluster import cluster, score_all\nfrom graphify.analyze import god_nodes, surprising_connections, suggest_questions\nfrom graphify.report import generate\nfrom graphify.export import to_json\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text(encoding=\\\"utf-8\\\"))\ndetection  = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\n\nG = build_from_json(extraction)\ncommunities = cluster(G)\ncohesion = score_all(G, communities)\ntokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}\ngods = god_nodes(G)\nsurprises = surprising_connections(G, communities)\nlabels = {cid: 'Community ' + str(cid) for cid in communities}\n# Placeholder questions - regenerated with real labels in Step 5\nquestions = suggest_questions(G, communities, labels)\n\nreport = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, '.', suggested_questions=questions)\nPath('graphify-out\u002FGRAPH_REPORT.md').write_text(report, encoding=\\\"utf-8\\\")\nto_json(G, communities, 'graphify-out\u002Fgraph.json')\n\nanalysis = {\n    'communities': {str(k): v for k, v in communities.items()},\n    'cohesion': {str(k): v for k, v in cohesion.items()},\n    'gods': gods,\n    'surprises': surprises,\n    'questions': questions,\n}\nPath('graphify-out\u002F.graphify_analysis.json').write_text(json.dumps(analysis, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\nif G.number_of_nodes() == 0:\n    print('ERROR: Graph is empty - extraction produced no nodes.')\n    print('Possible causes: all files were skipped, binary-only corpus, or extraction failed.')\n    raise SystemExit(1)\nprint(f'Graph: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges, {len(communities)} communities')\n\"\n```\n\nIf this step prints `ERROR: Graph is empty`, stop and tell the user what happened - do not proceed to labeling or visualization.\n\nReplace INPUT_PATH with the actual path.\n\n### Step 5 - Label communities\n\nRead `graphify-out\u002F.graphify_analysis.json`. For each community key, look at its node labels and write a 2-5 word plain-language name (e.g. \"Attention Mechanism\", \"Training Pipeline\", \"Data Loading\").\n\nThen regenerate the report and save the labels for the visualizer:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.cluster import score_all\nfrom graphify.analyze import god_nodes, surprising_connections, suggest_questions\nfrom graphify.report import generate\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text(encoding=\\\"utf-8\\\"))\ndetection  = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text(encoding=\\\"utf-8\\\"))\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\ncohesion = {int(k): v for k, v in analysis['cohesion'].items()}\ntokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}\n\n# LABELS - replace these with the names you chose above\nlabels = LABELS_DICT\n\n# Regenerate questions with real community labels (labels affect question phrasing)\nquestions = suggest_questions(G, communities, labels)\n\nreport = generate(G, communities, cohesion, labels, analysis['gods'], analysis['surprises'], detection, tokens, '.', suggested_questions=questions)\nPath('graphify-out\u002FGRAPH_REPORT.md').write_text(report, encoding=\\\"utf-8\\\")\nPath('graphify-out\u002F.graphify_labels.json').write_text(json.dumps({str(k): v for k, v in labels.items()}, ensure_ascii=False), encoding=\\\"utf-8\\\")\nprint('Report updated with community labels')\n\"\n```\n\nReplace `LABELS_DICT` with the actual dict you constructed (e.g. `{0: \"Attention Mechanism\", 1: \"Training Pipeline\"}`).\nReplace INPUT_PATH with the actual path.\n\n### Step 6 - Generate Obsidian vault (opt-in) + HTML\n\n**Generate HTML always** (unless `--no-viz`). **Obsidian vault only if `--obsidian` was explicitly given** — skip it otherwise, it generates one file per node.\n\nIf `--obsidian` was given:\n\n- If `--obsidian-dir \u003Cpath>` was also given, pass it via `--dir`. Otherwise defaults to `graphify-out\u002Fobsidian`.\n\n```bash\ngraphify export obsidian\n# or with custom dir: graphify export obsidian --dir ~\u002Fvaults\u002Fmy-project\n```\n\nGenerate the HTML graph (always, unless `--no-viz`):\n\n```bash\ngraphify export html  # auto-aggregates to community view if graph > 5000 nodes\n# or: graphify export html --no-viz\n```\n\n### Steps 6b-8 - Wiki, Neo4j, FalkorDB, SVG, GraphML, MCP, benchmark (only on their flags)\n\nThese run only when their flag is present (`--wiki`, `--neo4j`\u002F`--neo4j-push`, `--falkordb`\u002F`--falkordb-push`, `--svg`, `--graphml`, `--mcp`) or, for the token-reduction benchmark, when `total_words` exceeds 5,000. A default run with no export flags skips all of them. See `references\u002Fexports.md` for each one. Run any `--wiki` export before Step 9 cleanup so `.graphify_labels.json` is still available.\n\n---\n\n### Step 9 - Save manifest, update cost tracker, clean up, and report\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom pathlib import Path\nfrom datetime import datetime, timezone\nfrom graphify.detect import save_manifest\n\n# Save manifest for --update\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\n# In --update mode, 'all_files' carries the full corpus; 'files' is the changed\n# subset. Full-rebuild mode populates only 'files', so the fallback handles that.\nsave_manifest(detect.get('all_files') or detect['files'])\n\n# Update cumulative cost tracker\nextract = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text(encoding=\\\"utf-8\\\"))\ninput_tok = extract.get('input_tokens', 0)\noutput_tok = extract.get('output_tokens', 0)\n\ncost_path = Path('graphify-out\u002Fcost.json')\nif cost_path.exists():\n    cost = json.loads(cost_path.read_text(encoding=\\\"utf-8\\\"))\nelse:\n    cost = {'runs': [], 'total_input_tokens': 0, 'total_output_tokens': 0}\n\ncost['runs'].append({\n    'date': datetime.now(timezone.utc).isoformat(),\n    'input_tokens': input_tok,\n    'output_tokens': output_tok,\n    'files': detect.get('total_files', 0),\n})\ncost['total_input_tokens'] += input_tok\ncost['total_output_tokens'] += output_tok\ncost_path.write_text(json.dumps(cost, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\n\nprint(f'This run: {input_tok:,} input tokens, {output_tok:,} output tokens')\nprint(f'All time: {cost[\\\"total_input_tokens\\\"]:,} input, {cost[\\\"total_output_tokens\\\"]:,} output ({len(cost[\\\"runs\\\"])} runs)')\n\"\nrm -f graphify-out\u002F.graphify_detect.json graphify-out\u002F.graphify_extract.json graphify-out\u002F.graphify_ast.json graphify-out\u002F.graphify_semantic.json graphify-out\u002F.graphify_analysis.json\nfind graphify-out -maxdepth 1 -name '.graphify_chunk_*.json' -delete 2>\u002Fdev\u002Fnull\nrm -f graphify-out\u002F.needs_update 2>\u002Fdev\u002Fnull || true\n```\n\nTell the user (omit the obsidian line unless --obsidian was given):\n```\nGraph complete. Outputs in PATH_TO_DIR\u002Fgraphify-out\u002F\n\n  graph.html            - interactive graph, open in browser\n  GRAPH_REPORT.md       - audit report\n  graph.json            - raw graph data\n  obsidian\u002F             - Obsidian vault (only if --obsidian was given)\n```\n\nIf graphify saved you time, consider supporting it: https:\u002F\u002Fgithub.com\u002Fsponsors\u002Fsafishamsi\n\nReplace PATH_TO_DIR with the actual absolute path of the directory that was processed.\n\nThen paste these sections from GRAPH_REPORT.md directly into the chat:\n- God Nodes\n- Surprising Connections\n- Suggested Questions\n\nDo NOT paste the full report - just those three sections. Keep it concise.\n\nThen immediately offer to explore. Pick the single most interesting suggested question from the report - the one that crosses the most community boundaries or has the most surprising bridge node - and ask:\n\n> \"The most interesting question this graph can answer: **[question]**. Want me to trace it?\"\n\nIf the user says yes, run `\u002Fgraphify query \"[question]\"` on the graph and walk them through the answer using the graph structure - which nodes connect, which community boundaries get crossed, what the path reveals. Keep going as long as they want to explore. Each answer should end with a natural follow-up (\"this connects to X - want to go deeper?\") so the session feels like navigation, not a one-shot report.\n\nThe graph is the map. Your job after the pipeline is to be the guide.\n\n---\n\n## Interpreter guard for subcommands\n\nBefore running any subcommand below (`--update`, `--cluster-only`, `query`, `path`, `explain`, `add`), check that `.graphify_python` exists. If it's missing (e.g. user deleted `graphify-out\u002F`), re-resolve the interpreter first:\n\n```bash\nif [ ! -f graphify-out\u002F.graphify_python ]; then\n    GRAPHIFY_BIN=$(which graphify 2>\u002Fdev\u002Fnull)\n    if [ -n \"$GRAPHIFY_BIN\" ]; then\n        PYTHON=$(head -1 \"$GRAPHIFY_BIN\" | tr -d '#!')\n        case \"$PYTHON\" in *[!a-zA-Z0-9\u002F_.-]*) PYTHON=\"python3\" ;; esac\n    else\n        PYTHON=\"python3\"\n    fi\n    mkdir -p graphify-out\n    \"$PYTHON\" -c \"import sys; open('graphify-out\u002F.graphify_python', 'w', encoding='utf-8').write(sys.executable)\"\nfi\n```\n\n## For --update and --cluster-only\n\nBoth are non-default subcommands. `--update` re-extracts only new or changed files; `--cluster-only` reruns clustering on the existing graph. See `references\u002Fupdate.md` for both flows.\n\n---\n\n## For \u002Fgraphify query\n\nWhen `graphify-out\u002Fgraph.json` already exists and the user asks a question about the corpus, run the query directly:\n\n```bash\ngraphify query \"\u003Cquestion>\"\n```\n\nAnswer using only what the graph output contains, and quote `source_location` when citing a specific fact. Before traversal, expand the question against the graph's own vocabulary so a wording mismatch does not collapse the answer to noise. For that vocab-expansion step, the `--dfs` \u002F `--budget` modes, `save-result` feedback, and the `\u002Fgraphify path` and `\u002Fgraphify explain` flows, see `references\u002Fquery.md`.\n\n---\n\n## For \u002Fgraphify add and --watch\n\nNeither is part of the default build. When the user runs `\u002Fgraphify add \u003Curl>` to fetch a URL into the corpus, or passes `--watch` to auto-rebuild on file changes, see `references\u002Fadd-watch.md`.\n\n---\n\n## For the commit hook and native CLAUDE.md integration\n\nWhen the user asks to install the post-commit auto-rebuild hook or wire graphify into a project's CLAUDE.md, see `references\u002Fhooks.md`.\n\n---\n\n## Honesty Rules\n\n- Never invent an edge. If unsure, use AMBIGUOUS.\n- Never skip the corpus check warning.\n- Always show token cost in the report.\n- Never hide cohesion scores behind symbols - show the raw number.\n- Never run HTML viz on a graph with more than 5,000 nodes without warning the user.\n","# \u002Fgraphify\n\nTurn any folder of files into a navigable knowledge graph with community detection, an honest audit trail, and three outputs: interactive HTML, GraphRAG-ready JSON, and a plain-language GRAPH_REPORT.md.\n\n## Usage\n\n```\n\u002Fgraphify                                             # full pipeline on current directory → Obsidian vault\n\u002Fgraphify \u003Cpath>                                      # full pipeline on specific path\n\u002Fgraphify https:\u002F\u002Fgithub.com\u002F\u003Cowner>\u002F\u003Crepo>           # clone repo then run full pipeline on it\n\u002Fgraphify https:\u002F\u002Fgithub.com\u002F\u003Cowner>\u002F\u003Crepo> --branch \u003Cbranch>  # clone a specific branch\n\u002Fgraphify \u003Curl1> \u003Curl2> ...                           # clone multiple repos, build each, merge into one cross-repo graph\n\u002Fgraphify \u003Cpath> --mode deep                          # thorough extraction, richer INFERRED edges\n\u002Fgraphify \u003Cpath> --update                             # incremental - re-extract only new\u002Fchanged files\n\u002Fgraphify \u003Cpath> --directed                            # build directed graph (preserves edge direction: source→target)\n\u002Fgraphify \u003Cpath> --whisper-model medium                # use a larger Whisper model for better transcription accuracy\n\u002Fgraphify \u003Cpath> --cluster-only                       # rerun clustering on existing graph\n\u002Fgraphify \u003Cpath> --no-viz                             # skip visualization, just report + JSON\n\u002Fgraphify \u003Cpath> --html                               # (HTML is generated by default - this flag is a no-op)\n\u002Fgraphify \u003Cpath> --svg                                # also export graph.svg (embeds in Notion, GitHub)\n\u002Fgraphify \u003Cpath> --graphml                            # export graph.graphml (Gephi, yEd)\n\u002Fgraphify \u003Cpath> --neo4j                              # generate graphify-out\u002Fcypher.txt for Neo4j\n\u002Fgraphify \u003Cpath> --neo4j-push bolt:\u002F\u002Flocalhost:7687   # push directly to Neo4j\n\u002Fgraphify \u003Cpath> --falkordb                           # generate graphify-out\u002Fcypher.txt for FalkorDB\n\u002Fgraphify \u003Cpath> --falkordb-push falkordb:\u002F\u002Flocalhost:6379   # push directly to FalkorDB\n\u002Fgraphify \u003Cpath> --mcp                                # start MCP stdio server for agent access\n\u002Fgraphify \u003Cpath> --watch                              # watch folder, auto-rebuild on code changes (no LLM needed)\n\u002Fgraphify \u003Cpath> --wiki                               # build agent-crawlable wiki (index.md + one article per community)\n\u002Fgraphify \u003Cpath> --obsidian --obsidian-dir ~\u002Fvaults\u002Fmy-project  # write vault to custom path (e.g. existing vault)\"\n\u002Fgraphify add \u003Curl>                                   # fetch URL, save to .\u002Fraw, update graph\"\n\u002Fgraphify add \u003Curl> --author \"Name\"                   # tag who wrote it\n\u002Fgraphify add \u003Curl> --contributor \"Name\"              # tag who added it to the corpus\n\u002Fgraphify query \"\u003Cquestion>\"                          # BFS traversal - broad context\n\u002Fgraphify query \"\u003Cquestion>\" --dfs                    # DFS - trace a specific path\n\u002Fgraphify query \"\u003Cquestion>\" --budget 1500            # cap answer at N tokens\n\u002Fgraphify path \"AuthModule\" \"Database\"                # shortest path between two concepts\n\u002Fgraphify explain \"SwinTransformer\"                   # plain-language explanation of a node\n```\n\n## What graphify is for\n\nDrop any folder of code, docs, papers, images, or video into graphify and get a queryable knowledge graph. Persistent across sessions, honest audit trail (EXTRACTED\u002FINFERRED\u002FAMBIGUOUS), community detection surfaces cross-document connections you wouldn't think to ask about.\n\n## What You Must Do When Invoked\n\nIf the user invoked `\u002Fgraphify --help` or `\u002Fgraphify -h` (with no other arguments), print the contents of the `## Usage` section above verbatim and stop. Do not run any commands, do not detect files, do not default the path to `.`. Just print the Usage block and return.\n\n**Fast path — existing graph:** Before doing anything else, check whether `graphify-out\u002Fgraph.json` exists. The expected location is `graphify-out\u002Fgraph.json` relative to the **current working directory** (i.e. the project root where you are running commands). If it exists AND the user's request is a natural-language question about the codebase (e.g. \"How does X work?\", \"What calls Y?\", \"Trace the data flow through Z\") and NOT an explicit rebuild command (`--update`, `--cluster-only`, or a bare path\u002FURL that implies fresh extraction): **skip Steps 1–5 entirely and jump straight to `## For \u002Fgraphify query`.** Run `graphify query \"\u003Cquestion>\"` immediately. Do not run detect. Do not check corpus size. Do not ask the user to narrow. The graph is already built — use it.\n\nIf no path was given, use `.` (current directory). Do not ask the user for a path.\n\nIf the path argument starts with `https:\u002F\u002Fgithub.com\u002F` or `http:\u002F\u002Fgithub.com\u002F`, treat it as a GitHub URL - run Step 0 before anything else, then continue with the resolved local path.\n\nFollow these steps in order. Do not skip steps.\n\n### Step 0 - GitHub repos and multi-path merge (only if a URL or several paths)\n\nOnly when the path is one or more `https:\u002F\u002Fgithub.com\u002F...` URLs, or several local subfolders to merge. See `references\u002Fgithub-and-merge.md` for the clone, cross-repo merge, and monorepo flow, then continue with the resolved local path. A plain local path skips this step.\n\n### Step 1 - Ensure graphify is installed\n\n```bash\n# Detect the correct Python interpreter (handles uv tool, pipx, venv, system installs)\nPYTHON=\"\"\nGRAPHIFY_BIN=$(which graphify 2>\u002Fdev\u002Fnull)\n# 1. uv tool installs — most reliable on modern Mac\u002FLinux\nif [ -z \"$PYTHON\" ] && command -v uv >\u002Fdev\u002Fnull 2>&1; then\n    _UV_PY=$(uv tool run graphifyy python -c \"import sys; print(sys.executable)\" 2>\u002Fdev\u002Fnull)\n    if [ -n \"$_UV_PY\" ]; then PYTHON=\"$_UV_PY\"; fi\nfi\n# 2. Read shebang from graphify binary (pipx and direct pip installs)\nif [ -z \"$PYTHON\" ] && [ -n \"$GRAPHIFY_BIN\" ]; then\n    _SHEBANG=$(head -1 \"$GRAPHIFY_BIN\" | tr -d '#!')\n    case \"$_SHEBANG\" in\n        *[!a-zA-Z0-9\u002F_.-]*) ;;\n        *) \"$_SHEBANG\" -c \"import graphify\" 2>\u002Fdev\u002Fnull && PYTHON=\"$_SHEBANG\" ;;\n    esac\nfi\n# 3. Fall back to python3\nif [ -z \"$PYTHON\" ]; then PYTHON=\"python3\"; fi\nif ! \"$PYTHON\" -c \"import graphify\" 2>\u002Fdev\u002Fnull; then\n    if command -v uv >\u002Fdev\u002Fnull 2>&1; then\n        uv tool install --upgrade graphifyy -q 2>&1 | tail -3\n        _UV_PY=$(uv tool run graphifyy python -c \"import sys; print(sys.executable)\" 2>\u002Fdev\u002Fnull)\n        if [ -n \"$_UV_PY\" ]; then PYTHON=\"$_UV_PY\"; fi\n    else\n        \"$PYTHON\" -m pip install graphifyy -q 2>\u002Fdev\u002Fnull \\\n          || \"$PYTHON\" -m pip install graphifyy -q --break-system-packages 2>&1 | tail -3\n    fi\nfi\n# Write interpreter path for all subsequent steps (persists across invocations)\nmkdir -p graphify-out\n\"$PYTHON\" -c \"import sys; open('graphify-out\u002F.graphify_python', 'w', encoding='utf-8').write(sys.executable)\"\n# Save scan root so `graphify update` (no args) knows where to look next time\necho \"$(cd INPUT_PATH && pwd)\" > graphify-out\u002F.graphify_root\n```\n\nIf the import succeeds, print nothing and move straight to Step 2.\n\n**In every subsequent bash block, replace `python3` with `$(cat graphify-out\u002F.graphify_python)` to use the correct interpreter.**\n\n### Step 2 - Detect files\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.detect import detect\nfrom pathlib import Path\nresult = detect(Path('INPUT_PATH'))\nprint(json.dumps(result, ensure_ascii=False))\n\" > graphify-out\u002F.graphify_detect.json\n```\n\nReplace INPUT_PATH with the actual path the user provided. Do NOT cat or print the JSON - read it silently and present a clean summary instead:\n\n```\nCorpus: X files · ~Y words\n  code:     N files (.py .ts .go ...)\n  docs:     N files (.md .txt ...)\n  papers:   N files (.pdf ...)\n  images:   N files\n  video:    N files (.mp4 .mp3 ...)\n```\n\nOmit any category with 0 files from the summary.\n\nThen act on it:\n- If `total_files` is 0: stop with \"No supported files found in [path].\"\n- If `skipped_sensitive` is non-empty: mention file count skipped, not the file names.\n- If `total_words` > 2,000,000 OR `total_files` > 500: show the warning. Then compute the top 5 first-level subdirectories by file count:\n  - Read `scan_root` from the detect JSON (always an absolute path to the resolved INPUT_PATH).\n  - Concatenate all file lists across all types (`code`, `document`, `paper`, `image`, `video`).\n  - Filter out any path that starts with `scan_root + \"\u002Fgraphify-out\u002F\"` to exclude converted sidecars.\n  - For each file, strip the `scan_root` prefix and take the first path component. Files directly in `scan_root` with no subdirectory count as `(root)`.\n  - If all files are in `(root)` with no subdirectories, do not ask to narrow — no subfolders exist. Instead suggest `--no-cluster` to skip the expensive clustering step and proceed.\n  - Otherwise rank by count, show the top 5 with file counts, then ask which subfolder to run on. Wait for the user's answer before proceeding.\n- Otherwise: proceed directly to Step 2.5 if video files were detected, or Step 3 if not.\n\n### Step 2.5 - Video and audio (only if video files detected)\n\nSkip this step entirely if `detect` returned zero `video` files. When the corpus has video or audio, see `references\u002Ftranscribe.md` to transcribe them to text first, then treat the transcripts as doc files in Step 3.\n\n### Step 3 - Extract entities and relationships\n\n**Before starting:** note whether `--mode deep` was given. You must pass `DEEP_MODE=true` to every subagent in Step B2 if it was. Track this from the original invocation - do not lose it.\n\nThis step has two parts: **structural extraction** (deterministic, free) and **semantic extraction** (LLM, costs tokens).\n\n**Before dispatching subagents:** check whether `GEMINI_API_KEY` or `GOOGLE_API_KEY` is set. If neither is set, print this one-liner to the user:\n> Tip: set `GEMINI_API_KEY` or `GOOGLE_API_KEY` to use Gemini for semantic extraction (`pip install 'graphifyy[gemini]'`).\n\nPrint it once, then continue. If `GEMINI_API_KEY` or `GOOGLE_API_KEY` IS set, use `graphify.llm.extract_corpus_parallel(files, backend=\"gemini\")` for semantic extraction instead of dispatching Claude subagents. The default Gemini model is `gemini-3-flash-preview`; set `GRAPHIFY_GEMINI_MODEL` or pass `--model` in headless CLI flows to override it.\n\n> **No other API keys are read.** If `GEMINI_API_KEY`\u002F`GOOGLE_API_KEY` are unset, fall straight through to Claude Code subagent dispatch (Part B below) — the host session itself is the LLM. graphify does **not** read `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, or any other provider key from the environment. If a host agent prompts the user for `ANTHROPIC_API_KEY` to run extraction, that prompt is a misread of this skill — ignore it and dispatch subagents as written.\n\n**Run Part A (AST) and Part B (semantic) in parallel. Dispatch all semantic subagents AND start AST extraction in the same message. Both can run simultaneously since they operate on different file types. Merge results in Part C as before.**\n\nNote: Parallelizing AST + semantic saves 5-15s on large corpora. AST is deterministic and fast; start it while subagents are processing docs\u002Fpapers.\n\n#### Part A - Structural extraction for code files\n\nFor any code files detected, run AST extraction in parallel with Part B subagents:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.extract import collect_files, extract\nfrom pathlib import Path\nimport json\n\ncode_files = []\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\nfor f in detect.get('files', {}).get('code', []):\n    code_files.extend(collect_files(Path(f)) if Path(f).is_dir() else [Path(f)])\n\nif code_files:\n    result = extract(code_files, cache_root=Path('.'))\n    Path('graphify-out\u002F.graphify_ast.json').write_text(json.dumps(result, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\n    print(f'AST: {len(result[\\\"nodes\\\"])} nodes, {len(result[\\\"edges\\\"])} edges')\nelse:\n    Path('graphify-out\u002F.graphify_ast.json').write_text(json.dumps({'nodes':[],'edges':[],'input_tokens':0,'output_tokens':0}, ensure_ascii=False), encoding=\\\"utf-8\\\")\n    print('No code files - skipping AST extraction')\n\"\n```\n\n#### Part B - Semantic extraction (parallel subagents)\n\n**Fast path:** If detection found zero docs, papers, and images (code-only corpus), skip Part B entirely and go straight to Part C. AST handles code - there is nothing for semantic subagents to do.\n\n**MANDATORY: You MUST use the Agent tool here. Reading files yourself one-by-one is forbidden - it is 5-10x slower. If you do not use the Agent tool you are doing this wrong.**\n\nBefore dispatching subagents, print a timing estimate:\n- Load `total_words` and file counts from `graphify-out\u002F.graphify_detect.json`\n- Estimate agents needed: `ceil(uncached_non_code_files \u002F 22)` (chunk size is 20-25)\n- Estimate time: ~45s per agent batch (they run in parallel, so total ≈ 45s × ceil(agents\u002Fparallel_limit))\n- Print: \"Semantic extraction: ~N files → X agents, estimated ~Ys\"\n\n**Step B0 - Check extraction cache first**\n\nBefore dispatching any subagents, check which files already have cached extraction results:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.cache import check_semantic_cache\nfrom pathlib import Path\n\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\nall_files = [f for files in detect['files'].values() for f in files]\n\ncached_nodes, cached_edges, cached_hyperedges, uncached = check_semantic_cache(all_files)\n\nif cached_nodes or cached_edges or cached_hyperedges:\n    Path('graphify-out\u002F.graphify_cached.json').write_text(json.dumps({'nodes': cached_nodes, 'edges': cached_edges, 'hyperedges': cached_hyperedges}, ensure_ascii=False), encoding=\\\"utf-8\\\")\nPath('graphify-out\u002F.graphify_uncached.txt').write_text('\\n'.join(uncached), encoding=\\\"utf-8\\\")\nprint(f'Cache: {len(all_files)-len(uncached)} files hit, {len(uncached)} files need extraction')\n\"\n```\n\nOnly dispatch subagents for files listed in `graphify-out\u002F.graphify_uncached.txt`. If all files are cached, skip to Part C directly.\n\n**Step B1 - Split into chunks**\n\nLoad files from `graphify-out\u002F.graphify_uncached.txt`. Split into chunks of 20-25 files each. Each image gets its own chunk (vision needs separate context). When splitting, group files from the same directory together so related artifacts land in the same chunk and cross-file relationships are more likely to be extracted.\n\n**Step B2 - Dispatch ALL subagents in a single message**\n\nCall the Agent tool multiple times IN THE SAME RESPONSE - one call per chunk. This is the only way they run in parallel. If you make one Agent call, wait, then make another, you are doing it sequentially and defeating the purpose.\n\n**IMPORTANT - subagent type:** Always use `subagent_type=\"general-purpose\"`. Do NOT use `Explore` - it is read-only and cannot write chunk files to disk, which silently drops extraction results. General-purpose has Write and Bash access which the subagent needs.\n\nConcrete example for 3 chunks:\n```\n[Agent tool call 1: files 1-15, subagent_type=\"general-purpose\"]\n[Agent tool call 2: files 16-30, subagent_type=\"general-purpose\"]\n[Agent tool call 3: files 31-45, subagent_type=\"general-purpose\"]\n```\nAll three in one message. Not three separate messages.\n\nEach subagent receives this exact prompt (substitute FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, DEEP_MODE, and CHUNK_PATH).\n\nCHUNK_PATH must be an **absolute** path — derive it before dispatching:\n```bash\nPROJECT_ROOT=$(cat graphify-out\u002F.graphify_root)\n# Then for chunk N: CHUNK_PATH=\"${PROJECT_ROOT}\u002Fgraphify-out\u002F.graphify_chunk_0N.json\"\n```\n\nSubagent prompt template:\n\nSee `references\u002Fextraction-spec.md` for the exact subagent prompt (JSON schema, node-ID rules, confidence rubric, frontmatter, hyperedge, and vision rules). Load it only here, only when at least one chunk holds a doc, paper, or image; a pure-code corpus has skipped Part B and never reads it. Pass each subagent that prompt verbatim with FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, DEEP_MODE, and CHUNK_PATH substituted, and have it write the result to CHUNK_PATH.\n\n**Step B3 - Collect, cache, and merge**\n\nWait for all subagents. For each result:\n- Check that `graphify-out\u002F.graphify_chunk_NN.json` exists on disk — this is the success signal\n- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache\n- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: \"chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent.\" Do not silently skip.\n- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort\n\nIf more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type=\"general-purpose\"` is used.\n\nMerge all chunk files into `.graphify_semantic_new.json`. **After each Agent call completes, read the real token counts from the Agent tool result's `usage` field and write them back into the chunk JSON before merging** — the chunk JSON itself always has placeholder zeros. Then run:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json, glob\nfrom pathlib import Path\n\nchunks = sorted(glob.glob('graphify-out\u002F.graphify_chunk_*.json'))\nall_nodes, all_edges, all_hyperedges = [], [], []\ntotal_in, total_out = 0, 0\nfor c in chunks:\n    d = json.loads(Path(c).read_text(encoding=\\\"utf-8\\\"))\n    all_nodes += d.get('nodes', [])\n    all_edges += d.get('edges', [])\n    all_hyperedges += d.get('hyperedges', [])\n    total_in += d.get('input_tokens', 0)\n    total_out += d.get('output_tokens', 0)\nPath('graphify-out\u002F.graphify_semantic_new.json').write_text(json.dumps({\n    'nodes': all_nodes, 'edges': all_edges, 'hyperedges': all_hyperedges,\n    'input_tokens': total_in, 'output_tokens': total_out,\n}, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\nprint(f'Merged {len(chunks)} chunks: {total_in:,} in \u002F {total_out:,} out tokens')\n\"\n```\n\nSave new results to cache:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom graphify.cache import save_semantic_cache\nfrom pathlib import Path\n\nnew = json.loads(Path('graphify-out\u002F.graphify_semantic_new.json').read_text(encoding=\\\"utf-8\\\")) if Path('graphify-out\u002F.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\nsaved = save_semantic_cache(new.get('nodes', []), new.get('edges', []), new.get('hyperedges', []))\nprint(f'Cached {saved} files')\n\"\n```\n\nMerge cached + new results into `graphify-out\u002F.graphify_semantic.json`:\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom pathlib import Path\n\ncached = json.loads(Path('graphify-out\u002F.graphify_cached.json').read_text(encoding=\\\"utf-8\\\")) if Path('graphify-out\u002F.graphify_cached.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\nnew = json.loads(Path('graphify-out\u002F.graphify_semantic_new.json').read_text(encoding=\\\"utf-8\\\")) if Path('graphify-out\u002F.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}\n\nall_nodes = cached['nodes'] + new.get('nodes', [])\nall_edges = cached['edges'] + new.get('edges', [])\nall_hyperedges = cached.get('hyperedges', []) + new.get('hyperedges', [])\nseen = set()\ndeduped = []\nfor n in all_nodes:\n    if n['id'] not in seen:\n        seen.add(n['id'])\n        deduped.append(n)\n\nmerged = {\n    'nodes': deduped,\n    'edges': all_edges,\n    'hyperedges': all_hyperedges,\n    'input_tokens': new.get('input_tokens', 0),\n    'output_tokens': new.get('output_tokens', 0),\n}\nPath('graphify-out\u002F.graphify_semantic.json').write_text(json.dumps(merged, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\nprint(f'Extraction complete - {len(deduped)} nodes, {len(all_edges)} edges ({len(cached[\\\"nodes\\\"])} from cache, {len(new.get(\\\"nodes\\\",[]))} new)')\n\"\n```\nClean up temp files: `rm -f graphify-out\u002F.graphify_cached.json graphify-out\u002F.graphify_uncached.txt graphify-out\u002F.graphify_semantic_new.json`\n\n#### Part C - Merge AST + semantic into final extraction\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom pathlib import Path\n\nast = json.loads(Path('graphify-out\u002F.graphify_ast.json').read_text(encoding=\\\"utf-8\\\"))\nsem = json.loads(Path('graphify-out\u002F.graphify_semantic.json').read_text(encoding=\\\"utf-8\\\"))\n\n# Merge: AST nodes first, semantic nodes deduplicated by id\nseen = {n['id'] for n in ast['nodes']}\nmerged_nodes = list(ast['nodes'])\nfor n in sem['nodes']:\n    if n['id'] not in seen:\n        merged_nodes.append(n)\n        seen.add(n['id'])\n\nmerged_edges = ast['edges'] + sem['edges']\nmerged_hyperedges = sem.get('hyperedges', [])\nmerged = {\n    'nodes': merged_nodes,\n    'edges': merged_edges,\n    'hyperedges': merged_hyperedges,\n    'input_tokens': sem.get('input_tokens', 0),\n    'output_tokens': sem.get('output_tokens', 0),\n}\nPath('graphify-out\u002F.graphify_extract.json').write_text(json.dumps(merged, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\ntotal = len(merged_nodes)\nedges = len(merged_edges)\nprint(f'Merged: {total} nodes, {edges} edges ({len(ast[\\\"nodes\\\"])} AST + {len(sem[\\\"nodes\\\"])} semantic)')\n\"\n```\n\n### Step 4 - Build graph, cluster, analyze, generate outputs\n\n**Before starting:** note whether `--directed` was given. If so, pass `directed=True` to `build_from_json()` in the code block below. This builds a `DiGraph` that preserves edge direction (source→target) instead of the default undirected `Graph`.\n\n```bash\nmkdir -p graphify-out\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.cluster import cluster, score_all\nfrom graphify.analyze import god_nodes, surprising_connections, suggest_questions\nfrom graphify.report import generate\nfrom graphify.export import to_json\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text(encoding=\\\"utf-8\\\"))\ndetection  = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\n\nG = build_from_json(extraction)\ncommunities = cluster(G)\ncohesion = score_all(G, communities)\ntokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}\ngods = god_nodes(G)\nsurprises = surprising_connections(G, communities)\nlabels = {cid: 'Community ' + str(cid) for cid in communities}\n# Placeholder questions - regenerated with real labels in Step 5\nquestions = suggest_questions(G, communities, labels)\n\nreport = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, '.', suggested_questions=questions)\nPath('graphify-out\u002FGRAPH_REPORT.md').write_text(report, encoding=\\\"utf-8\\\")\nto_json(G, communities, 'graphify-out\u002Fgraph.json')\n\nanalysis = {\n    'communities': {str(k): v for k, v in communities.items()},\n    'cohesion': {str(k): v for k, v in cohesion.items()},\n    'gods': gods,\n    'surprises': surprises,\n    'questions': questions,\n}\nPath('graphify-out\u002F.graphify_analysis.json').write_text(json.dumps(analysis, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\nif G.number_of_nodes() == 0:\n    print('ERROR: Graph is empty - extraction produced no nodes.')\n    print('Possible causes: all files were skipped, binary-only corpus, or extraction failed.')\n    raise SystemExit(1)\nprint(f'Graph: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges, {len(communities)} communities')\n\"\n```\n\nIf this step prints `ERROR: Graph is empty`, stop and tell the user what happened - do not proceed to labeling or visualization.\n\nReplace INPUT_PATH with the actual path.\n\n### Step 5 - Label communities\n\nRead `graphify-out\u002F.graphify_analysis.json`. For each community key, look at its node labels and write a 2-5 word plain-language name (e.g. \"Attention Mechanism\", \"Training Pipeline\", \"Data Loading\").\n\nThen regenerate the report and save the labels for the visualizer:\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport sys, json\nfrom graphify.build import build_from_json\nfrom graphify.cluster import score_all\nfrom graphify.analyze import god_nodes, surprising_connections, suggest_questions\nfrom graphify.report import generate\nfrom pathlib import Path\n\nextraction = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text(encoding=\\\"utf-8\\\"))\ndetection  = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\nanalysis   = json.loads(Path('graphify-out\u002F.graphify_analysis.json').read_text(encoding=\\\"utf-8\\\"))\n\nG = build_from_json(extraction)\ncommunities = {int(k): v for k, v in analysis['communities'].items()}\ncohesion = {int(k): v for k, v in analysis['cohesion'].items()}\ntokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}\n\n# LABELS - replace these with the names you chose above\nlabels = LABELS_DICT\n\n# Regenerate questions with real community labels (labels affect question phrasing)\nquestions = suggest_questions(G, communities, labels)\n\nreport = generate(G, communities, cohesion, labels, analysis['gods'], analysis['surprises'], detection, tokens, '.', suggested_questions=questions)\nPath('graphify-out\u002FGRAPH_REPORT.md').write_text(report, encoding=\\\"utf-8\\\")\nPath('graphify-out\u002F.graphify_labels.json').write_text(json.dumps({str(k): v for k, v in labels.items()}, ensure_ascii=False), encoding=\\\"utf-8\\\")\nprint('Report updated with community labels')\n\"\n```\n\nReplace `LABELS_DICT` with the actual dict you constructed (e.g. `{0: \"Attention Mechanism\", 1: \"Training Pipeline\"}`).\nReplace INPUT_PATH with the actual path.\n\n### Step 6 - Generate Obsidian vault (opt-in) + HTML\n\n**Generate HTML always** (unless `--no-viz`). **Obsidian vault only if `--obsidian` was explicitly given** — skip it otherwise, it generates one file per node.\n\nIf `--obsidian` was given:\n\n- If `--obsidian-dir \u003Cpath>` was also given, pass it via `--dir`. Otherwise defaults to `graphify-out\u002Fobsidian`.\n\n```bash\ngraphify export obsidian\n# or with custom dir: graphify export obsidian --dir ~\u002Fvaults\u002Fmy-project\n```\n\nGenerate the HTML graph (always, unless `--no-viz`):\n\n```bash\ngraphify export html  # auto-aggregates to community view if graph > 5000 nodes\n# or: graphify export html --no-viz\n```\n\n### Steps 6b-8 - Wiki, Neo4j, FalkorDB, SVG, GraphML, MCP, benchmark (only on their flags)\n\nThese run only when their flag is present (`--wiki`, `--neo4j`\u002F`--neo4j-push`, `--falkordb`\u002F`--falkordb-push`, `--svg`, `--graphml`, `--mcp`) or, for the token-reduction benchmark, when `total_words` exceeds 5,000. A default run with no export flags skips all of them. See `references\u002Fexports.md` for each one. Run any `--wiki` export before Step 9 cleanup so `.graphify_labels.json` is still available.\n\n---\n\n### Step 9 - Save manifest, update cost tracker, clean up, and report\n\n```bash\n$(cat graphify-out\u002F.graphify_python) -c \"\nimport json\nfrom pathlib import Path\nfrom datetime import datetime, timezone\nfrom graphify.detect import save_manifest\n\n# Save manifest for --update\ndetect = json.loads(Path('graphify-out\u002F.graphify_detect.json').read_text(encoding=\\\"utf-8\\\"))\n# In --update mode, 'all_files' carries the full corpus; 'files' is the changed\n# subset. Full-rebuild mode populates only 'files', so the fallback handles that.\nsave_manifest(detect.get('all_files') or detect['files'])\n\n# Update cumulative cost tracker\nextract = json.loads(Path('graphify-out\u002F.graphify_extract.json').read_text(encoding=\\\"utf-8\\\"))\ninput_tok = extract.get('input_tokens', 0)\noutput_tok = extract.get('output_tokens', 0)\n\ncost_path = Path('graphify-out\u002Fcost.json')\nif cost_path.exists():\n    cost = json.loads(cost_path.read_text(encoding=\\\"utf-8\\\"))\nelse:\n    cost = {'runs': [], 'total_input_tokens': 0, 'total_output_tokens': 0}\n\ncost['runs'].append({\n    'date': datetime.now(timezone.utc).isoformat(),\n    'input_tokens': input_tok,\n    'output_tokens': output_tok,\n    'files': detect.get('total_files', 0),\n})\ncost['total_input_tokens'] += input_tok\ncost['total_output_tokens'] += output_tok\ncost_path.write_text(json.dumps(cost, indent=2, ensure_ascii=False), encoding=\\\"utf-8\\\")\n\nprint(f'This run: {input_tok:,} input tokens, {output_tok:,} output tokens')\nprint(f'All time: {cost[\\\"total_input_tokens\\\"]:,} input, {cost[\\\"total_output_tokens\\\"]:,} output ({len(cost[\\\"runs\\\"])} runs)')\n\"\nrm -f graphify-out\u002F.graphify_detect.json graphify-out\u002F.graphify_extract.json graphify-out\u002F.graphify_ast.json graphify-out\u002F.graphify_semantic.json graphify-out\u002F.graphify_analysis.json\nfind graphify-out -maxdepth 1 -name '.graphify_chunk_*.json' -delete 2>\u002Fdev\u002Fnull\nrm -f graphify-out\u002F.needs_update 2>\u002Fdev\u002Fnull || true\n```\n\nTell the user (omit the obsidian line unless --obsidian was given):\n```\nGraph complete. Outputs in PATH_TO_DIR\u002Fgraphify-out\u002F\n\n  graph.html            - interactive graph, open in browser\n  GRAPH_REPORT.md       - audit report\n  graph.json            - raw graph data\n  obsidian\u002F             - Obsidian vault (only if --obsidian was given)\n```\n\nIf graphify saved you time, consider supporting it: https:\u002F\u002Fgithub.com\u002Fsponsors\u002Fsafishamsi\n\nReplace PATH_TO_DIR with the actual absolute path of the directory that was processed.\n\nThen paste these sections from GRAPH_REPORT.md directly into the chat:\n- God Nodes\n- Surprising Connections\n- Suggested Questions\n\nDo NOT paste the full report - just those three sections. Keep it concise.\n\nThen immediately offer to explore. Pick the single most interesting suggested question from the report - the one that crosses the most community boundaries or has the most surprising bridge node - and ask:\n\n> \"The most interesting question this graph can answer: **[question]**. Want me to trace it?\"\n\nIf the user says yes, run `\u002Fgraphify query \"[question]\"` on the graph and walk them through the answer using the graph structure - which nodes connect, which community boundaries get crossed, what the path reveals. Keep going as long as they want to explore. Each answer should end with a natural follow-up (\"this connects to X - want to go deeper?\") so the session feels like navigation, not a one-shot report.\n\nThe graph is the map. Your job after the pipeline is to be the guide.\n\n---\n\n## Interpreter guard for subcommands\n\nBefore running any subcommand below (`--update`, `--cluster-only`, `query`, `path`, `explain`, `add`), check that `.graphify_python` exists. If it's missing (e.g. user deleted `graphify-out\u002F`), re-resolve the interpreter first:\n\n```bash\nif [ ! -f graphify-out\u002F.graphify_python ]; then\n    GRAPHIFY_BIN=$(which graphify 2>\u002Fdev\u002Fnull)\n    if [ -n \"$GRAPHIFY_BIN\" ]; then\n        PYTHON=$(head -1 \"$GRAPHIFY_BIN\" | tr -d '#!')\n        case \"$PYTHON\" in *[!a-zA-Z0-9\u002F_.-]*) PYTHON=\"python3\" ;; esac\n    else\n        PYTHON=\"python3\"\n    fi\n    mkdir -p graphify-out\n    \"$PYTHON\" -c \"import sys; open('graphify-out\u002F.graphify_python', 'w', encoding='utf-8').write(sys.executable)\"\nfi\n```\n\n## For --update and --cluster-only\n\nBoth are non-default subcommands. `--update` re-extracts only new or changed files; `--cluster-only` reruns clustering on the existing graph. See `references\u002Fupdate.md` for both flows.\n\n---\n\n## For \u002Fgraphify query\n\nWhen `graphify-out\u002Fgraph.json` already exists and the user asks a question about the corpus, run the query directly:\n\n```bash\ngraphify query \"\u003Cquestion>\"\n```\n\nAnswer using only what the graph output contains, and quote `source_location` when citing a specific fact. Before traversal, expand the question against the graph's own vocabulary so a wording mismatch does not collapse the answer to noise. For that vocab-expansion step, the `--dfs` \u002F `--budget` modes, `save-result` feedback, and the `\u002Fgraphify path` and `\u002Fgraphify explain` flows, see `references\u002Fquery.md`.\n\n---\n\n## For \u002Fgraphify add and --watch\n\nNeither is part of the default build. When the user runs `\u002Fgraphify add \u003Curl>` to fetch a URL into the corpus, or passes `--watch` to auto-rebuild on file changes, see `references\u002Fadd-watch.md`.\n\n---\n\n## For the commit hook and native CLAUDE.md integration\n\nWhen the user asks to install the post-commit auto-rebuild hook or wire graphify into a project's CLAUDE.md, see `references\u002Fhooks.md`.\n\n---\n\n## Honesty Rules\n\n- Never invent an edge. If unsure, use AMBIGUOUS.\n- Never skip the corpus check warning.\n- Always show token cost in the report.\n- Never hide cohesion scores behind symbols - show the raw number.\n- Never run HTML viz on a graph with more than 5,000 nodes without warning the user.\n",{"name":5,"draft":24,"triggers":25,"description":7},true,{"files":26},"test -d graphify-out","main","7da8c355f6e99dcb88d8bb9f6ff27b3cb35bae47","_drafts\u002Fgraphify-protocol",0,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills","https:\u002F\u002Fgithub.com\u002Fkalaverin","2026-11-15 01:37:57",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":24},[36,39,42],{"tool":37,"command":38},"npx","npx skills add kalaverin\u002Fskills --skill graphify-protocol",{"tool":40,"command":41},"bunx","bunx skills add kalaverin\u002Fskills --skill graphify-protocol",{"tool":43,"command":44},"pnpm","pnpm dlx skills add kalaverin\u002Fskills --skill graphify-protocol","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002FSKILL.md",[47,53,59,63,67,71,75,79,83,87],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},".graphify_version","OTHER","其他",6,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002F.graphify_version",{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},"README.md","REFERENCE","参考文档",5915,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002FREADME.md",{"path":60,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":61,"sourceHtmlUrl":62},"references\u002Fadd-watch.md",2457,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002Freferences\u002Fadd-watch.md",{"path":64,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Fexports.md",3073,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002Freferences\u002Fexports.md",{"path":68,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":69,"sourceHtmlUrl":70},"references\u002Fextraction-spec.md",7161,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002Freferences\u002Fextraction-spec.md",{"path":72,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fgithub-and-merge.md",2177,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002Freferences\u002Fgithub-and-merge.md",{"path":76,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fhooks.md",1267,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002Freferences\u002Fhooks.md",{"path":80,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fquery.md",5166,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002Freferences\u002Fquery.md",{"path":84,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Ftranscribe.md",2652,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002Freferences\u002Ftranscribe.md",{"path":88,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fupdate.md",7518,"https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002F_drafts\u002Fgraphify-protocol\u002Freferences\u002Fupdate.md",[92,99,106,113,120,127],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M786R9KK7RP1J8EB7X9TC9KR","todo-protocol","Mandatory protocol for using the SetTodoList tool. Governs when to create a todo list, how to update it without violating immutability rules, how to synchronize item status after every tool call, and the forbidden mutations. Always active.","https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002Ftodo-protocol\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":19},"01M786QZTC43FBK3A251NTY62Y","subagents-protocol","Mandatory protocol for delegating work to built-in subagents (coder, explore, plan), also called our bots by users. Always active. Owns the context-hygiene delegation test (material vs answer, cost balance, warm-instance reuse), launch parameters (mandatory explicit `model`), the single-source model-selection table, answer budgets, degradation handling, the launch checklist, and the role library for delegated review\u002Faudit with intent routing (`references\u002Froles.md`).","https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002Fsubagents-protocol\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":19},"01M786QSXFDM550NCC4PQXN26X","serena-protocol","MANDATORY skill for Serena (MCP) memory, knowledge base, and symbolic code exploration operations. Use whenever the agent needs to: read or write Serena memories, mutate or persist memory, explore code via symbolic MCP tools, resolve contradictions in stored knowledge, or follow memory metadata, naming, and routing conventions.","https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002Fserena-protocol\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":19},"01M786QMXA58XD5DJZ2AZER5ZP","read-for-comments","Mandatory local standards library and archive. Before fetching any standard from the internet, the agent MUST check the Serena `standard\u002F` archive and this skill's `references\u002F` seed; after ANY standard-body download, the agent MUST archive it per the event-bound Archival Rule. Governs standard lookup, fetch, archival, and the family and full-body rules.","https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002Fread-for-comments\u002FSKILL.md",[],[],{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":19},"01M786QD59A2R2JK1NJTK7MADP","python-lang","MANDATORY skill for Python code. Use when writing, editing, refactoring, or reviewing Python files, modules, packages, classes, functions, type annotations, imports, exceptions, comprehensions, decorators, or docstrings. Enforces Google Python Style Guide and a mandatory, unconditional Ruff format+check pipeline scoped strictly to the agent's own changes.","https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002Fpython-lang\u002FSKILL.md",[],[],{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":19},"01M786Q683RHDC93NWABY7XKQN","preflight-checklist","Mandatory session-initialization closer and Startup Gate audit. Always loaded. Runs EXACTLY ONCE at session start, after all skill loading completes: verifies Startup Gate completion with evidence (mirror sync, forced import, discovery, activation, memory priming, MCP declaration, think block), runs dynamic session checks derived from the active skill set (mode states, delegation readiness), and reports a compact evidence-backed verdict table to the user before the first task output. Any FAIL is fixed before proceeding.","https:\u002F\u002Fgithub.com\u002Fkalaverin\u002Fskills\u002Fblob\u002Fmain\u002Fpreflight-checklist\u002FSKILL.md",[],[]]