shmakk 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/README.md +16 -1
  2. package/package.json +6 -3
  3. package/scripts/import-skills.js +536 -0
  4. package/scripts/install-skills.js +64 -0
  5. package/skills/ai-elements.md +482 -0
  6. package/skills/architecture.md +151 -0
  7. package/skills/backend-adapter-aws-lambda.md +204 -0
  8. package/skills/backend-adapter-express.md +177 -0
  9. package/skills/backend-adapter-fastify.md +222 -0
  10. package/skills/backend-adapter-fetch.md +200 -0
  11. package/skills/backend-api-docs.md +22 -0
  12. package/skills/backend-aspire.md +232 -0
  13. package/skills/backend-aspnet-core.md +62 -0
  14. package/skills/backend-build-chatgpt-app.md +321 -0
  15. package/skills/backend-build-mcp-app.md +393 -0
  16. package/skills/backend-build-mcp-server.md +222 -0
  17. package/skills/backend-build-mcpb.md +200 -0
  18. package/skills/backend-building-ai-agent-on-cloudflare.md +401 -0
  19. package/skills/backend-caching.md +206 -0
  20. package/skills/backend-chatgpt-app-submission.md +157 -0
  21. package/skills/backend-chatgpt-apps.md +321 -0
  22. package/skills/backend-client-setup.md +318 -0
  23. package/skills/backend-containerize-aspnet-framework.md +455 -0
  24. package/skills/backend-create-spring-boot-java-project.md +164 -0
  25. package/skills/backend-create-spring-boot-kotlin-project.md +148 -0
  26. package/skills/backend-csharp-async.md +50 -0
  27. package/skills/backend-csharp-docs.md +63 -0
  28. package/skills/backend-csharp-mcp-server-generator.md +60 -0
  29. package/skills/backend-dotenv.md +201 -0
  30. package/skills/backend-dotenvx.md +119 -0
  31. package/skills/backend-env-vars.md +259 -0
  32. package/skills/backend-error-handling.md +254 -0
  33. package/skills/backend-fastapi.md +437 -0
  34. package/skills/backend-go-mcp-server-generator.md +335 -0
  35. package/skills/backend-java-mcp-server-generator.md +757 -0
  36. package/skills/backend-kotlin-mcp-server-generator.md +450 -0
  37. package/skills/backend-middlewares.md +243 -0
  38. package/skills/backend-multi-stage-dockerfile.md +47 -0
  39. package/skills/backend-nestjs.md +192 -0
  40. package/skills/backend-next-forge.md +375 -0
  41. package/skills/backend-nextjs.md +746 -0
  42. package/skills/backend-openapi-to-application-code.md +113 -0
  43. package/skills/backend-php-mcp-server-generator.md +523 -0
  44. package/skills/backend-python-mcp-server-generator.md +106 -0
  45. package/skills/backend-routing-middleware.md +251 -0
  46. package/skills/backend-ruby-mcp-server-generator.md +661 -0
  47. package/skills/backend-rust-mcp-server-generator.md +578 -0
  48. package/skills/backend-semantic-kernel.md +57 -0
  49. package/skills/backend-server-setup.md +379 -0
  50. package/skills/backend-server-side-calls.md +250 -0
  51. package/skills/backend-subscriptions.md +407 -0
  52. package/skills/backend-swift-mcp-server-generator.md +670 -0
  53. package/skills/backend-trpc-router.md +152 -0
  54. package/skills/backend-typescript-mcp-server-generator.md +91 -0
  55. package/skills/backend-validators.md +229 -0
  56. package/skills/backend.md +76 -0
  57. package/skills/backup.md +165 -0
  58. package/skills/budget.md +140 -0
  59. package/skills/business-gtm-0-to-1-launch.md +322 -0
  60. package/skills/business-gtm-operating-cadence.md +421 -0
  61. package/skills/business-gtm-positioning-strategy.md +439 -0
  62. package/skills/business-gtm-product-led-growth.md +340 -0
  63. package/skills/calendar.md +95 -0
  64. package/skills/code-review.md +130 -0
  65. package/skills/compliance.md +168 -0
  66. package/skills/contracts.md +130 -0
  67. package/skills/daily-job-run.md +46 -0
  68. package/skills/daily-webdesign.md +187 -0
  69. package/skills/database-bigquery-pipeline-audit.md +130 -0
  70. package/skills/database-cosmosdb-datamodeling.md +1046 -0
  71. package/skills/database-durable-objects.md +187 -0
  72. package/skills/database-ef-core.md +76 -0
  73. package/skills/database-fabric-lakehouse.md +107 -0
  74. package/skills/database-neon-postgres-egress-optimizer.md +213 -0
  75. package/skills/database-neon-postgres.md +218 -0
  76. package/skills/database-postgresql-code-review.md +213 -0
  77. package/skills/database-postgresql-optimization.md +405 -0
  78. package/skills/database-sql-code-review.md +302 -0
  79. package/skills/database-sql-optimization.md +297 -0
  80. package/skills/dependency-audit.md +165 -0
  81. package/skills/design-kami-landing.md +234 -0
  82. package/skills/design.md +221 -0
  83. package/skills/dev-acquire-codebase-knowledge.md +175 -0
  84. package/skills/dev-add-educational-comments.md +129 -0
  85. package/skills/dev-add-model-descriptions.md +74 -0
  86. package/skills/dev-adr-review.md +56 -0
  87. package/skills/dev-boost-prompt.md +26 -0
  88. package/skills/dev-build-run-debug.md +130 -0
  89. package/skills/dev-chunk.md +49 -0
  90. package/skills/dev-claude-md-improver.md +180 -0
  91. package/skills/dev-code-exemplars-blueprint-generator.md +127 -0
  92. package/skills/dev-code-tour.md +434 -0
  93. package/skills/dev-comment-code-generate-a-tutorial.md +27 -0
  94. package/skills/dev-commit.md +81 -0
  95. package/skills/dev-context-map.md +53 -0
  96. package/skills/dev-conventional-commit.md +73 -0
  97. package/skills/dev-create-architectural-decision-record.md +98 -0
  98. package/skills/dev-create-draft-pr.md +17 -0
  99. package/skills/dev-create-pr.md +17 -0
  100. package/skills/dev-create-readme.md +22 -0
  101. package/skills/dev-csharp-mstest.md +479 -0
  102. package/skills/dev-csharp-nunit.md +72 -0
  103. package/skills/dev-csharp-tunit.md +101 -0
  104. package/skills/dev-csharp-xunit.md +69 -0
  105. package/skills/dev-debug-failing-test.md +90 -0
  106. package/skills/dev-diff-analyze.md +32 -0
  107. package/skills/dev-diffs.md +24 -0
  108. package/skills/dev-dotnet-best-practices.md +86 -0
  109. package/skills/dev-dotnet-design-pattern-review.md +43 -0
  110. package/skills/dev-dotnet-timezone.md +110 -0
  111. package/skills/dev-dotnet-upgrade.md +117 -0
  112. package/skills/dev-doublecheck.md +278 -0
  113. package/skills/dev-explain-error.md +15 -0
  114. package/skills/dev-finding-discovery.md +164 -0
  115. package/skills/dev-fix-finding.md +111 -0
  116. package/skills/dev-full-file-edit.md +25 -0
  117. package/skills/dev-git-commit.md +125 -0
  118. package/skills/dev-git-flow-branch-creator.md +293 -0
  119. package/skills/dev-git-workflow.md +46 -0
  120. package/skills/dev-github-automation.md +64 -0
  121. package/skills/dev-github-code-review.md +1140 -0
  122. package/skills/dev-github-issues.md +202 -0
  123. package/skills/dev-gpt-5-4-prompting.md +55 -0
  124. package/skills/dev-investigation-mode.md +277 -0
  125. package/skills/dev-java-add-graalvm-native-image-support.md +450 -0
  126. package/skills/dev-java-docs.md +24 -0
  127. package/skills/dev-java-refactoring-extract-method.md +105 -0
  128. package/skills/dev-java-refactoring-remove-parameter.md +85 -0
  129. package/skills/dev-merge.md +73 -0
  130. package/skills/dev-migrate-create.md +36 -0
  131. package/skills/dev-migrate-validate.md +36 -0
  132. package/skills/dev-my-issues.md +9 -0
  133. package/skills/dev-my-pull-requests.md +15 -0
  134. package/skills/dev-planning-oracle-to-postgres-migration-integration-testing.md +45 -0
  135. package/skills/dev-playwright-generate-test.md +18 -0
  136. package/skills/dev-playwright.md +148 -0
  137. package/skills/dev-prompt-builder.md +142 -0
  138. package/skills/dev-pytest-coverage.md +29 -0
  139. package/skills/dev-python-manager-discovery.md +330 -0
  140. package/skills/dev-python-pypi-package-builder.md +445 -0
  141. package/skills/dev-readme-blueprint-generator.md +79 -0
  142. package/skills/dev-refactor-method-complexity-reduce.md +99 -0
  143. package/skills/dev-refactor-plan.md +66 -0
  144. package/skills/dev-refactor.md +646 -0
  145. package/skills/dev-review-and-refactor.md +16 -0
  146. package/skills/dev-reviewing-oracle-to-postgres-migration.md +68 -0
  147. package/skills/dev-ruff-recursive-fix.md +201 -0
  148. package/skills/dev-run-e2e-tests.md +126 -0
  149. package/skills/dev-run-pre-commit-checks.md +133 -0
  150. package/skills/dev-run-smoke-tests.md +127 -0
  151. package/skills/dev-scaffolding-oracle-to-postgres-migration-test-project.md +55 -0
  152. package/skills/dev-spring-boot-testing.md +190 -0
  153. package/skills/dev-sync-upstream.md +32 -0
  154. package/skills/dev-sync.md +74 -0
  155. package/skills/dev-tdd-workflow.md +23 -0
  156. package/skills/dev-terraform-azurerm-set-diff-analyzer.md +49 -0
  157. package/skills/dev-test-driven-development.md +372 -0
  158. package/skills/dev-test-gaps.md +18 -0
  159. package/skills/dev-test-triage.md +55 -0
  160. package/skills/dev-typer.md +267 -0
  161. package/skills/dev-typescript-setup.md +25 -0
  162. package/skills/dev-unified-diff-edit.md +16 -0
  163. package/skills/dev-unit-test-vue-pinia.md +198 -0
  164. package/skills/dev-using-git-worktrees.md +216 -0
  165. package/skills/dev-validation.md +99 -0
  166. package/skills/dev-verification.md +168 -0
  167. package/skills/dev-webapp-testing.md +134 -0
  168. package/skills/dev-write-coding-standards-from-file.md +317 -0
  169. package/skills/dev-write-tests.md +16 -0
  170. package/skills/devops-appinsights-instrumentation.md +49 -0
  171. package/skills/devops-az-cost-optimize.md +306 -0
  172. package/skills/devops-chronicle.md +154 -0
  173. package/skills/devops-deployments-cicd.md +331 -0
  174. package/skills/devops-devops-rollout-plan.md +118 -0
  175. package/skills/devops-geistdocs.md +276 -0
  176. package/skills/devops-observability.md +774 -0
  177. package/skills/devops-observe-metrics.md +35 -0
  178. package/skills/devops-observe-trace.md +30 -0
  179. package/skills/devops-phoenix-cli.md +163 -0
  180. package/skills/devops-phoenix-tracing.md +140 -0
  181. package/skills/devops-publish-to-pages.md +108 -0
  182. package/skills/devops-telemetry.md +87 -0
  183. package/skills/devops-update-avm-modules-in-bicep.md +61 -0
  184. package/skills/devops.md +81 -0
  185. package/skills/diagrams-canvas.md +204 -0
  186. package/skills/diagrams-draw-io-diagram-generator.md +463 -0
  187. package/skills/diagrams-excalidraw-diagram-generator.md +614 -0
  188. package/skills/diagrams-graphify.md +1277 -0
  189. package/skills/docs-bear-notes.md +108 -0
  190. package/skills/docs-create-llms.md +211 -0
  191. package/skills/docs-doc-gen.md +20 -0
  192. package/skills/docs-documentation-writer.md +46 -0
  193. package/skills/docs-llm-config.md +33 -0
  194. package/skills/docs-mkdocs-translations.md +109 -0
  195. package/skills/docs-obsidian-vault-maintainer.md +14 -0
  196. package/skills/docs-obsidian.md +82 -0
  197. package/skills/docs-prose.md +324 -0
  198. package/skills/docs-update-llms.md +217 -0
  199. package/skills/docs-update-markdown-file-index.md +77 -0
  200. package/skills/docs-wiki-maintainer.md +20 -0
  201. package/skills/documents.md +120 -0
  202. package/skills/email.md +113 -0
  203. package/skills/expenses.md +140 -0
  204. package/skills/file-ops.md +149 -0
  205. package/skills/files-convert-plaintext-to-md.md +363 -0
  206. package/skills/files-doc.md +81 -0
  207. package/skills/files-docx.md +594 -0
  208. package/skills/files-markdown-to-html.md +917 -0
  209. package/skills/files-nano-pdf.md +39 -0
  210. package/skills/files-pdf.md +315 -0
  211. package/skills/files-pdftk-server.md +163 -0
  212. package/skills/files-pptx-html-fidelity-audit.md +255 -0
  213. package/skills/files-pptx.md +231 -0
  214. package/skills/files-xlsx.md +301 -0
  215. package/skills/find-jobs.md +78 -0
  216. package/skills/format-conversion.md +157 -0
  217. package/skills/frontend-ai-elements.md +483 -0
  218. package/skills/frontend-ai-gateway.md +563 -0
  219. package/skills/frontend-ai-generation-persistence.md +242 -0
  220. package/skills/frontend-ai-sdk.md +799 -0
  221. package/skills/frontend-ai-visibility.md +127 -0
  222. package/skills/frontend-angular-developer.md +130 -0
  223. package/skills/frontend-aspnet-minimal-api-openapi.md +42 -0
  224. package/skills/frontend-bencium-innovative-ux-designer.md +719 -0
  225. package/skills/frontend-chat-sdk.md +666 -0
  226. package/skills/frontend-chrome-devtools.md +98 -0
  227. package/skills/frontend-frontend-app-builder.md +186 -0
  228. package/skills/frontend-frontend-design.md +43 -0
  229. package/skills/frontend-frontend-testing-debugging.md +143 -0
  230. package/skills/frontend-gsap-framer-scroll-animation.md +152 -0
  231. package/skills/frontend-internal-linking.md +109 -0
  232. package/skills/frontend-json-render.md +335 -0
  233. package/skills/frontend-keyword-clustering.md +118 -0
  234. package/skills/frontend-next-intl-add-language.md +20 -0
  235. package/skills/frontend-on-page-seo.md +112 -0
  236. package/skills/frontend-premium-frontend-ui.md +114 -0
  237. package/skills/frontend-react-best-practices.md +143 -0
  238. package/skills/frontend-schema-markup.md +160 -0
  239. package/skills/frontend-seo-audit.md +110 -0
  240. package/skills/frontend-swr.md +215 -0
  241. package/skills/frontend-technical-seo.md +162 -0
  242. package/skills/frontend-use-dom.md +418 -0
  243. package/skills/frontend-web-coder.md +564 -0
  244. package/skills/frontend-web-design-reviewer.md +369 -0
  245. package/skills/frontend-web-perf.md +202 -0
  246. package/skills/frontend.md +125 -0
  247. package/skills/general-adapter-standalone.md +199 -0
  248. package/skills/general-auth.md +356 -0
  249. package/skills/general-containerize-aspnetcore.md +393 -0
  250. package/skills/general-create-technical-spike.md +231 -0
  251. package/skills/general-cron-jobs.md +72 -0
  252. package/skills/general-ddd-aggregate.md +52 -0
  253. package/skills/general-ddd-context.md +46 -0
  254. package/skills/general-ddd-validate.md +51 -0
  255. package/skills/general-dependency-check.md +26 -0
  256. package/skills/general-email-marketing.md +86 -0
  257. package/skills/general-healthcheck.md +246 -0
  258. package/skills/general-import-infrastructure-as-code.md +368 -0
  259. package/skills/general-init.md +49 -0
  260. package/skills/general-java-junit.md +64 -0
  261. package/skills/general-java-springboot.md +66 -0
  262. package/skills/general-javascript-typescript-jest.md +45 -0
  263. package/skills/general-kotlin-springboot.md +71 -0
  264. package/skills/general-make-repo-contribution.md +91 -0
  265. package/skills/general-market-research.md +78 -0
  266. package/skills/general-marketplace.md +468 -0
  267. package/skills/general-model-recommendation.md +673 -0
  268. package/skills/general-payments.md +352 -0
  269. package/skills/general-quality-playbook.md +480 -0
  270. package/skills/general-run-integration-tests.md +113 -0
  271. package/skills/general-superjson.md +274 -0
  272. package/skills/general-swiftpm-macos.md +51 -0
  273. package/skills/general-threat-model.md +61 -0
  274. package/skills/invoices.md +167 -0
  275. package/skills/licenses.md +159 -0
  276. package/skills/logs.md +156 -0
  277. package/skills/marketing.md +139 -0
  278. package/skills/media-image-manipulation-image-magick.md +253 -0
  279. package/skills/media-imagegen.md +357 -0
  280. package/skills/media-openai-whisper-api.md +63 -0
  281. package/skills/media-openai-whisper.md +39 -0
  282. package/skills/media-peekaboo.md +191 -0
  283. package/skills/media-screenshot.md +268 -0
  284. package/skills/media-speech.md +145 -0
  285. package/skills/media-transcribe.md +82 -0
  286. package/skills/media-video-frames.md +47 -0
  287. package/skills/mobile-android-emulator-qa.md +81 -0
  288. package/skills/mobile-android-performance.md +280 -0
  289. package/skills/mobile-building-mcp-server-on-cloudflare.md +267 -0
  290. package/skills/mobile-building-native-ui.md +322 -0
  291. package/skills/mobile-expo-api-routes.md +369 -0
  292. package/skills/mobile-expo-cicd-workflows.md +92 -0
  293. package/skills/mobile-expo-deployment.md +191 -0
  294. package/skills/mobile-expo-dev-client.md +165 -0
  295. package/skills/mobile-expo-module.md +177 -0
  296. package/skills/mobile-expo-tailwind-setup.md +481 -0
  297. package/skills/mobile-expo-ui-jetpack-compose.md +41 -0
  298. package/skills/mobile-expo-ui-swift-ui.md +40 -0
  299. package/skills/mobile-ios-app-intents.md +78 -0
  300. package/skills/mobile-ios-debugger-agent.md +52 -0
  301. package/skills/mobile-ios-ettrace-performance.md +198 -0
  302. package/skills/mobile-ios-memgraph-leaks.md +77 -0
  303. package/skills/mobile-native-data-fetching.md +508 -0
  304. package/skills/mobile-packaging-notarization.md +48 -0
  305. package/skills/mobile-react-native-architecture.md +672 -0
  306. package/skills/mobile-react-native-mobile-design.md +438 -0
  307. package/skills/mobile-signing-entitlements.md +59 -0
  308. package/skills/mobile-swiftui-liquid-glass.md +91 -0
  309. package/skills/mobile-swiftui-patterns.md +210 -0
  310. package/skills/mobile-swiftui-performance-audit.md +108 -0
  311. package/skills/mobile-swiftui-ui-patterns.md +97 -0
  312. package/skills/mobile-swiftui-view-refactor.md +204 -0
  313. package/skills/mobile-upgrading-expo.md +134 -0
  314. package/skills/mobile.md +183 -0
  315. package/skills/notes.md +106 -0
  316. package/skills/planning-adr-create.md +62 -0
  317. package/skills/planning-adr-index.md +67 -0
  318. package/skills/planning-architecture-blueprint-generator.md +323 -0
  319. package/skills/planning-brainstorming.md +165 -0
  320. package/skills/planning-breakdown-epic-arch.md +67 -0
  321. package/skills/planning-breakdown-epic-pm.md +59 -0
  322. package/skills/planning-breakdown-feature-implementation.md +129 -0
  323. package/skills/planning-breakdown-feature-prd.md +62 -0
  324. package/skills/planning-breakdown-plan.md +510 -0
  325. package/skills/planning-breakdown-test.md +366 -0
  326. package/skills/planning-cloud-design-patterns.md +63 -0
  327. package/skills/planning-content-brief.md +128 -0
  328. package/skills/planning-content-strategy.md +138 -0
  329. package/skills/planning-content-translation.md +143 -0
  330. package/skills/planning-create-github-action-workflow-specification.md +277 -0
  331. package/skills/planning-create-github-issues-feature-from-implementation-plan.md +29 -0
  332. package/skills/planning-create-github-issues-for-unmet-specification-requirements.md +36 -0
  333. package/skills/planning-create-github-pull-request-from-specification.md +25 -0
  334. package/skills/planning-create-implementation-plan.md +158 -0
  335. package/skills/planning-create-specification.md +128 -0
  336. package/skills/planning-first-ask.md +31 -0
  337. package/skills/planning-folder-structure-blueprint-generator.md +406 -0
  338. package/skills/planning-gen-specs-as-issues.md +166 -0
  339. package/skills/planning-generate-snapshot.md +144 -0
  340. package/skills/planning-generate-status-report.md +336 -0
  341. package/skills/planning-metric-pack-designer.md +27 -0
  342. package/skills/planning-pm-spec.md +53 -0
  343. package/skills/planning-prd.md +144 -0
  344. package/skills/planning-project-assessment.md +182 -0
  345. package/skills/planning-project-setup-info-local.md +128 -0
  346. package/skills/planning-project-workflow-analysis-blueprint-generator.md +294 -0
  347. package/skills/planning-service-oriented-architecture.md +248 -0
  348. package/skills/planning-spec-to-backlog.md +544 -0
  349. package/skills/planning-technology-stack-blueprint-generator.md +243 -0
  350. package/skills/planning-update-implementation-plan.md +158 -0
  351. package/skills/planning-update-specification.md +128 -0
  352. package/skills/planning-what-context-needed.md +40 -0
  353. package/skills/planning-writing-plans.md +153 -0
  354. package/skills/prepare-application.md +81 -0
  355. package/skills/productivity-apple-notes.md +78 -0
  356. package/skills/productivity-apple-reminders.md +119 -0
  357. package/skills/productivity-capture-tasks-from-meeting-notes.md +680 -0
  358. package/skills/productivity-daily-prep.md +156 -0
  359. package/skills/productivity-email-drafter.md +101 -0
  360. package/skills/productivity-hr-onboarding.md +53 -0
  361. package/skills/productivity-things-mac.md +87 -0
  362. package/skills/productivity-update.md +169 -0
  363. package/skills/reminders.md +109 -0
  364. package/skills/research-dossier-collect.md +71 -0
  365. package/skills/research-kg-extract.md +37 -0
  366. package/skills/research-openai-docs.md +89 -0
  367. package/skills/research-research-add-items.md +31 -0
  368. package/skills/research-research-report.md +94 -0
  369. package/skills/research-research-synthesize.md +63 -0
  370. package/skills/research-summarize.md +88 -0
  371. package/skills/research-transformers-js.md +635 -0
  372. package/skills/research.md +119 -0
  373. package/skills/security-ai-prompt-engineering-safety-review.md +231 -0
  374. package/skills/security-attack-path-analysis.md +182 -0
  375. package/skills/security-gdpr-compliant.md +284 -0
  376. package/skills/security-mcp-security-audit.md +279 -0
  377. package/skills/security-pii-detect.md +31 -0
  378. package/skills/security-secret-scanning.md +243 -0
  379. package/skills/security-security-best-practices.md +87 -0
  380. package/skills/security-security-ownership-map.md +207 -0
  381. package/skills/security-security-review.md +169 -0
  382. package/skills/security-security-scan.md +138 -0
  383. package/skills/security-security-threat-model.md +82 -0
  384. package/skills/security-threat-model-analyst.md +76 -0
  385. package/skills/sysmon.md +181 -0
  386. package/skills/system-arch-linux-triage.md +32 -0
  387. package/skills/system-centos-linux-triage.md +32 -0
  388. package/skills/system-debian-linux-triage.md +32 -0
  389. package/skills/system-fedora-linux-triage.md +32 -0
  390. package/skills/system-geofeed-tuner.md +865 -0
  391. package/skills/system-iot-anomalies.md +15 -0
  392. package/skills/system-iot-firmware.md +16 -0
  393. package/skills/system-iot-fleet.md +14 -0
  394. package/skills/system-iot-register.md +19 -0
  395. package/skills/system-iot-witness-verify.md +15 -0
  396. package/skills/system-tmux.md +171 -0
  397. package/skills/system-window-management.md +228 -0
  398. package/skills/task-management.md +90 -0
  399. package/skills/tasks.md +102 -0
  400. package/skills/test-coverage.md +188 -0
  401. package/skills/ux-ui.md +128 -0
  402. package/skills/web.md +186 -0
  403. package/skills/workflow-act-on-feedback.md +15 -0
  404. package/skills/workflow-automate-this.md +245 -0
  405. package/skills/workflow-autoresearch.md +276 -0
  406. package/skills/workflow-coding-agent.md +317 -0
  407. package/skills/workflow-deep-research.md +44 -0
  408. package/skills/workflow-dispatching-parallel-agents.md +183 -0
  409. package/skills/workflow-eval-driven-dev.md +148 -0
  410. package/skills/workflow-executing-plans.md +71 -0
  411. package/skills/workflow-mentoring-juniors.md +311 -0
  412. package/skills/workflow-receiving-code-review.md +214 -0
  413. package/skills/workflow-repo-story-time.md +155 -0
  414. package/skills/workflow-requesting-code-review.md +104 -0
  415. package/skills/workflow-session-report.md +43 -0
  416. package/skills/workflow-structured-autonomy-generate.md +126 -0
  417. package/skills/workflow-subagent-driven-development.md +280 -0
  418. package/skills/writing.md +106 -0
  419. package/src/agent.js +0 -0
  420. package/src/browser.js +297 -0
  421. package/src/cli.js +25 -4
  422. package/src/code-reviewer.js +119 -0
  423. package/src/completions.js +1 -1
  424. package/src/control.js +222 -30
  425. package/src/coordinator.js +303 -0
  426. package/src/correction.js +29 -8
  427. package/src/edit-tracker.js +21 -0
  428. package/src/edit-viewer.js +414 -0
  429. package/src/endpoints.js +64 -15
  430. package/src/index.js +45 -11
  431. package/src/llm.js +86 -2
  432. package/src/mcp-client.js +416 -0
  433. package/src/memory.js +182 -0
  434. package/src/planner.js +216 -0
  435. package/src/rules.js +90 -0
  436. package/src/self-commands.js +757 -0
  437. package/src/services/voice.js +10 -7
  438. package/src/session-search.js +427 -0
  439. package/src/session.js +487 -99
  440. package/src/shmakk-server.js +91 -0
  441. package/src/skills.js +410 -3
  442. package/src/subagent.js +4 -1
  443. package/src/system-prompt.js +13 -5
  444. package/src/task-file.js +114 -0
  445. package/src/taskClassifier.js +246 -0
  446. package/src/team.js +752 -0
  447. package/src/tools.js +142 -21
  448. package/src/web.js +35 -5
  449. package/src/workflows.js +261 -0
  450. package/src/workspace-index.js +25 -6
