$npx -y skills add xwtro0tk1t-cloud/harness --skill graphManage code knowledge graphs via code-review-graph (CRG). Build, update, and check status of project code graphs stored in .code-review-graph/graph.db. Use when: (1) user says "build graph", "update graph", "graph status", "/graph", (2) Harness init detects CRG, (3) preparing to
| 1 | # Graph — Knowledge Graph Management |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Manage project code knowledge graphs powered by [code-review-graph](https://github.com/tirth8205/code-review-graph). The graph stores code structure (functions, classes, calls, imports) in `.code-review-graph/graph.db` (SQLite) and enables architecture understanding, impact analysis, and caller/callee tracing. |
| 6 | |
| 7 | **Announce at start:** "I'm using the graph skill to manage the project's code knowledge graph." |
| 8 | |
| 9 | ## Commands |
| 10 | |
| 11 | ### `/graph build` — Full Build |
| 12 | |
| 13 | Build a complete code graph for the current project: |
| 14 | |
| 15 | ```bash |
| 16 | # Check CRG is available first |
| 17 | python -c "import code_review_graph.tools" 2>/dev/null |
| 18 | if [ $? -ne 0 ]; then |
| 19 | echo "CRG not installed. Run: pip install code-review-graph" |
| 20 | exit 1 |
| 21 | fi |
| 22 | |
| 23 | # Full build |
| 24 | code-review-graph build --repo . |
| 25 | ``` |
| 26 | |
| 27 | After build, report: |
| 28 | - Graph location: `.code-review-graph/graph.db` |
| 29 | - Node count: `SELECT COUNT(*) FROM nodes` |
| 30 | - Edge count: `SELECT COUNT(*) FROM edges` |
| 31 | - Community count: use `list_communities_func` from `code_review_graph.tools` |
| 32 | |
| 33 | ### `/graph update` — Incremental Update |
| 34 | |
| 35 | Update the graph with recent changes (faster than full build): |
| 36 | |
| 37 | ```bash |
| 38 | code-review-graph update --repo . |
| 39 | ``` |
| 40 | |
| 41 | ### `/graph status` — Graph Status |
| 42 | |
| 43 | Check if a graph exists and show stats: |
| 44 | |
| 45 | ```python |
| 46 | import os, sqlite3 |
| 47 | |
| 48 | db_path = ".code-review-graph/graph.db" |
| 49 | if not os.path.exists(db_path): |
| 50 | print("No graph found. Run /graph build first.") |
| 51 | else: |
| 52 | conn = sqlite3.connect(db_path) |
| 53 | nodes = conn.execute("SELECT COUNT(*) FROM nodes").fetchone()[0] |
| 54 | edges = conn.execute("SELECT COUNT(*) FROM edges").fetchone()[0] |
| 55 | mtime = os.path.getmtime(db_path) |
| 56 | from datetime import datetime |
| 57 | last_updated = datetime.fromtimestamp(mtime).strftime("%Y-%m-%d %H:%M") |
| 58 | print(f"Graph: {db_path}") |
| 59 | print(f"Nodes: {nodes} | Edges: {edges} | Last updated: {last_updated}") |
| 60 | conn.close() |
| 61 | ``` |
| 62 | |
| 63 | Also run `list_communities_func` from `code_review_graph.tools` to show community count. |
| 64 | |
| 65 | ### `/graph view` — Interactive Visualization in Browser |
| 66 | |
| 67 | Open an interactive graph visualization in the browser: |
| 68 | |
| 69 | ```bash |
| 70 | # Generate HTML + start local server (auto-opens http://localhost:8765) |
| 71 | code-review-graph visualize --repo . --serve |
| 72 | ``` |
| 73 | |
| 74 | View modes: |
| 75 | |
| 76 | ```bash |
| 77 | # Default: auto-detect best layout |
| 78 | code-review-graph visualize --repo . --serve |
| 79 | |
| 80 | # Community/module view: nodes grouped by detected communities |
| 81 | code-review-graph visualize --repo . --mode community --serve |
| 82 | |
| 83 | # File-level view: nodes are files, edges are cross-file dependencies |
| 84 | code-review-graph visualize --repo . --mode file --serve |
| 85 | |
| 86 | # Full view: every function/class as a node |
| 87 | code-review-graph visualize --repo . --mode full --serve |
| 88 | ``` |
| 89 | |
| 90 | Export (no server): |
| 91 | |
| 92 | ```bash |
| 93 | # Generate HTML file only → open .code-review-graph/visualization.html manually |
| 94 | code-review-graph visualize --repo . |
| 95 | |
| 96 | # Export as SVG image |
| 97 | code-review-graph visualize --repo . --format svg |
| 98 | |
| 99 | # Export for Obsidian |
| 100 | code-review-graph visualize --repo . --format obsidian |
| 101 | |
| 102 | # Export as GraphML (for yEd/Gephi) |
| 103 | code-review-graph visualize --repo . --format graphml |
| 104 | ``` |
| 105 | |
| 106 | ### `/graph wiki` — Generate Markdown Wiki |
| 107 | |
| 108 | ```bash |
| 109 | code-review-graph wiki --repo . |
| 110 | # Generates markdown docs from community structure |
| 111 | ``` |
| 112 | |
| 113 | ### `/graph install` — Check/Install CRG |
| 114 | |
| 115 | ```bash |
| 116 | python -c "import code_review_graph.tools; print('CRG is available')" 2>/dev/null \ |
| 117 | || echo "CRG not installed. Install with: pip install code-review-graph" |
| 118 | ``` |
| 119 | |
| 120 | ## Graceful Degradation |
| 121 | |
| 122 | - CRG not installed → show install command, never crash |
| 123 | - Detection method: `python -c "import code_review_graph.tools"` (matches `graph_builder.py` pattern) |
| 124 | - Graph file missing → prompt `/graph build` |
| 125 | |
| 126 | ## Storage |
| 127 | |
| 128 | - Graph: `.code-review-graph/graph.db` (CRG default, in workspace) |
| 129 | - Metadata: `.code-review-graph/` directory, managed by CRG automatically |