$npx -y skills add xwtro0tk1t-cloud/harness --skill exploreGraph-driven project understanding using code-review-graph (CRG). Query architecture, modules, callers/callees, impact radius, hotspots, execution flows, and search nodes. Use when: (1) brainstorming and need to understand project structure, (2) writing plans and need impact anal
| 1 | # Explore — Graph-Driven Project Understanding |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Query the project's code knowledge graph to understand architecture, trace call chains, and analyze impact. Powered by CRG's graph.db (SQLite) + CRG Python API. |
| 6 | |
| 7 | **Announce at start:** "I'm using the explore skill to query the project's code knowledge graph." |
| 8 | |
| 9 | ## Prerequisites |
| 10 | |
| 11 | - CRG must be installed: `python -c "import code_review_graph.tools"` |
| 12 | - Graph must exist: `.code-review-graph/graph.db` |
| 13 | - If missing → tell user: "Please run `/graph build` first" |
| 14 | - If graph older than 24h → suggest: "Graph may be stale, consider `/graph update`" |
| 15 | |
| 16 | ## Commands |
| 17 | |
| 18 | ### `/explore architecture` — Project Architecture Overview |
| 19 | |
| 20 | Shows module decomposition, coupling relationships, and entry points. |
| 21 | |
| 22 | ```python |
| 23 | from pathlib import Path |
| 24 | from code_review_graph.tools import list_communities_func, get_architecture_overview_func |
| 25 | |
| 26 | # Get communities (modules) — CRG takes repo_root, not db_path |
| 27 | repo = Path(".") |
| 28 | result = list_communities_func(repo_root=repo) |
| 29 | communities = result.get("communities", []) |
| 30 | |
| 31 | # Get architecture overview |
| 32 | overview = get_architecture_overview_func(repo_root=repo) |
| 33 | ``` |
| 34 | |
| 35 | Present as: module list with node counts, inter-module coupling, key entry points. |
| 36 | |
| 37 | ### `/explore module <name>` — Module Details |
| 38 | |
| 39 | Shows nodes, edges, and responsibilities of a specific module. |
| 40 | |
| 41 | ```python |
| 42 | from pathlib import Path |
| 43 | from code_review_graph.tools import list_communities_func |
| 44 | |
| 45 | # CRG has no single-community query API — filter from full list |
| 46 | result = list_communities_func(repo_root=Path(".")) |
| 47 | communities = result.get("communities", []) |
| 48 | target = [c for c in communities if name.lower() in str(c).lower()] |
| 49 | ``` |
| 50 | |
| 51 | ### `/explore callers <func>` — Who Calls This Function? |
| 52 | |
| 53 | Direct SQLite query (no CRG wrapper available for this): |
| 54 | |
| 55 | ```python |
| 56 | import sqlite3 |
| 57 | conn = sqlite3.connect(".code-review-graph/graph.db") |
| 58 | conn.row_factory = sqlite3.Row |
| 59 | rows = conn.execute( |
| 60 | "SELECT * FROM edges WHERE target_qualified LIKE ? AND kind='CALLS'", |
| 61 | (f"%{func}%",) |
| 62 | ).fetchall() |
| 63 | conn.close() |
| 64 | ``` |
| 65 | |
| 66 | ### `/explore callees <func>` — What Does This Function Call? |
| 67 | |
| 68 | ```python |
| 69 | import sqlite3 |
| 70 | conn = sqlite3.connect(".code-review-graph/graph.db") |
| 71 | conn.row_factory = sqlite3.Row |
| 72 | rows = conn.execute( |
| 73 | "SELECT * FROM edges WHERE source_qualified LIKE ? AND kind='CALLS'", |
| 74 | (f"%{func}%",) |
| 75 | ).fetchall() |
| 76 | conn.close() |
| 77 | ``` |
| 78 | |
| 79 | ### `/explore impact <file>` — Impact Analysis |
| 80 | |
| 81 | Shows which flows and functions are affected by changes to a file. |
| 82 | |
| 83 | ```python |
| 84 | from pathlib import Path |
| 85 | from code_review_graph.tools import get_impact_radius, get_affected_flows_func |
| 86 | |
| 87 | # CRG takes changed_files (list) and repo_root, not file_path + db_path |
| 88 | repo = Path(".") |
| 89 | impact = get_impact_radius(changed_files=["<file>"], repo_root=repo) |
| 90 | result = get_affected_flows_func(changed_files=["<file>"], repo_root=repo) |
| 91 | flows = result.get("flows", result.get("affected_flows", [])) |
| 92 | ``` |
| 93 | |
| 94 | ### `/explore hotspots` — Hub Nodes, Bridge Nodes, Knowledge Gaps |
| 95 | |
| 96 | **IMPORTANT:** `get_hub_nodes_func` / `get_bridge_nodes_func` from `code_review_graph.tools` are buggy. Use `code_review_graph.analysis` instead: |
| 97 | |
| 98 | ```python |
| 99 | from code_review_graph.tools._common import _get_store |
| 100 | from code_review_graph.analysis import find_hub_nodes, find_bridge_nodes |
| 101 | |
| 102 | # CRG analysis functions take a store object, not db_path |
| 103 | # Must use _get_store() first to get the store |
| 104 | store, _ = _get_store(str(Path(".").resolve())) |
| 105 | hubs = find_hub_nodes(store, top_n=20) |
| 106 | bridges = find_bridge_nodes(store, top_n=20) |
| 107 | ``` |
| 108 | |
| 109 | For knowledge gaps (`get_knowledge_gaps` has sqlite3.Row type issue), use direct SQLite: |
| 110 | |
| 111 | ```python |
| 112 | import sqlite3 |
| 113 | conn = sqlite3.connect(".code-review-graph/graph.db") |
| 114 | # Nodes with high connectivity but no docstring/comments |
| 115 | rows = conn.execute(""" |
| 116 | SELECT n.qualified_name, n.kind, COUNT(e.id) as edge_count |
| 117 | FROM nodes n |
| 118 | JOIN edges e ON n.qualified_name = e.source_qualified OR n.qualified_name = e.target_qualified |
| 119 | WHERE n.docstring IS NULL OR n.docstring = '' |
| 120 | GROUP BY n.qualified_name |
| 121 | HAVING edge_count > 5 |
| 122 | ORDER BY edge_count DESC |
| 123 | LIMIT 20 |
| 124 | """).fetchall() |
| 125 | conn.close() |
| 126 | ``` |
| 127 | |
| 128 | ### `/explore flows` — Execution Flow List |
| 129 | |
| 130 | ```python |
| 131 | from pathlib import Path |
| 132 | from code_review_graph.tools import list_flows |
| 133 | |
| 134 | # Note: NO _func suffix — it's list_flows, not list_flows_func |
| 135 | result = list_flows(repo_root=Path(".")) |
| 136 | flows = result.get("flows", []) |
| 137 | ``` |
| 138 | |
| 139 | ### `/explore search <keyword>` — Search Nodes by Keyword |
| 140 | |
| 141 | Try CRG's search first, f |