@@ -0,0 +1,1277 @@
1
+ ---
2
+ name: graphify
3
+ description: any input (code, docs, papers, images) → knowledge graph → clustered communities → HTML + JSON + audit report
4
+ trigger: /graphify
5
+ category: diagrams
6
+ ---
7
+
8
+ # /graphify
9
+
10
+ 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.
11
+
12
+ ## Usage
13
+
14
+ ```
15
+ /graphify # full pipeline on current directory → Obsidian vault
16
+ /graphify <path> # full pipeline on specific path
17
+ /graphify <path> --mode deep # thorough extraction, richer INFERRED edges
18
+ /graphify <path> --update # incremental - re-extract only new/changed files
19
+ /graphify <path> --directed # build directed graph (preserves edge direction: source→target)
20
+ /graphify <path> --whisper-model medium # use a larger Whisper model for better transcription accuracy
21
+ /graphify <path> --cluster-only # rerun clustering on existing graph
22
+ /graphify <path> --no-viz # skip visualization, just report + JSON
23
+ /graphify <path> --html # (HTML is generated by default - this flag is a no-op)
24
+ /graphify <path> --svg # also export graph.svg (embeds in Notion, GitHub)
25
+ /graphify <path> --graphml # export graph.graphml (Gephi, yEd)
26
+ /graphify <path> --neo4j # generate graphify-out/cypher.txt for Neo4j
27
+ /graphify <path> --neo4j-push bolt://localhost:7687 # push directly to Neo4j
28
+ /graphify <path> --mcp # start MCP stdio server for agent access
29
+ /graphify <path> --watch # watch folder, auto-rebuild on code changes (no LLM needed)
30
+ /graphify <path> --wiki # build agent-crawlable wiki (index.md + one article per community)
31
+ /graphify <path> --obsidian --obsidian-dir ~/vaults/my-project # write vault to custom path (e.g. existing vault)
32
+ /graphify add <url> # fetch URL, save to ./raw, update graph
33
+ /graphify add <url> --author "Name" # tag who wrote it
34
+ /graphify add <url> --contributor "Name" # tag who added it to the corpus
35
+ /graphify query "<question>" # BFS traversal - broad context
36
+ /graphify query "<question>" --dfs # DFS - trace a specific path
37
+ /graphify query "<question>" --budget 1500 # cap answer at N tokens
38
+ /graphify path "AuthModule" "Database" # shortest path between two concepts
39
+ /graphify explain "SwinTransformer" # plain-language explanation of a node
40
+ ```
41
+
42
+ ## What graphify is for
43
+
44
+ graphify is built around Andrej Karpathy's /raw folder workflow: drop anything into a folder - papers, tweets, screenshots, code, notes - and get a structured knowledge graph that shows you what you didn't know was connected.
45
+
46
+ Three things it does that Claude alone cannot:
47
+ 1. **Persistent graph** - relationships are stored in `graphify-out/graph.json` and survive across sessions. Ask questions weeks later without re-reading everything.
48
+ 2. **Honest audit trail** - every edge is tagged EXTRACTED, INFERRED, or AMBIGUOUS. You know what was found vs invented.
49
+ 3. **Cross-document surprise** - community detection finds connections between concepts in different files that you would never think to ask about directly.
50
+
51
+ Use it for:
52
+ - A codebase you're new to (understand architecture before touching anything)
53
+ - A reading list (papers + tweets + notes → one navigable graph)
54
+ - A research corpus (citation graph + concept graph in one)
55
+ - Your personal /raw folder (drop everything in, let it grow, query it)
56
+
57
+ ## What You Must Do When Invoked
58
+
59
+ If no path was given, use `.` (current directory). Do not ask the user for a path.
60
+
61
+ Follow these steps in order. Do not skip steps.
62
+
63
+ ### Step 1 - Ensure graphify is installed
64
+
65
+ ```bash
66
+ # Detect the correct Python interpreter (handles pipx, venv, system installs)
67
+ GRAPHIFY_BIN=$(which graphify 2>/dev/null)
68
+ if [ -n "$GRAPHIFY_BIN" ]; then
69
+ PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!')
70
+ case "$PYTHON" in
71
+ *[!a-zA-Z0-9/_.-]*) PYTHON="python3" ;;
72
+ esac
73
+ else
74
+ PYTHON="python3"
75
+ fi
76
+ "$PYTHON" -c "import graphify" 2>/dev/null || "$PYTHON" -m pip install graphifyy -q 2>/dev/null || "$PYTHON" -m pip install graphifyy -q --break-system-packages 2>&1 | tail -3
77
+ # Write interpreter path for all subsequent steps (persists across invocations)
78
+ mkdir -p graphify-out
79
+ "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w').write(sys.executable)"
80
+ ```
81
+
82
+ If the import succeeds, print nothing and move straight to Step 2.
83
+
84
+ **In every subsequent bash block, replace `python3` with `$(cat graphify-out/.graphify_python)` to use the correct interpreter.**
85
+
86
+ ### Step 2 - Detect files
87
+
88
+ ```bash
89
+ $(cat graphify-out/.graphify_python) -c "
90
+ import json
91
+ from graphify.detect import detect
92
+ from pathlib import Path
93
+ result = detect(Path('INPUT_PATH'))
94
+ print(json.dumps(result))
95
+ " > graphify-out/.graphify_detect.json
96
+ ```
97
+
98
+ Replace 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:
99
+
100
+ ```
101
+ Corpus: X files · ~Y words
102
+ code: N files (.py .ts .go ...)
103
+ docs: N files (.md .txt ...)
104
+ papers: N files (.pdf ...)
105
+ images: N files
106
+ video: N files (.mp4 .mp3 ...)
107
+ ```
108
+
109
+ Omit any category with 0 files from the summary.
110
+
111
+ Then act on it:
112
+ - If `total_files` is 0: stop with "No supported files found in [path]."
113
+ - If `skipped_sensitive` is non-empty: mention file count skipped, not the file names.
114
+ - If `total_words` > 2,000,000 OR `total_files` > 200: show the warning and the top 5 subdirectories by file count, then ask which subfolder to run on. Wait for the user's answer before proceeding.
115
+ - Otherwise: proceed directly to Step 2.5 if video files were detected, or Step 3 if not.
116
+
117
+ ### Step 2.5 - Transcribe video / audio files (only if video files detected)
118
+
119
+ Skip this step entirely if `detect` returned zero `video` files.
120
+
121
+ Video and audio files cannot be read directly. Transcribe them to text first, then treat the transcripts as doc files in Step 3.
122
+
123
+ **Strategy:** Read the god nodes from `graphify-out/.graphify_detect.json` (or the analysis file if it exists from a previous run). You are already a language model — write a one-sentence domain hint yourself from those labels. Then pass it to Whisper as the initial prompt. No separate API call needed.
124
+
125
+ **However**, if the corpus has *only* video files and no other docs/code, use the generic fallback prompt: `"Use proper punctuation and paragraph breaks."`
126
+
127
+ **Step 1 - Write the Whisper prompt yourself.**
128
+
129
+ Read the top god node labels from detect output or analysis, then compose a short domain hint sentence, for example:
130
+
131
+ - Labels: `transformer, attention, encoder, decoder` → `"Machine learning research on transformer architectures and attention mechanisms. Use proper punctuation and paragraph breaks."`
132
+ - Labels: `kubernetes, deployment, pod, helm` → `"DevOps discussion about Kubernetes deployments and Helm charts. Use proper punctuation and paragraph breaks."`
133
+
134
+ Set it as `WHISPER_PROMPT` to use in the next command.
135
+
136
+ **Step 2 - Transcribe:**
137
+
138
+ ```bash
139
+ GRAPHIFY_WHISPER_MODEL=base # or whatever --whisper-model the user passed
140
+ $(cat graphify-out/.graphify_python) -c "
141
+ import json, os
142
+ from pathlib import Path
143
+ from graphify.transcribe import transcribe_all
144
+
145
+ detect = json.loads(Path('graphify-out/.graphify_detect.json').read_text())
146
+ video_files = detect.get('files', {}).get('video', [])
147
+ prompt = os.environ.get('GRAPHIFY_WHISPER_PROMPT', 'Use proper punctuation and paragraph breaks.')
148
+
149
+ transcript_paths = transcribe_all(video_files, initial_prompt=prompt)
150
+ print(json.dumps(transcript_paths))
151
+ " > graphify-out/.graphify_transcripts.json
152
+ ```
153
+
154
+ After transcription:
155
+ - Read the transcript paths from `graphify-out/.graphify_transcripts.json`
156
+ - Add them to the docs list before dispatching semantic subagents in Step 3B
157
+ - Print how many transcripts were created: `Transcribed N video file(s) -> treating as docs`
158
+ - If transcription fails for a file, print a warning and continue with the rest
159
+
160
+ **Whisper model:** Default is `base`. If the user passed `--whisper-model <name>`, set `GRAPHIFY_WHISPER_MODEL=<name>` in the environment before running the command above.
161
+
162
+ ### Step 3 - Extract entities and relationships
163
+
164
+ **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.
165
+
166
+ This step has two parts: **structural extraction** (deterministic, free) and **semantic extraction** (Claude, costs tokens).
167
+
168
+ **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.**
169
+
170
+ Note: Parallelizing AST + semantic saves 5-15s on large corpora. AST is deterministic and fast; start it while subagents are processing docs/papers.
171
+
172
+ #### Part A - Structural extraction for code files
173
+
174
+ For any code files detected, run AST extraction in parallel with Part B subagents:
175
+
176
+ ```bash
177
+ $(cat graphify-out/.graphify_python) -c "
178
+ import sys, json
179
+ from graphify.extract import collect_files, extract
180
+ from pathlib import Path
181
+ import json
182
+
183
+ code_files = []
184
+ detect = json.loads(Path('graphify-out/.graphify_detect.json').read_text())
185
+ for f in detect.get('files', {}).get('code', []):
186
+ code_files.extend(collect_files(Path(f)) if Path(f).is_dir() else [Path(f)])
187
+
188
+ if code_files:
189
+ result = extract(code_files)
190
+ Path('graphify-out/.graphify_ast.json').write_text(json.dumps(result, indent=2))
191
+ print(f'AST: {len(result[\"nodes\"])} nodes, {len(result[\"edges\"])} edges')
192
+ else:
193
+ Path('graphify-out/.graphify_ast.json').write_text(json.dumps({'nodes':[],'edges':[],'input_tokens':0,'output_tokens':0}))
194
+ print('No code files - skipping AST extraction')
195
+ "
196
+ ```
197
+
198
+ #### Part B - Semantic extraction (parallel subagents)
199
+
200
+ **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.
201
+
202
+ **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.**
203
+
204
+ Before dispatching subagents, print a timing estimate:
205
+ - Load `total_words` and file counts from `graphify-out/.graphify_detect.json`
206
+ - Estimate agents needed: `ceil(uncached_non_code_files / 22)` (chunk size is 20-25)
207
+ - Estimate time: ~45s per agent batch (they run in parallel, so total ≈ 45s × ceil(agents/parallel_limit))
208
+ - Print: "Semantic extraction: ~N files → X agents, estimated ~Ys"
209
+
210
+ **Step B0 - Check extraction cache first**
211
+
212
+ Before dispatching any subagents, check which files already have cached extraction results:
213
+
214
+ ```bash
215
+ $(cat graphify-out/.graphify_python) -c "
216
+ import json
217
+ from graphify.cache import check_semantic_cache
218
+ from pathlib import Path
219
+
220
+ detect = json.loads(Path('graphify-out/.graphify_detect.json').read_text())
221
+ all_files = [f for files in detect['files'].values() for f in files]
222
+
223
+ cached_nodes, cached_edges, cached_hyperedges, uncached = check_semantic_cache(all_files)
224
+
225
+ if cached_nodes or cached_edges or cached_hyperedges:
226
+ Path('graphify-out/.graphify_cached.json').write_text(json.dumps({'nodes': cached_nodes, 'edges': cached_edges, 'hyperedges': cached_hyperedges}))
227
+ Path('graphify-out/.graphify_uncached.txt').write_text('\n'.join(uncached))
228
+ print(f'Cache: {len(all_files)-len(uncached)} files hit, {len(uncached)} files need extraction')
229
+ "
230
+ ```
231
+
232
+ Only dispatch subagents for files listed in `graphify-out/.graphify_uncached.txt`. If all files are cached, skip to Part C directly.
233
+
234
+ **Step B1 - Split into chunks**
235
+
236
+ Load files from `graphify-out/.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.
237
+
238
+ **Step B2 - Dispatch ALL subagents in a single message**
239
+
240
+ Call 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.
241
+
242
+ **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.
243
+
244
+ Concrete example for 3 chunks:
245
+ ```
246
+ [Agent tool call 1: files 1-15, subagent_type="general-purpose"]
247
+ [Agent tool call 2: files 16-30, subagent_type="general-purpose"]
248
+ [Agent tool call 3: files 31-45, subagent_type="general-purpose"]
249
+ ```
250
+ All three in one message. Not three separate messages.
251
+
252
+ Each subagent receives this exact prompt (substitute FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, and DEEP_MODE):
253
+
254
+ ```
255
+ You are a graphify extraction subagent. Read the files listed and extract a knowledge graph fragment.
256
+ Output ONLY valid JSON matching the schema below - no explanation, no markdown fences, no preamble.
257
+
258
+ Files (chunk CHUNK_NUM of TOTAL_CHUNKS):
259
+ FILE_LIST
260
+
261
+ Rules:
262
+ - EXTRACTED: relationship explicit in source (import, call, citation, "see §3.2")
263
+ - INFERRED: reasonable inference (shared data structure, implied dependency)
264
+ - AMBIGUOUS: uncertain - flag for review, do not omit
265
+
266
+ Code files: focus on semantic edges AST cannot find (call relationships, shared data, arch patterns).
267
+ Do not re-extract imports - AST already has those.
268
+ Doc/paper files: extract named concepts, entities, citations. Also extract rationale — sections that explain WHY a decision was made, trade-offs chosen, or design intent. These become nodes with `rationale_for` edges pointing to the concept they explain.
269
+ Image files: use vision to understand what the image IS - do not just OCR.
270
+ UI screenshot: layout patterns, design decisions, key elements, purpose.
271
+ Chart: metric, trend/insight, data source.
272
+ Tweet/post: claim as node, author, concepts mentioned.
273
+ Diagram: components and connections.
274
+ Research figure: what it demonstrates, method, result.
275
+ Handwritten/whiteboard: ideas and arrows, mark uncertain readings AMBIGUOUS.
276
+
277
+ DEEP_MODE (if --mode deep was given): be aggressive with INFERRED edges - indirect deps,
278
+ shared assumptions, latent couplings. Mark uncertain ones AMBIGUOUS instead of omitting.
279
+
280
+ Semantic similarity: if two concepts in this chunk solve the same problem or represent the same idea without any structural link (no import, no call, no citation), add a `semantically_similar_to` edge marked INFERRED with a confidence_score reflecting how similar they are (0.6-0.95). Examples:
281
+ - Two functions that both validate user input but never call each other
282
+ - A class in code and a concept in a paper that describe the same algorithm
283
+ - Two error types that handle the same failure mode differently
284
+ Only add these when the similarity is genuinely non-obvious and cross-cutting. Do not add them for trivially similar things.
285
+
286
+ Hyperedges: if 3 or more nodes clearly participate together in a shared concept, flow, or pattern that is not captured by pairwise edges alone, add a hyperedge to a top-level `hyperedges` array. Examples:
287
+ - All classes that implement a common protocol or interface
288
+ - All functions in an authentication flow (even if they don't all call each other)
289
+ - All concepts from a paper section that form one coherent idea
290
+ Use sparingly — only when the group relationship adds information beyond the pairwise edges. Maximum 3 hyperedges per chunk.
291
+
292
+ If a file has YAML frontmatter (--- ... ---), copy source_url, captured_at, author,
293
+ contributor onto every node from that file.
294
+
295
+ confidence_score is REQUIRED on every edge - never omit it, never use 0.5 as a default:
296
+ - EXTRACTED edges: confidence_score = 1.0 always
297
+ - INFERRED edges: reason about each edge individually.
298
+ Direct structural evidence (shared data structure, clear dependency): 0.8-0.9.
299
+ Reasonable inference with some uncertainty: 0.6-0.7.
300
+ Weak or speculative: 0.4-0.5. Most edges should be 0.6-0.9, not 0.5.
301
+ - AMBIGUOUS edges: 0.1-0.3
302
+
303
+ Output exactly this JSON (no other text):
304
+ {"nodes":[{"id":"filestem_entityname","label":"Human Readable Name","file_type":"code|document|paper|image","source_file":"relative/path","source_location":null,"source_url":null,"captured_at":null,"author":null,"contributor":null}],"edges":[{"source":"node_id","target":"node_id","relation":"calls|implements|references|cites|conceptually_related_to|shares_data_with|semantically_similar_to|rationale_for","confidence":"EXTRACTED|INFERRED|AMBIGUOUS","confidence_score":1.0,"source_file":"relative/path","source_location":null,"weight":1.0}],"hyperedges":[{"id":"snake_case_id","label":"Human Readable Label","nodes":["node_id1","node_id2","node_id3"],"relation":"participate_in|implement|form","confidence":"EXTRACTED|INFERRED","confidence_score":0.75,"source_file":"relative/path"}],"input_tokens":0,"output_tokens":0}
305
+ ```
306
+
307
+ **Step B3 - Collect, cache, and merge**
308
+
309
+ Wait for all subagents. For each result:
310
+ - Check that `graphify-out/.graphify_chunk_NN.json` exists on disk — this is the success signal
311
+ - If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache
312
+ - 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.
313
+ - If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort
314
+
315
+ If 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.
316
+
317
+ Save new results to cache:
318
+ ```bash
319
+ $(cat graphify-out/.graphify_python) -c "
320
+ import json
321
+ from graphify.cache import save_semantic_cache
322
+ from pathlib import Path
323
+
324
+ new = json.loads(Path('graphify-out/.graphify_semantic_new.json').read_text()) if Path('graphify-out/.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}
325
+ saved = save_semantic_cache(new.get('nodes', []), new.get('edges', []), new.get('hyperedges', []))
326
+ print(f'Cached {saved} files')
327
+ "
328
+ ```
329
+
330
+ Merge cached + new results into `graphify-out/.graphify_semantic.json`:
331
+ ```bash
332
+ $(cat graphify-out/.graphify_python) -c "
333
+ import json
334
+ from pathlib import Path
335
+
336
+ cached = json.loads(Path('graphify-out/.graphify_cached.json').read_text()) if Path('graphify-out/.graphify_cached.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}
337
+ new = json.loads(Path('graphify-out/.graphify_semantic_new.json').read_text()) if Path('graphify-out/.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}
338
+
339
+ all_nodes = cached['nodes'] + new.get('nodes', [])
340
+ all_edges = cached['edges'] + new.get('edges', [])
341
+ all_hyperedges = cached.get('hyperedges', []) + new.get('hyperedges', [])
342
+ seen = set()
343
+ deduped = []
344
+ for n in all_nodes:
345
+ if n['id'] not in seen:
346
+ seen.add(n['id'])
347
+ deduped.append(n)
348
+
349
+ merged = {
350
+ 'nodes': deduped,
351
+ 'edges': all_edges,
352
+ 'hyperedges': all_hyperedges,
353
+ 'input_tokens': new.get('input_tokens', 0),
354
+ 'output_tokens': new.get('output_tokens', 0),
355
+ }
356
+ Path('graphify-out/.graphify_semantic.json').write_text(json.dumps(merged, indent=2))
357
+ print(f'Extraction complete - {len(deduped)} nodes, {len(all_edges)} edges ({len(cached[\"nodes\"])} from cache, {len(new.get(\"nodes\",[]))} new)')
358
+ "
359
+ ```
360
+ Clean up temp files: `rm -f graphify-out/.graphify_cached.json graphify-out/.graphify_uncached.txt graphify-out/.graphify_semantic_new.json`
361
+
362
+ #### Part C - Merge AST + semantic into final extraction
363
+
364
+ ```bash
365
+ $(cat graphify-out/.graphify_python) -c "
366
+ import sys, json
367
+ from pathlib import Path
368
+
369
+ ast = json.loads(Path('graphify-out/.graphify_ast.json').read_text())
370
+ sem = json.loads(Path('graphify-out/.graphify_semantic.json').read_text())
371
+
372
+ # Merge: AST nodes first, semantic nodes deduplicated by id
373
+ seen = {n['id'] for n in ast['nodes']}
374
+ merged_nodes = list(ast['nodes'])
375
+ for n in sem['nodes']:
376
+ if n['id'] not in seen:
377
+ merged_nodes.append(n)
378
+ seen.add(n['id'])
379
+
380
+ merged_edges = ast['edges'] + sem['edges']
381
+ merged_hyperedges = sem.get('hyperedges', [])
382
+ merged = {
383
+ 'nodes': merged_nodes,
384
+ 'edges': merged_edges,
385
+ 'hyperedges': merged_hyperedges,
386
+ 'input_tokens': sem.get('input_tokens', 0),
387
+ 'output_tokens': sem.get('output_tokens', 0),
388
+ }
389
+ Path('graphify-out/.graphify_extract.json').write_text(json.dumps(merged, indent=2))
390
+ total = len(merged_nodes)
391
+ edges = len(merged_edges)
392
+ print(f'Merged: {total} nodes, {edges} edges ({len(ast[\"nodes\"])} AST + {len(sem[\"nodes\"])} semantic)')
393
+ "
394
+ ```
395
+
396
+ ### Step 4 - Build graph, cluster, analyze, generate outputs
397
+
398
+ **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`.
399
+
400
+ ```bash
401
+ mkdir -p graphify-out
402
+ $(cat graphify-out/.graphify_python) -c "
403
+ import sys, json
404
+ from graphify.build import build_from_json
405
+ from graphify.cluster import cluster, score_all
406
+ from graphify.analyze import god_nodes, surprising_connections, suggest_questions
407
+ from graphify.report import generate
408
+ from graphify.export import to_json
409
+ from pathlib import Path
410
+
411
+ extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text())
412
+ detection = json.loads(Path('graphify-out/.graphify_detect.json').read_text())
413
+
414
+ G = build_from_json(extraction)
415
+ communities = cluster(G)
416
+ cohesion = score_all(G, communities)
417
+ tokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}
418
+ gods = god_nodes(G)
419
+ surprises = surprising_connections(G, communities)
420
+ labels = {cid: 'Community ' + str(cid) for cid in communities}
421
+ # Placeholder questions - regenerated with real labels in Step 5
422
+ questions = suggest_questions(G, communities, labels)
423
+
424
+ report = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, 'INPUT_PATH', suggested_questions=questions)
425
+ Path('graphify-out/GRAPH_REPORT.md').write_text(report)
426
+ to_json(G, communities, 'graphify-out/graph.json')
427
+
428
+ analysis = {
429
+ 'communities': {str(k): v for k, v in communities.items()},
430
+ 'cohesion': {str(k): v for k, v in cohesion.items()},
431
+ 'gods': gods,
432
+ 'surprises': surprises,
433
+ 'questions': questions,
434
+ }
435
+ Path('graphify-out/.graphify_analysis.json').write_text(json.dumps(analysis, indent=2))
436
+ if G.number_of_nodes() == 0:
437
+ print('ERROR: Graph is empty - extraction produced no nodes.')
438
+ print('Possible causes: all files were skipped, binary-only corpus, or extraction failed.')
439
+ raise SystemExit(1)
440
+ print(f'Graph: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges, {len(communities)} communities')
441
+ "
442
+ ```
443
+
444
+ If this step prints `ERROR: Graph is empty`, stop and tell the user what happened - do not proceed to labeling or visualization.
445
+
446
+ Replace INPUT_PATH with the actual path.
447
+
448
+ ### Step 5 - Label communities
449
+
450
+ Read `graphify-out/.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").
451
+
452
+ Then regenerate the report and save the labels for the visualizer:
453
+
454
+ ```bash
455
+ $(cat graphify-out/.graphify_python) -c "
456
+ import sys, json
457
+ from graphify.build import build_from_json
458
+ from graphify.cluster import score_all
459
+ from graphify.analyze import god_nodes, surprising_connections, suggest_questions
460
+ from graphify.report import generate
461
+ from pathlib import Path
462
+
463
+ extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text())
464
+ detection = json.loads(Path('graphify-out/.graphify_detect.json').read_text())
465
+ analysis = json.loads(Path('graphify-out/.graphify_analysis.json').read_text())
466
+
467
+ G = build_from_json(extraction)
468
+ communities = {int(k): v for k, v in analysis['communities'].items()}
469
+ cohesion = {int(k): v for k, v in analysis['cohesion'].items()}
470
+ tokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}
471
+
472
+ # LABELS - replace these with the names you chose above
473
+ labels = LABELS_DICT
474
+
475
+ # Regenerate questions with real community labels (labels affect question phrasing)
476
+ questions = suggest_questions(G, communities, labels)
477
+
478
+ report = generate(G, communities, cohesion, labels, analysis['gods'], analysis['surprises'], detection, tokens, 'INPUT_PATH', suggested_questions=questions)
479
+ Path('graphify-out/GRAPH_REPORT.md').write_text(report)
480
+ Path('graphify-out/.graphify_labels.json').write_text(json.dumps({str(k): v for k, v in labels.items()}))
481
+ print('Report updated with community labels')
482
+ "
483
+ ```
484
+
485
+ Replace `LABELS_DICT` with the actual dict you constructed (e.g. `{0: "Attention Mechanism", 1: "Training Pipeline"}`).
486
+ Replace INPUT_PATH with the actual path.
487
+
488
+ ### Step 6 - Generate Obsidian vault (opt-in) + HTML
489
+
490
+ **Generate HTML always** (unless `--no-viz`). **Obsidian vault only if `--obsidian` was explicitly given** — skip it otherwise, it generates one file per node.
491
+
492
+ If `--obsidian` was given:
493
+
494
+ - If `--obsidian-dir <path>` was also given, use that path as the vault directory. Otherwise default to `graphify-out/obsidian`.
495
+
496
+ ```bash
497
+ $(cat graphify-out/.graphify_python) -c "
498
+ import sys, json
499
+ from graphify.build import build_from_json
500
+ from graphify.export import to_obsidian, to_canvas
501
+ from pathlib import Path
502
+
503
+ extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text())
504
+ analysis = json.loads(Path('graphify-out/.graphify_analysis.json').read_text())
505
+ labels_raw = json.loads(Path('graphify-out/.graphify_labels.json').read_text()) if Path('graphify-out/.graphify_labels.json').exists() else {}
506
+
507
+ G = build_from_json(extraction)
508
+ communities = {int(k): v for k, v in analysis['communities'].items()}
509
+ cohesion = {int(k): v for k, v in analysis['cohesion'].items()}
510
+ labels = {int(k): v for k, v in labels_raw.items()}
511
+
512
+ obsidian_dir = 'OBSIDIAN_DIR' # replace with --obsidian-dir value, or 'graphify-out/obsidian' if not given
513
+
514
+ n = to_obsidian(G, communities, obsidian_dir, community_labels=labels or None, cohesion=cohesion)
515
+ print(f'Obsidian vault: {n} notes in {obsidian_dir}/')
516
+
517
+ to_canvas(G, communities, f'{obsidian_dir}/graph.canvas', community_labels=labels or None)
518
+ print(f'Canvas: {obsidian_dir}/graph.canvas - open in Obsidian for structured community layout')
519
+ print()
520
+ print(f'Open {obsidian_dir}/ as a vault in Obsidian.')
521
+ print(' Graph view - nodes colored by community (set automatically)')
522
+ print(' graph.canvas - structured layout with communities as groups')
523
+ print(' _COMMUNITY_* - overview notes with cohesion scores and dataview queries')
524
+ "
525
+ ```
526
+
527
+ Generate the HTML graph (always, unless `--no-viz`):
528
+
529
+ ```bash
530
+ $(cat graphify-out/.graphify_python) -c "
531
+ import sys, json
532
+ from graphify.build import build_from_json
533
+ from graphify.export import to_html
534
+ from pathlib import Path
535
+
536
+ extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text())
537
+ analysis = json.loads(Path('graphify-out/.graphify_analysis.json').read_text())
538
+ labels_raw = json.loads(Path('graphify-out/.graphify_labels.json').read_text()) if Path('graphify-out/.graphify_labels.json').exists() else {}
539
+
540
+ G = build_from_json(extraction)
541
+ communities = {int(k): v for k, v in analysis['communities'].items()}
542
+ labels = {int(k): v for k, v in labels_raw.items()}
543
+
544
+ if G.number_of_nodes() > 5000:
545
+ print(f'Graph has {G.number_of_nodes()} nodes - too large for HTML viz. Use Obsidian vault instead.')
546
+ else:
547
+ to_html(G, communities, 'graphify-out/graph.html', community_labels=labels or None)
548
+ print('graph.html written - open in any browser, no server needed')
549
+ "
550
+ ```
551
+
552
+ ### Step 7 - Neo4j export (only if --neo4j or --neo4j-push flag)
553
+
554
+ **If `--neo4j`** - generate a Cypher file for manual import:
555
+
556
+ ```bash
557
+ $(cat graphify-out/.graphify_python) -c "
558
+ import sys, json
559
+ from graphify.build import build_from_json
560
+ from graphify.export import to_cypher
561
+ from pathlib import Path
562
+
563
+ G = build_from_json(json.loads(Path('graphify-out/.graphify_extract.json').read_text()))
564
+ to_cypher(G, 'graphify-out/cypher.txt')
565
+ print('cypher.txt written - import with: cypher-shell < graphify-out/cypher.txt')
566
+ "
567
+ ```
568
+
569
+ **If `--neo4j-push <uri>`** - push directly to a running Neo4j instance. Ask the user for credentials if not provided:
570
+
571
+ ```bash
572
+ $(cat graphify-out/.graphify_python) -c "
573
+ import sys, json
574
+ from graphify.build import build_from_json
575
+ from graphify.cluster import cluster
576
+ from graphify.export import push_to_neo4j
577
+ from pathlib import Path
578
+
579
+ extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text())
580
+ analysis = json.loads(Path('graphify-out/.graphify_analysis.json').read_text())
581
+ G = build_from_json(extraction)
582
+ communities = {int(k): v for k, v in analysis['communities'].items()}
583
+
584
+ result = push_to_neo4j(G, uri='NEO4J_URI', user='NEO4J_USER', password='NEO4J_PASSWORD', communities=communities)
585
+ print(f'Pushed to Neo4j: {result[\"nodes\"]} nodes, {result[\"edges\"]} edges')
586
+ "
587
+ ```
588
+
589
+ Replace `NEO4J_URI`, `NEO4J_USER`, `NEO4J_PASSWORD` with actual values. Default URI is `bolt://localhost:7687`, default user is `neo4j`. Uses MERGE - safe to re-run without creating duplicates.
590
+
591
+ ### Step 7b - SVG export (only if --svg flag)
592
+
593
+ ```bash
594
+ $(cat graphify-out/.graphify_python) -c "
595
+ import sys, json
596
+ from graphify.build import build_from_json
597
+ from graphify.export import to_svg
598
+ from pathlib import Path
599
+
600
+ extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text())
601
+ analysis = json.loads(Path('graphify-out/.graphify_analysis.json').read_text())
602
+ labels_raw = json.loads(Path('graphify-out/.graphify_labels.json').read_text()) if Path('graphify-out/.graphify_labels.json').exists() else {}
603
+
604
+ G = build_from_json(extraction)
605
+ communities = {int(k): v for k, v in analysis['communities'].items()}
606
+ labels = {int(k): v for k, v in labels_raw.items()}
607
+
608
+ to_svg(G, communities, 'graphify-out/graph.svg', community_labels=labels or None)
609
+ print('graph.svg written - embeds in Obsidian, Notion, GitHub READMEs')
610
+ "
611
+ ```
612
+
613
+ ### Step 7c - GraphML export (only if --graphml flag)
614
+
615
+ ```bash
616
+ $(cat graphify-out/.graphify_python) -c "
617
+ import json
618
+ from graphify.build import build_from_json
619
+ from graphify.export import to_graphml
620
+ from pathlib import Path
621
+
622
+ extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text())
623
+ analysis = json.loads(Path('graphify-out/.graphify_analysis.json').read_text())
624
+
625
+ G = build_from_json(extraction)
626
+ communities = {int(k): v for k, v in analysis['communities'].items()}
627
+
628
+ to_graphml(G, communities, 'graphify-out/graph.graphml')
629
+ print('graph.graphml written - open in Gephi, yEd, or any GraphML tool')
630
+ "
631
+ ```
632
+
633
+ ### Step 7d - MCP server (only if --mcp flag)
634
+
635
+ ```bash
636
+ python3 -m graphify.serve graphify-out/graph.json
637
+ ```
638
+
639
+ This starts a stdio MCP server that exposes tools: `query_graph`, `get_node`, `get_neighbors`, `get_community`, `god_nodes`, `graph_stats`, `shortest_path`. Add to Claude Desktop or any MCP-compatible agent orchestrator so other agents can query the graph live.
640
+
641
+ To configure in Claude Desktop, add to `claude_desktop_config.json`:
642
+ ```json
643
+ {
644
+ "mcpServers": {
645
+ "graphify": {
646
+ "command": "python3",
647
+ "args": ["-m", "graphify.serve", "/absolute/path/to/graphify-out/graph.json"]
648
+ }
649
+ }
650
+ }
651
+ ```
652
+
653
+ ### Step 8 - Token reduction benchmark (only if total_words > 5000)
654
+
655
+ If `total_words` from `graphify-out/.graphify_detect.json` is greater than 5,000, run:
656
+
657
+ ```bash
658
+ $(cat graphify-out/.graphify_python) -c "
659
+ import json
660
+ from graphify.benchmark import run_benchmark, print_benchmark
661
+ from pathlib import Path
662
+
663
+ detection = json.loads(Path('graphify-out/.graphify_detect.json').read_text())
664
+ result = run_benchmark('graphify-out/graph.json', corpus_words=detection['total_words'])
665
+ print_benchmark(result)
666
+ "
667
+ ```
668
+
669
+ Print the output directly in chat. If `total_words <= 5000`, skip silently - the graph value is structural clarity, not token compression, for small corpora.
670
+
671
+ ---
672
+
673
+ ### Step 9 - Save manifest, update cost tracker, clean up, and report
674
+
675
+ ```bash
676
+ $(cat graphify-out/.graphify_python) -c "
677
+ import json
678
+ from pathlib import Path
679
+ from datetime import datetime, timezone
680
+ from graphify.detect import save_manifest
681
+
682
+ # Save manifest for --update
683
+ detect = json.loads(Path('graphify-out/.graphify_detect.json').read_text())
684
+ save_manifest(detect['files'])
685
+
686
+ # Update cumulative cost tracker
687
+ extract = json.loads(Path('graphify-out/.graphify_extract.json').read_text())
688
+ input_tok = extract.get('input_tokens', 0)
689
+ output_tok = extract.get('output_tokens', 0)
690
+
691
+ cost_path = Path('graphify-out/cost.json')
692
+ if cost_path.exists():
693
+ cost = json.loads(cost_path.read_text())
694
+ else:
695
+ cost = {'runs': [], 'total_input_tokens': 0, 'total_output_tokens': 0}
696
+
697
+ cost['runs'].append({
698
+ 'date': datetime.now(timezone.utc).isoformat(),
699
+ 'input_tokens': input_tok,
700
+ 'output_tokens': output_tok,
701
+ 'files': detect.get('total_files', 0),
702
+ })
703
+ cost['total_input_tokens'] += input_tok
704
+ cost['total_output_tokens'] += output_tok
705
+ cost_path.write_text(json.dumps(cost, indent=2))
706
+
707
+ print(f'This run: {input_tok:,} input tokens, {output_tok:,} output tokens')
708
+ print(f'All time: {cost[\"total_input_tokens\"]:,} input, {cost[\"total_output_tokens\"]:,} output ({len(cost[\"runs\"])} runs)')
709
+ "
710
+ rm -f graphify-out/.graphify_detect.json graphify-out/.graphify_extract.json graphify-out/.graphify_ast.json graphify-out/.graphify_semantic.json graphify-out/.graphify_analysis.json graphify-out/.graphify_labels.json
711
+ rm -f graphify-out/.needs_update 2>/dev/null || true
712
+ ```
713
+
714
+ Tell the user (omit the obsidian line unless --obsidian was given):
715
+ ```
716
+ Graph complete. Outputs in PATH_TO_DIR/graphify-out/
717
+
718
+ graph.html - interactive graph, open in browser
719
+ GRAPH_REPORT.md - audit report
720
+ graph.json - raw graph data
721
+ obsidian/ - Obsidian vault (only if --obsidian was given)
722
+ ```
723
+
724
+ If graphify saved you time, consider supporting it: https://github.com/sponsors/safishamsi
725
+
726
+ Replace PATH_TO_DIR with the actual absolute path of the directory that was processed.
727
+
728
+ Then paste these sections from GRAPH_REPORT.md directly into the chat:
729
+ - God Nodes
730
+ - Surprising Connections
731
+ - Suggested Questions
732
+
733
+ Do NOT paste the full report - just those three sections. Keep it concise.
734
+
735
+ Then 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:
736
+
737
+ > "The most interesting question this graph can answer: **[question]**. Want me to trace it?"
738
+
739
+ If the user says yes, run `/graphify 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.
740
+
741
+ The graph is the map. Your job after the pipeline is to be the guide.
742
+
743
+ ---
744
+
745
+ ## Interpreter guard for subcommands
746
+
747
+ Before 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/`), re-resolve the interpreter first:
748
+
749
+ ```bash
750
+ if [ ! -f graphify-out/.graphify_python ]; then
751
+ GRAPHIFY_BIN=$(which graphify 2>/dev/null)
752
+ if [ -n "$GRAPHIFY_BIN" ]; then
753
+ PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!')
754
+ case "$PYTHON" in *[!a-zA-Z0-9/_.-]*) PYTHON="python3" ;; esac
755
+ else
756
+ PYTHON="python3"
757
+ fi
758
+ mkdir -p graphify-out
759
+ "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w').write(sys.executable)"
760
+ fi
761
+ ```
762
+
763
+ ## For --update (incremental re-extraction)
764
+
765
+ Use when you've added or modified files since the last run. Only re-extracts changed files - saves tokens and time.
766
+
767
+ ```bash
768
+ $(cat graphify-out/.graphify_python) -c "
769
+ import sys, json
770
+ from graphify.detect import detect_incremental, save_manifest
771
+ from pathlib import Path
772
+
773
+ result = detect_incremental(Path('INPUT_PATH'))
774
+ new_total = result.get('new_total', 0)
775
+ print(json.dumps(result, indent=2))
776
+ Path('graphify-out/.graphify_incremental.json').write_text(json.dumps(result))
777
+ if new_total == 0:
778
+ print('No files changed since last run. Nothing to update.')
779
+ raise SystemExit(0)
780
+ print(f'{new_total} new/changed file(s) to re-extract.')
781
+ "
782
+ ```
783
+
784
+ If new files exist, first check whether all changed files are code files:
785
+
786
+ ```bash
787
+ $(cat graphify-out/.graphify_python) -c "
788
+ import json
789
+ from pathlib import Path
790
+
791
+ result = json.loads(open('graphify-out/.graphify_incremental.json').read()) if Path('graphify-out/.graphify_incremental.json').exists() else {}
792
+ code_exts = {'.py','.ts','.js','.go','.rs','.java','.cpp','.c','.rb','.swift','.kt','.cs','.scala','.php','.cc','.cxx','.hpp','.h','.kts','.lua','.toc'}
793
+ new_files = result.get('new_files', {})
794
+ all_changed = [f for files in new_files.values() for f in files]
795
+ code_only = all(Path(f).suffix.lower() in code_exts for f in all_changed)
796
+ print('code_only:', code_only)
797
+ "
798
+ ```
799
+
800
+ If `code_only` is True: print `[graphify update] Code-only changes detected - skipping semantic extraction (no LLM needed)`, run only Step 3A (AST) on the changed files, skip Step 3B entirely (no subagents), then go straight to merge and Steps 4–8.
801
+
802
+ If `code_only` is False (any changed file is a doc/paper/image): run the full Steps 3A–3C pipeline as normal.
803
+
804
+ Then:
805
+
806
+ ```bash
807
+ $(cat graphify-out/.graphify_python) -c "
808
+ import sys, json
809
+ from graphify.build import build_from_json
810
+ from graphify.export import to_json
811
+ from networkx.readwrite import json_graph
812
+ import networkx as nx
813
+ from pathlib import Path
814
+
815
+ # Load existing graph
816
+ existing_data = json.loads(Path('graphify-out/graph.json').read_text())
817
+ G_existing = json_graph.node_link_graph(existing_data, edges='links')
818
+
819
+ # Load new extraction
820
+ new_extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text())
821
+ G_new = build_from_json(new_extraction)
822
+
823
+ # Prune nodes from deleted files
824
+ incremental = json.loads(Path('graphify-out/.graphify_incremental.json').read_text())
825
+ deleted = set(incremental.get('deleted_files', []))
826
+ if deleted:
827
+ to_remove = [n for n, d in G_existing.nodes(data=True) if d.get('source_file') in deleted]
828
+ G_existing.remove_nodes_from(to_remove)
829
+ print(f'Pruned {len(to_remove)} ghost nodes from {len(deleted)} deleted file(s)')
830
+
831
+ # Merge: new nodes/edges into existing graph
832
+ G_existing.update(G_new)
833
+ print(f'Merged: {G_existing.number_of_nodes()} nodes, {G_existing.number_of_edges()} edges')
834
+ "
835
+ ```
836
+
837
+ Then run Steps 4–8 on the merged graph as normal.
838
+
839
+ After Step 4, show the graph diff:
840
+
841
+ ```bash
842
+ $(cat graphify-out/.graphify_python) -c "
843
+ import json
844
+ from graphify.analyze import graph_diff
845
+ from graphify.build import build_from_json
846
+ from networkx.readwrite import json_graph
847
+ import networkx as nx
848
+ from pathlib import Path
849
+
850
+ # Load old graph (before update) from backup written before merge
851
+ old_data = json.loads(Path('graphify-out/.graphify_old.json').read_text()) if Path('graphify-out/.graphify_old.json').exists() else None
852
+ new_extract = json.loads(Path('graphify-out/.graphify_extract.json').read_text())
853
+ G_new = build_from_json(new_extract)
854
+
855
+ if old_data:
856
+ G_old = json_graph.node_link_graph(old_data, edges='links')
857
+ diff = graph_diff(G_old, G_new)
858
+ print(diff['summary'])
859
+ if diff['new_nodes']:
860
+ print('New nodes:', ', '.join(n['label'] for n in diff['new_nodes'][:5]))
861
+ if diff['new_edges']:
862
+ print('New edges:', len(diff['new_edges']))
863
+ "
864
+ ```
865
+
866
+ Before the merge step, save the old graph: `cp graphify-out/graph.json graphify-out/.graphify_old.json`
867
+ Clean up after: `rm -f graphify-out/.graphify_old.json`
868
+
869
+ ---
870
+
871
+ ## For --cluster-only
872
+
873
+ Skip Steps 1–3. Load the existing graph from `graphify-out/graph.json` and re-run clustering:
874
+
875
+ ```bash
876
+ $(cat graphify-out/.graphify_python) -c "
877
+ import sys, json
878
+ from graphify.cluster import cluster, score_all
879
+ from graphify.analyze import god_nodes, surprising_connections
880
+ from graphify.report import generate
881
+ from graphify.export import to_json
882
+ from networkx.readwrite import json_graph
883
+ import networkx as nx
884
+ from pathlib import Path
885
+
886
+ data = json.loads(Path('graphify-out/graph.json').read_text())
887
+ G = json_graph.node_link_graph(data, edges='links')
888
+
889
+ detection = {'total_files': 0, 'total_words': 99999, 'needs_graph': True, 'warning': None,
890
+ 'files': {'code': [], 'document': [], 'paper': []}}
891
+ tokens = {'input': 0, 'output': 0}
892
+
893
+ communities = cluster(G)
894
+ cohesion = score_all(G, communities)
895
+ gods = god_nodes(G)
896
+ surprises = surprising_connections(G, communities)
897
+ labels = {cid: 'Community ' + str(cid) for cid in communities}
898
+
899
+ report = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, '.')
900
+ Path('graphify-out/GRAPH_REPORT.md').write_text(report)
901
+ to_json(G, communities, 'graphify-out/graph.json')
902
+
903
+ analysis = {
904
+ 'communities': {str(k): v for k, v in communities.items()},
905
+ 'cohesion': {str(k): v for k, v in cohesion.items()},
906
+ 'gods': gods,
907
+ 'surprises': surprises,
908
+ }
909
+ Path('graphify-out/.graphify_analysis.json').write_text(json.dumps(analysis, indent=2))
910
+ print(f'Re-clustered: {len(communities)} communities')
911
+ "
912
+ ```
913
+
914
+ Then run Steps 5–9 as normal (label communities, generate viz, benchmark, clean up, report).
915
+
916
+ ---
917
+
918
+ ## For /graphify query
919
+
920
+ Two traversal modes - choose based on the question:
921
+
922
+ | Mode | Flag | Best for |
923
+ |------|------|----------|
924
+ | BFS (default) | _(none)_ | "What is X connected to?" - broad context, nearest neighbors first |
925
+ | DFS | `--dfs` | "How does X reach Y?" - trace a specific chain or dependency path |
926
+
927
+ First check the graph exists:
928
+ ```bash
929
+ $(cat graphify-out/.graphify_python) -c "
930
+ from pathlib import Path
931
+ if not Path('graphify-out/graph.json').exists():
932
+ print('ERROR: No graph found. Run /graphify <path> first to build the graph.')
933
+ raise SystemExit(1)
934
+ "
935
+ ```
936
+ If it fails, stop and tell the user to run `/graphify <path>` first.
937
+
938
+ Load `graphify-out/graph.json`, then:
939
+
940
+ 1. Find the 1-3 nodes whose label best matches key terms in the question.
941
+ 2. Run the appropriate traversal from each starting node.
942
+ 3. Read the subgraph - node labels, edge relations, confidence tags, source locations.
943
+ 4. Answer using **only** what the graph contains. Quote `source_location` when citing a specific fact.
944
+ 5. If the graph lacks enough information, say so - do not hallucinate edges.
945
+
946
+ ```bash
947
+ $(cat graphify-out/.graphify_python) -c "
948
+ import sys, json
949
+ from networkx.readwrite import json_graph
950
+ import networkx as nx
951
+ from pathlib import Path
952
+
953
+ data = json.loads(Path('graphify-out/graph.json').read_text())
954
+ G = json_graph.node_link_graph(data, edges='links')
955
+
956
+ question = 'QUESTION'
957
+ mode = 'MODE' # 'bfs' or 'dfs'
958
+ terms = [t.lower() for t in question.split() if len(t) > 3]
959
+
960
+ # Find best-matching start nodes
961
+ scored = []
962
+ for nid, ndata in G.nodes(data=True):
963
+ label = ndata.get('label', '').lower()
964
+ score = sum(1 for t in terms if t in label)
965
+ if score > 0:
966
+ scored.append((score, nid))
967
+ scored.sort(reverse=True)
968
+ start_nodes = [nid for _, nid in scored[:3]]
969
+
970
+ if not start_nodes:
971
+ print('No matching nodes found for query terms:', terms)
972
+ sys.exit(0)
973
+
974
+ subgraph_nodes = set()
975
+ subgraph_edges = []
976
+
977
+ if mode == 'dfs':
978
+ # DFS: follow one path as deep as possible before backtracking.
979
+ # Depth-limited to 6 to avoid traversing the whole graph.
980
+ visited = set()
981
+ stack = [(n, 0) for n in reversed(start_nodes)]
982
+ while stack:
983
+ node, depth = stack.pop()
984
+ if node in visited or depth > 6:
985
+ continue
986
+ visited.add(node)
987
+ subgraph_nodes.add(node)
988
+ for neighbor in G.neighbors(node):
989
+ if neighbor not in visited:
990
+ stack.append((neighbor, depth + 1))
991
+ subgraph_edges.append((node, neighbor))
992
+ else:
993
+ # BFS: explore all neighbors layer by layer up to depth 3.
994
+ frontier = set(start_nodes)
995
+ subgraph_nodes = set(start_nodes)
996
+ for _ in range(3):
997
+ next_frontier = set()
998
+ for n in frontier:
999
+ for neighbor in G.neighbors(n):
1000
+ if neighbor not in subgraph_nodes:
1001
+ next_frontier.add(neighbor)
1002
+ subgraph_edges.append((n, neighbor))
1003
+ subgraph_nodes.update(next_frontier)
1004
+ frontier = next_frontier
1005
+
1006
+ # Token-budget aware output: rank by relevance, cut at budget (~4 chars/token)
1007
+ token_budget = BUDGET # default 2000
1008
+ char_budget = token_budget * 4
1009
+
1010
+ # Score each node by term overlap for ranked output
1011
+ def relevance(nid):
1012
+ label = G.nodes[nid].get('label', '').lower()
1013
+ return sum(1 for t in terms if t in label)
1014
+
1015
+ ranked_nodes = sorted(subgraph_nodes, key=relevance, reverse=True)
1016
+
1017
+ lines = [f'Traversal: {mode.upper()} | Start: {[G.nodes[n].get(\"label\",n) for n in start_nodes]} | {len(subgraph_nodes)} nodes']
1018
+ for nid in ranked_nodes:
1019
+ d = G.nodes[nid]
1020
+ lines.append(f' NODE {d.get(\"label\", nid)} [src={d.get(\"source_file\",\"\")} loc={d.get(\"source_location\",\"\")}]')
1021
+ for u, v in subgraph_edges:
1022
+ if u in subgraph_nodes and v in subgraph_nodes:
1023
+ d = G.edges[u, v]
1024
+ lines.append(f' EDGE {G.nodes[u].get(\"label\",u)} --{d.get(\"relation\",\"\")} [{d.get(\"confidence\",\"\")}]--> {G.nodes[v].get(\"label\",v)}')
1025
+
1026
+ output = '\n'.join(lines)
1027
+ if len(output) > char_budget:
1028
+ output = output[:char_budget] + f'\n... (truncated at ~{token_budget} token budget - use --budget N for more)'
1029
+ print(output)
1030
+ "
1031
+ ```
1032
+
1033
+ Replace `QUESTION` with the user's actual question, `MODE` with `bfs` or `dfs`, and `BUDGET` with the token budget (default `2000`, or whatever `--budget N` specifies). Then answer based on the subgraph output above.
1034
+
1035
+ After writing the answer, save it back into the graph so it improves future queries:
1036
+
1037
+ ```bash
1038
+ $(cat graphify-out/.graphify_python) -m graphify save-result --question "QUESTION" --answer "ANSWER" --type query --nodes NODE1 NODE2
1039
+ ```
1040
+
1041
+ Replace `QUESTION` with the question, `ANSWER` with your full answer text, `SOURCE_NODES` with the list of node labels you cited. This closes the feedback loop: the next `--update` will extract this Q&A as a node in the graph.
1042
+
1043
+ ---
1044
+
1045
+ ## For /graphify path
1046
+
1047
+ Find the shortest path between two named concepts in the graph.
1048
+
1049
+ First check the graph exists:
1050
+ ```bash
1051
+ $(cat graphify-out/.graphify_python) -c "
1052
+ from pathlib import Path
1053
+ if not Path('graphify-out/graph.json').exists():
1054
+ print('ERROR: No graph found. Run /graphify <path> first to build the graph.')
1055
+ raise SystemExit(1)
1056
+ "
1057
+ ```
1058
+ If it fails, stop and tell the user to run `/graphify <path>` first.
1059
+
1060
+ ```bash
1061
+ $(cat graphify-out/.graphify_python) -c "
1062
+ import json, sys
1063
+ import networkx as nx
1064
+ from networkx.readwrite import json_graph
1065
+ from pathlib import Path
1066
+
1067
+ data = json.loads(Path('graphify-out/graph.json').read_text())
1068
+ G = json_graph.node_link_graph(data, edges='links')
1069
+
1070
+ a_term = 'NODE_A'
1071
+ b_term = 'NODE_B'
1072
+
1073
+ def find_node(term):
1074
+ term = term.lower()
1075
+ scored = sorted(
1076
+ [(sum(1 for w in term.split() if w in G.nodes[n].get('label','').lower()), n)
1077
+ for n in G.nodes()],
1078
+ reverse=True
1079
+ )
1080
+ return scored[0][1] if scored and scored[0][0] > 0 else None
1081
+
1082
+ src = find_node(a_term)
1083
+ tgt = find_node(b_term)
1084
+
1085
+ if not src or not tgt:
1086
+ print(f'Could not find nodes matching: {a_term!r} or {b_term!r}')
1087
+ sys.exit(0)
1088
+
1089
+ try:
1090
+ path = nx.shortest_path(G, src, tgt)
1091
+ print(f'Shortest path ({len(path)-1} hops):')
1092
+ for i, nid in enumerate(path):
1093
+ label = G.nodes[nid].get('label', nid)
1094
+ if i < len(path) - 1:
1095
+ edge = G.edges[nid, path[i+1]]
1096
+ rel = edge.get('relation', '')
1097
+ conf = edge.get('confidence', '')
1098
+ print(f' {label} --{rel}--> [{conf}]')
1099
+ else:
1100
+ print(f' {label}')
1101
+ except nx.NetworkXNoPath:
1102
+ print(f'No path found between {a_term!r} and {b_term!r}')
1103
+ except nx.NodeNotFound as e:
1104
+ print(f'Node not found: {e}')
1105
+ "
1106
+ ```
1107
+
1108
+ Replace `NODE_A` and `NODE_B` with the actual concept names from the user. Then explain the path in plain language - what each hop means, why it's significant.
1109
+
1110
+ After writing the explanation, save it back:
1111
+
1112
+ ```bash
1113
+ $(cat graphify-out/.graphify_python) -m graphify save-result --question "Path from NODE_A to NODE_B" --answer "ANSWER" --type path_query --nodes NODE_A NODE_B
1114
+ ```
1115
+
1116
+ ---
1117
+
1118
+ ## For /graphify explain
1119
+
1120
+ Give a plain-language explanation of a single node - everything connected to it.
1121
+
1122
+ First check the graph exists:
1123
+ ```bash
1124
+ $(cat graphify-out/.graphify_python) -c "
1125
+ from pathlib import Path
1126
+ if not Path('graphify-out/graph.json').exists():
1127
+ print('ERROR: No graph found. Run /graphify <path> first to build the graph.')
1128
+ raise SystemExit(1)
1129
+ "
1130
+ ```
1131
+ If it fails, stop and tell the user to run `/graphify <path>` first.
1132
+
1133
+ ```bash
1134
+ $(cat graphify-out/.graphify_python) -c "
1135
+ import json, sys
1136
+ import networkx as nx
1137
+ from networkx.readwrite import json_graph
1138
+ from pathlib import Path
1139
+
1140
+ data = json.loads(Path('graphify-out/graph.json').read_text())
1141
+ G = json_graph.node_link_graph(data, edges='links')
1142
+
1143
+ term = 'NODE_NAME'
1144
+ term_lower = term.lower()
1145
+
1146
+ # Find best matching node
1147
+ scored = sorted(
1148
+ [(sum(1 for w in term_lower.split() if w in G.nodes[n].get('label','').lower()), n)
1149
+ for n in G.nodes()],
1150
+ reverse=True
1151
+ )
1152
+ if not scored or scored[0][0] == 0:
1153
+ print(f'No node matching {term!r}')
1154
+ sys.exit(0)
1155
+
1156
+ nid = scored[0][1]
1157
+ data_n = G.nodes[nid]
1158
+ print(f'NODE: {data_n.get(\"label\", nid)}')
1159
+ print(f' source: {data_n.get(\"source_file\",\"unknown\")}')
1160
+ print(f' type: {data_n.get(\"file_type\",\"unknown\")}')
1161
+ print(f' degree: {G.degree(nid)}')
1162
+ print()
1163
+ print('CONNECTIONS:')
1164
+ for neighbor in G.neighbors(nid):
1165
+ edge = G.edges[nid, neighbor]
1166
+ nlabel = G.nodes[neighbor].get('label', neighbor)
1167
+ rel = edge.get('relation', '')
1168
+ conf = edge.get('confidence', '')
1169
+ src_file = G.nodes[neighbor].get('source_file', '')
1170
+ print(f' --{rel}--> {nlabel} [{conf}] ({src_file})')
1171
+ "
1172
+ ```
1173
+
1174
+ Replace `NODE_NAME` with the concept the user asked about. Then write a 3-5 sentence explanation of what this node is, what it connects to, and why those connections are significant. Use the source locations as citations.
1175
+
1176
+ After writing the explanation, save it back:
1177
+
1178
+ ```bash
1179
+ $(cat graphify-out/.graphify_python) -m graphify save-result --question "Explain NODE_NAME" --answer "ANSWER" --type explain --nodes NODE_NAME
1180
+ ```
1181
+
1182
+ ---
1183
+
1184
+ ## For /graphify add
1185
+
1186
+ Fetch a URL and add it to the corpus, then update the graph.
1187
+
1188
+ ```bash
1189
+ $(cat graphify-out/.graphify_python) -c "
1190
+ import sys
1191
+ from graphify.ingest import ingest
1192
+ from pathlib import Path
1193
+
1194
+ try:
1195
+ out = ingest('URL', Path('./raw'), author='AUTHOR', contributor='CONTRIBUTOR')
1196
+ print(f'Saved to {out}')
1197
+ except ValueError as e:
1198
+ print(f'error: {e}', file=sys.stderr)
1199
+ sys.exit(1)
1200
+ except RuntimeError as e:
1201
+ print(f'error: {e}', file=sys.stderr)
1202
+ sys.exit(1)
1203
+ "
1204
+ ```
1205
+
1206
+ Replace `URL` with the actual URL, `AUTHOR` with the user's name if provided, `CONTRIBUTOR` likewise. If the command exits with an error, tell the user what went wrong - do not silently continue. After a successful save, automatically run the `--update` pipeline on `./raw` to merge the new file into the existing graph.
1207
+
1208
+ Supported URL types (auto-detected):
1209
+ - YouTube / any video URL → audio downloaded via yt-dlp, transcribed to `.txt` on next run (requires `pip install 'graphifyy[video]'`)
1210
+ - Twitter/X → fetched via oEmbed, saved as `.md` with tweet text and author
1211
+ - arXiv → abstract + metadata saved as `.md`
1212
+ - PDF → downloaded as `.pdf`
1213
+ - Images (.png/.jpg/.webp) → downloaded, Claude vision extracts on next run
1214
+ - Any webpage → converted to markdown via html2text
1215
+
1216
+ ---
1217
+
1218
+ ## For --watch
1219
+
1220
+ Start a background watcher that monitors a folder and auto-updates the graph when files change.
1221
+
1222
+ ```bash
1223
+ python3 -m graphify.watch INPUT_PATH --debounce 3
1224
+ ```
1225
+
1226
+ Replace INPUT_PATH with the folder to watch. Behavior depends on what changed:
1227
+
1228
+ - **Code files only (.py, .ts, .go, etc.):** re-runs AST extraction + rebuild + cluster immediately, no LLM needed. `graph.json` and `GRAPH_REPORT.md` are updated automatically.
1229
+ - **Docs, papers, or images:** writes a `graphify-out/needs_update` flag and prints a notification to run `/graphify --update` (LLM semantic re-extraction required).
1230
+
1231
+ Debounce (default 3s): waits until file activity stops before triggering, so a wave of parallel agent writes doesn't trigger a rebuild per file.
1232
+
1233
+ Press Ctrl+C to stop.
1234
+
1235
+ For agentic workflows: run `--watch` in a background terminal. Code changes from agent waves are picked up automatically between waves. If agents are also writing docs or notes, you'll need a manual `/graphify --update` after those waves.
1236
+
1237
+ ---
1238
+
1239
+ ## For git commit hook
1240
+
1241
+ Install a post-commit hook that auto-rebuilds the graph after every commit. No background process needed - triggers once per commit, works with any editor.
1242
+
1243
+ ```bash
1244
+ graphify hook install # install
1245
+ graphify hook uninstall # remove
1246
+ graphify hook status # check
1247
+ ```
1248
+
1249
+ After every `git commit`, the hook detects which code files changed (via `git diff HEAD~1`), re-runs AST extraction on those files, and rebuilds `graph.json` and `GRAPH_REPORT.md`. Doc/image changes are ignored by the hook - run `/graphify --update` manually for those.
1250
+
1251
+ If a post-commit hook already exists, graphify appends to it rather than replacing it.
1252
+
1253
+ ---
1254
+
1255
+ ## For native CLAUDE.md integration
1256
+
1257
+ Run once per project to make graphify always-on in Claude Code sessions:
1258
+
1259
+ ```bash
1260
+ graphify claude install
1261
+ ```
1262
+
1263
+ This writes a `## graphify` section to the local `CLAUDE.md` that instructs Claude to check the graph before answering codebase questions and rebuild it after code changes. No manual `/graphify` needed in future sessions.
1264
+
1265
+ ```bash
1266
+ graphify claude uninstall # remove the section
1267
+ ```
1268
+
1269
+ ---
1270
+
1271
+ ## Honesty Rules
1272
+
1273
+ - Never invent an edge. If unsure, use AMBIGUOUS.
1274
+ - Never skip the corpus check warning.
1275
+ - Always show token cost in the report.
1276
+ - Never hide cohesion scores behind symbols - show the raw number.
1277
+ - Never run HTML viz on a graph with more than 5,000 nodes without warning the user.