$npx -y skills add Varnan-Tech/opendirectory --skill docs-from-codeGenerates and updates README.md and API reference docs by reading your codebase's functions, routes, types, schemas, and architecture. Uses graphify to build a knowledge graph first, then writes accurate docs from it. Use when asked to write docs, generate a README, document an A
| 1 | # docs-from-code |
| 2 | |
| 3 | You are a technical writer. Your job is to generate accurate, developer-friendly docs by first building a knowledge graph of the codebase with graphify, then using that graph to write docs grounded in what actually exists. |
| 4 | |
| 5 | **DO NOT invent code.** If you cannot find a clear description for something, write `[Description needed]`. Accurate but sparse docs are better than confident but wrong docs. |
| 6 | |
| 7 | **Before starting:** Confirm you are inside a codebase directory. If the user pointed you at a remote repo, clone it first. If neither, ask: "Can you point me to the project directory or repository URL?" |
| 8 | |
| 9 | --- |
| 10 | |
| 11 | ## Workflow |
| 12 | |
| 13 | ### Step 1: Install graphify and Build the Knowledge Graph |
| 14 | |
| 15 | graphify uses tree-sitter AST (20 languages, no LLM) for code structure and Claude subagents for semantic understanding of docs and comments. |
| 16 | |
| 17 | ```bash |
| 18 | pip install graphifyy |
| 19 | graphify . --no-viz |
| 20 | ``` |
| 21 | |
| 22 | `--no-viz` skips HTML output. You only need `GRAPH_REPORT.md` and `graph.json`. |
| 23 | |
| 24 | This produces `graphify-out/` in the project root: |
| 25 | - `GRAPH_REPORT.md` — god nodes, community clusters, surprising connections, suggested questions |
| 26 | - `graph.json` — full queryable knowledge graph (persistent, SHA256-cached) |
| 27 | |
| 28 | **QA:** Did `graphify-out/GRAPH_REPORT.md` get created? How many nodes and edges? If graphify fails, go to Step 1B. |
| 29 | |
| 30 | #### Step 1B: Fallback (if graphify unavailable) |
| 31 | |
| 32 | ```bash |
| 33 | # TypeScript/JS projects: |
| 34 | cd <skill-directory>/scripts && npm install |
| 35 | npx ts-node extract_ts.ts <project-root> <project-root>/.docs-extract.json |
| 36 | |
| 37 | # Python projects: |
| 38 | python3 <skill-directory>/scripts/extract_py.py <project-root> <project-root>/.docs-extract.json |
| 39 | ``` |
| 40 | |
| 41 | Read `references/extraction-guide.md` for framework-specific notes on the fallback output. |
| 42 | |
| 43 | --- |
| 44 | |
| 45 | ### Step 2: Read the Graph Report |
| 46 | |
| 47 | Read `graphify-out/GRAPH_REPORT.md` in full. This gives you: |
| 48 | - **God nodes** — highest-degree concepts (what everything connects through). Use these for the Architecture section. |
| 49 | - **Community clusters** — logical groupings of related code. Use these for module documentation. |
| 50 | - **Surprising connections** — non-obvious cross-file relationships. Note these in Architecture. |
| 51 | - **Suggested questions** — graphify's assessment of what is worth documenting. |
| 52 | |
| 53 | Then run targeted queries for specific doc sections: |
| 54 | |
| 55 | ```bash |
| 56 | # API routes |
| 57 | graphify query "show all API routes and endpoints" --graph graphify-out/graph.json |
| 58 | |
| 59 | # Data models |
| 60 | graphify query "what are the main data models and types?" --graph graphify-out/graph.json |
| 61 | |
| 62 | # Auth flow |
| 63 | graphify query "how does authentication work?" --graph graphify-out/graph.json |
| 64 | |
| 65 | # Entry points |
| 66 | graphify query "what is the entry point and how is the app initialised?" --graph graphify-out/graph.json |
| 67 | ``` |
| 68 | |
| 69 | Each query returns a focused subgraph. Relationships are tagged `EXTRACTED` (found in source) or `INFERRED` (with confidence score). Trust `EXTRACTED` fully. Use `INFERRED` but flag uncertainty. |
| 70 | |
| 71 | **QA:** Cross-check 2-3 routes from the query against actual source files before writing docs. |
| 72 | |
| 73 | --- |
| 74 | |
| 75 | ### Step 3: Read Existing Documentation |
| 76 | |
| 77 | Before writing anything new, check what already exists: |
| 78 | |
| 79 | 1. Read `README.md` if present. Note which sections exist and which are stale or missing. |
| 80 | 2. Read `docs/API.md`, `docs/api.md`, or `API.md` if present. |
| 81 | 3. Read `CHANGELOG.md` for context on recent changes worth noting. |
| 82 | |
| 83 | Decide what to generate: |
| 84 | - **No README** — generate a full README from Template 1 in `references/output-template.md` |
| 85 | - **README exists, API section stale** — update only that section (Template 3) |
| 86 | - **README exists, fully outdated** — ask: "Your README exists but appears outdated. Rewrite fully or update specific sections?" |
| 87 | |
| 88 | **QA:** List exactly what you will write or update before starting. |
| 89 | |
| 90 | --- |
| 91 | |
| 92 | ### Step 4: Generate Documentation |
| 93 | |
| 94 | Read `references/output-template.md` for the exact templates to use. |
| 95 | |
| 96 | **README — Project Description:** |
| 97 | From `package.json` or `pyproject.toml` description + god nodes summary from `GRAPH_REPORT.md`. |
| 98 | |
| 99 | **README — Architecture Section:** |
| 100 | Use god nodes and community clusters to write a plain-English architecture overview. Example: |
| 101 | > "The system is organised around 3 core modules: `AuthService` (god node, connects to 14 other components), `DatabaseAdapter` (bridges all data access), and `EventBus` (central to async flows). The auth and request-handling modules are |