一键导入
initialize-project
Initialize a new project with the copilot template. Interactive setup that auto-detects the tech stack and fills in all template placeholders.
用 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.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
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.
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.
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 | initialize-project |
| description | Initialize a new project with the copilot template. Interactive setup that auto-detects the tech stack and fills in all template placeholders. |
| argument-hint | Target project path (optional — will ask if not provided). |
| license | MIT |
| metadata | {"author":"copilot-template","version":"1.0"} |
Initialize a new project with this copilot template. Auto-detect the tech stack from the target repo and fill in all template placeholders.
Ask the user these questions one at a time (wait for each answer before proceeding):
CLAUDE.md, .claude/commands/).github/agents/, .github/skills/, .github/prompts/, AGENTS.md).github/copilot-instructions.md and .github/instructions/ are always copied — both tools read them.yes (recommended for projects with 10+ files), no.github/code-graph/ and wired into the AI tool(s) selected in question 2 — no external package install required beyond mcp>=1.0.0.uv is recommended (auto-installs deps); pip works too.yes.yes, noyes, ask for additional paths (optional). Include .code-graph/ by default.Investigate the TARGET project to auto-detect as much as possible. Read these files if they exist:
README.md — project description, setup instructions, architecturepackage.json — Node.js deps, scriptstsconfig.json / jsconfig.json — TypeScript/JS configCargo.toml — Rustgo.mod — Gopyproject.toml, setup.py, requirements.txt — Pythonpom.xml, build.gradle — Java/KotlinGemfile — Ruby.eslintrc*, .prettierrc*, biome.json — linter/formatterdocker-compose.yml, Dockerfile — infrastructure hintsMakefile — build commandssrc/ directory listing — project structureExtract:
Present findings in a summary table and ask the user to confirm or correct before proceeding.
Copy files from the copilot-template repo to the target project. Only copy what's relevant to the tools selected in Step 1.
Always copy (shared conventions used by both tools):
.github/copilot-instructions.md (CLAUDE.md pre-flight + on-demand reads depend on this).github/instructions/ (all instruction .md files — testing, styling, etc.)openspec/config.yaml (create openspec/ dir if needed)For VS Code Copilot:
.github/agents/ (all agent .md files).github/skills/ (all skill directories including initialize-project/ — the target project can use it to initialize other projects later).github/prompts/ (all prompt .md files)AGENTS.mdFor Claude Code:
CLAUDE.md.claude/commands/project/ (all command files EXCEPT initialize.md).claude/hooks/ (all hook scripts — block-generated, log-bash, report-graph, warn-scope).claude/settings.json (wires the hooks into Claude Code lifecycle events).claude/settings.local.json — that's per-machine personal overridesFor both: all of the above (Always + VS Code + Claude Code lists).
Do NOT overwrite existing files without asking. If a file exists, show both versions side by side (existing vs template) and ask the user how to proceed:
Do NOT attempt automatic merging — the risk of duplicated or corrupted content is too high.
Using the detected info from Step 2, replace all _TBD_ placeholders and <!-- FILL: ... --> comment blocks in the copied files.
In .github/copilot-instructions.md:
<!-- FILL: ... --> comments after filling## Project-Specific Rules (create concise bullet points; do not duplicate existing global rules)In CLAUDE.md:
In AGENTS.md:
_TBD_ or <!-- FILL markersAskUserQuestion, TodoWrite, replace_string_in_file, multi_replace_string_in_file) and replace with runtime-supported names where neededRun this step only if the user selected yes in Step 1 question 5.
Copy .github/code-graph/ from the copilot-template to the target project.
This includes:
builder.py — parses source files into SQLiteserver.py — MCP server exposing tools to the AI assistantvisualize.py — generates standalone HTML graph visualizationparsers/ — per-language parser modules (regex + tree-sitter)package.json — d3 dependency for visualizationrequirements.txt — mcp>=1.0.0 plus optional tree-sitter language packagespost-commit / post-merge / post-rewrite — optional git hooks for automatic graph updatesDo NOT copy node_modules/ — it will be installed in the next step.
cd <target-project>/.github/code-graph && npm install
This installs d3 (used by visualize.py to generate offline-capable HTML graphs).
uv is installeduv is the recommended way to run the MCP server (auto-installs Python deps without polluting the system).
Check availability:
command -v uv
If uv is not found, install it automatically:
curl -LsSf https://astral.sh/uv/install.sh | sh
After install, ensure ~/.local/bin (or the printed install path) is on $PATH for the current session:
export PATH="$HOME/.local/bin:$PATH"
Verify:
uv --version
Do NOT ask the user to install uv manually — install it automatically and report the result.
If the install script fails (e.g. no internet, corporate proxy), fall back to pip install 'mcp>=1.0.0' and use python instead of uv in MCP configs.
.code-graph/ to .gitignoreAppend .code-graph/ to the target project's .gitignore if not already present.
Also ensure node_modules/ is in .gitignore (usually already present).
The graph database is local/generated — it must not be committed.
By this point uv should be installed (step 6c). If step 6c fell back to pip, use "command": "python" and "args": ["${workspaceFolder}/.github/code-graph/server.py"] in all configs below instead of the uv variant.
VS Code Copilot → create or merge into .vscode/mcp.json:
{
"servers": {
"code-graph": {
"type": "stdio",
"command": "uv",
"args": ["run", "--with-requirements", "${workspaceFolder}/.github/code-graph/requirements.txt", "${workspaceFolder}/.github/code-graph/server.py"]
}
}
}
Claude Code → create or merge into .mcp.json at repo root:
{
"mcpServers": {
"code-graph": {
"type": "stdio",
"command": "uv",
"args": ["run", "--with-requirements", ".github/code-graph/requirements.txt", ".github/code-graph/server.py"]
}
}
}
Cursor → create or merge into .cursor/mcp.json:
{
"mcpServers": {
"code-graph": {
"type": "stdio",
"command": "uv",
"args": ["run", "--with-requirements", ".github/code-graph/requirements.txt", ".github/code-graph/server.py"]
}
}
}
If Both was selected in Step 1, write all applicable configs.
Do NOT overwrite existing MCP configs — merge code-graph key into the servers/mcpServers object.
The --build flag does NOT require the mcp package. Tree-sitter packages (installed via requirements.txt) are used automatically where available and fall back to regex parsers otherwise.
Run in the target project root:
uv run --with-requirements .github/code-graph/requirements.txt .github/code-graph/server.py --build
Expected output includes timed progress per phase, ending with:
Graph built: N files → .code-graph/graph.db (X.XXs)
If the build fails:
python --version--build path does NOT import MCP — if you see an mcp error, something else is wrong.Confirm .code-graph/graph.db exists. Report the file size and build time to the user as confirmation.
Ask the user a Yes/No question:
Install git hooks? — "Auto-update the code graph on commit, merge, and rebase?" Options:
Yes(recommended),No
If the user selects No, skip to 6i.
If the user selects Yes:
GIT_DIR=$(git -C <target-project> rev-parse --git-dir)
mkdir -p "$GIT_DIR/hooks"
cp <target-project>/.github/code-graph/post-commit "$GIT_DIR/hooks/post-commit"
cp <target-project>/.github/code-graph/post-merge "$GIT_DIR/hooks/post-merge"
cp <target-project>/.github/code-graph/post-rewrite "$GIT_DIR/hooks/post-rewrite"
chmod +x "$GIT_DIR/hooks/post-commit" "$GIT_DIR/hooks/post-merge" "$GIT_DIR/hooks/post-rewrite"
Each hook runs:
uv run --with-requirements .github/code-graph/requirements.txt .github/code-graph/server.py --update
(Falls back to python .github/code-graph/server.py --update if uv is unavailable.)
Behavior:
.code-graph/graph.db does not exist yet, the hook exits silently..git/hooks/ is not committed), so each developer installs it once.git fetch alone does not update the graph because it does not change the checked-out files..git/ is above the target project root.Run this only if Step 1 question 6 is yes.
git config --global core.excludesfile
~/.config/git/ignore and set it:git config --global core.excludesfile "$HOME/.config/git/ignore"
mkdir -p "$HOME/.config/git"
touch "$HOME/.config/git/ignore"
.code-graph/ and any user-provided local-only folder entries if missing.The copied agent files already include a mandatory "Step 0 — Orient with Code-Graph" section with HARD-RULE wording (code-graph first, non-negotiable, only fall back when the DB is genuinely absent).
Verify it is present in the target project by grepping each agent file for the literal string MANDATORY — non-negotiable:
grep -L "MANDATORY — non-negotiable" <target>/.github/agents/*.agent.md
Files returned (missing the marker) need the block restored — copy the Step 0 block from the matching file in copilot-template/.github/agents/ verbatim. Do not improvise the wording; the literal HARD RULE phrasing is what enforces the rule.
Register the target project so future git pull updates in copilot-template auto-propagate.
projects.json in the copilot-template root (create with {"projects": []} if missing).{
"path": "<absolute-path-to-target-project>",
"tools": ["claude", "vscode"],
"code_graph": true,
"registered_at": "YYYY-MM-DD"
}
Set tools to match what was selected in Step 1, code_graph to match Step 1 question 5, and registered_at to today's date.projects.json back../setup.sh in the copilot-template root to ensure git hooks are configured for auto-sync:
cd <copilot-template-path> && ./setup.sh
After setup, every git pull in copilot-template will automatically sync updated agents, skills, commands, code-graph files, and .mcp.json to all registered projects — and rebuild their graphs if code_graph: true.CLAUDE.md or copilot-instructions.md, warn and ask (merge/overwrite/skip)._TBD_ and <!-- FILL markers in copied instruction files..code-graph/graph.db exists in the target project and at least one MCP config file has been written.