一键导入
rebuild-code-graph
Rebuild or update the code-graph database. Use when the user wants to refresh the code graph, e.g. after major changes or when graph seems stale.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Rebuild or update the code-graph database. Use when the user wants to refresh the code graph, e.g. after major changes or when graph seems stale.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Initialize a new project with the copilot template. Interactive setup that auto-detects the tech stack and fills in all template placeholders.
Start work on a new ticket. Runs pre-flight checks, investigates the codebase, and flows into OpenSpec proposal. Use when the user pastes a ticket, issue, or task description.
Implement tasks from an OpenSpec change. Use when the user wants to start or continue implementing a proposed change.
Archive a completed change. Use when implementation is done and the change is ready to be moved to the archive.
Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.
Propose a new change with all artifacts generated in one step. Use when the user wants to describe what they want to build and get a complete proposal with specs and tasks ready for implementation.
基于 SOC 职业分类
| name | rebuild-code-graph |
| description | Rebuild or update the code-graph database. Use when the user wants to refresh the code graph, e.g. after major changes or when graph seems stale. |
| argument-hint | "build" for full rebuild (default), "update" for incremental update. |
| license | MIT |
| metadata | {"author":"copilot-template","version":"1.0"} |
Rebuild or incrementally update the .code-graph/graph.db SQLite database.
IMPORTANT: This skill runs commands. Follow every step in order. Do not skip error handling.
Find server.py — it could be in several locations depending on the project setup:
.github/code-graph/server.py # standard location
copilot-template/.github/code-graph/server.py # monorepo with template as submodule
Search for it:
find . -path "*/code-graph/server.py" -not -path "*/node_modules/*" 2>/dev/null | head -5
If not found: stop and tell the user:
"No code-graph tooling found. Run the
initialize-projectskill to set it up, or copy.github/code-graph/from the copilot-template."
If multiple found: use the one closest to the current working directory (shortest path). Report which one you're using.
Store the resolved path as $SERVER_PY.
python3 --version 2>/dev/null || python --version 2>/dev/null
If neither works: stop and tell the user Python 3.10+ is required.
If version is below 3.10: stop and tell the user Python 3.10+ is required.
Store the working Python command as $PYTHON (python3 preferred over python).
--update--build.code-graph/graph.db does not exist → always use --build (update requires an existing db)Execute from the project root (the directory where .code-graph/ should be created):
cd <project-root> && $PYTHON $SERVER_PY <--build or --update>
Expected success output includes lines like:
Detected stacks: java, structuredGraph built: N files -> .code-graph/graph.db (X.XXs)or for update:
Graph updated: updated N, dependents M, deleted DGraph up to date — no changes detected.Confirm the database exists and has data:
$PYTHON -c "
import sqlite3, os
db = '<project-root>/.code-graph/graph.db'
if not os.path.exists(db):
print('ERROR: graph.db was not created')
exit(1)
conn = sqlite3.connect(db)
nodes = conn.execute('SELECT COUNT(*) FROM nodes').fetchone()[0]
edges = conn.execute('SELECT COUNT(*) FROM edges').fetchone()[0]
stacks = conn.execute(\"SELECT value FROM meta WHERE key='stacks'\").fetchone()
print(f'Graph OK: {nodes:,} nodes, {edges:,} edges')
if stacks: print(f'Stacks: {stacks[0]}')
conn.close()
"
If nodes is 0: warn the user — the builder may not have detected the tech stack. Ask them to check if the project has recognizable stack markers (pom.xml, package.json, go.mod, etc.).
Tell the user:
If the build command fails:
ModuleNotFoundError: No module named 'parsers' — the script was run from the wrong directory. Ensure $PYTHON runs $SERVER_PY with the server.py's parent directory containing parsers/. The --build flag does NOT require mcp.
FileNotFoundError or permission errors — check the project root path is correct and writable.
Empty output / no files parsed — the stack detection found no recognized files. Check that the project root is correct (not a subdirectory).
Any other error — show the full error output to the user and suggest running manually:
cd <project-root> && uv run --with-requirements .github/code-graph/requirements.txt .github/code-graph/server.py --build