代码库知识图谱构建
graphify
构建/查询代码库的可导航知识图谱。在接手不熟悉的代码库、回答跨模块的“X 与 Y 如何关联”一类问题,或在重构前追踪依赖关系时使用。
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- graphify
- trigger
- /graphify
- description
- Build/query a navigable knowledge graph of a codebase. Use when onboarding to an unfamiliar codebase, answering cross-module how-does-X-relate-to-Y, or tracing dependencies before a refactor.
02 资源文件 3
- 参考文档reference/build-pipeline.md36.4 KB
- 参考文档reference/query-and-navigate.md8.8 KB
- 参考文档reference/update-and-maintain.md9.7 KB
03 SKILL.md 正文
/graphify
Turn 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.
Three things it does that Claude alone cannot:
- Persistent graph — relationships are stored in
graphify-out/graph.jsonand survive across sessions. Ask questions weeks later without re-reading everything. - Honest audit trail — every edge is tagged EXTRACTED, INFERRED, or AMBIGUOUS. You know what was found vs invented.
- Cross-document surprise — community detection finds connections between concepts in different files you would never think to ask about directly.
Command surface
/graphify [<path>|<github-url> ...] # build a graph (default path: current directory)
/graphify query "<question>" # traverse the graph for an answer (--dfs, --budget N)
/graphify path "A" "B" # shortest path between two concepts
/graphify explain "Concept" # plain-language explanation of one node
/graphify add <url> # fetch a URL into ./raw, then update the graph
Build flags (combine freely): --mode deep, --update, --directed, --cluster-only, --no-viz,
--svg, --graphml, --neo4j[-push <uri>], --mcp, --watch, --wiki, --obsidian[-dir <path>],
--branch <b>, --whisper-model <name>. Multiple URLs build each repo and merge into one cross-repo
graph.
Route by command
Pick the matching reference, then follow its steps in order. Do not skip steps.
- Building a graph (any
/graphify <path>or<github-url>, with or without build flags) →reference/build-pipeline.md(Steps 0–9: clone, install, detect, transcribe, extract, build, cluster, label, export, report). - Querying an existing graph (
query,path,explain) →reference/query-and-navigate.md. - Keeping a graph current (
--update,--cluster-only,add,--watch, git hook, CLAUDE.md integration) →reference/update-and-maintain.md.
The interpreter resolved in build Step 1 is written to graphify-out/.graphify_python; every later
bash block uses $(cat graphify-out/.graphify_python) instead of python3. Query and maintenance
subcommands re-resolve it first if graphify-out/ was deleted (guard in the reference files).
Honesty Rules (apply to every branch)
- Never invent an edge. If unsure, use AMBIGUOUS.
- Never skip the corpus-size check warning (Step 2: >2M words or >200 files).
- Always show token cost in the report.
- Never hide cohesion scores behind symbols — show the raw number.
- Never run HTML viz on a graph with more than 5,000 nodes without warning the user.
04 同仓库更多 Skills
技术文档写作规范
writing-standards
遵循 AS v2 技术写作规范(清晰、简洁、主动语态、Python/Django 惯例)。适用于撰写 README、文档字符串(PEP 257)、提交信息、PR 描述、错误信息或任何技术文档。
成果验证关卡
verification-gate
在宣称成功之前先进行验证。适用于准备表示某功能可用/已完成、实现功能后、修复缺陷后,或推送代码前——先运行验证命令并确认输出。
测试驱动开发
test-driven-development
在 AS v2(pytest + Django/DRF)中先编写失败的测试,再进行实现。适用于实现功能或修复缺陷时,在编写任何生产代码之前使用。
子智能体编排开发
subagent-development
在 AS v2 中编排子智能体——将任务拆解为相互独立的领域,并行处理并进行两阶段审查。适用于委派探索、实现或跨文件验证,以加快工作进度并节省主上下文。
自动化安全扫描
security-scan
为 AS v2 提供自动化安全扫描。在提交前或审查变更中的漏洞时使用。执行依赖审计(pip-audit、npm audit)、密钥检测(grep 模式)和代码模式扫描(SQL 注入、XSS、eval、pickle、硬编码密钥)。与项目 hooks 系统集成。
交接文档恢复工作
resume-handoff
从保存的交接文档恢复工作,在继续之前先根据当前代码库验证其状态。适用于上下文清空后或在新会话中(通过路径、会话名称或 GitHub issue)从保存的交接文档恢复工作。