QRSPI: Worktree
Context
Create an isolated git worktree for implementation and parse the plan into a machine-readable task list. This keeps the main workspace clean while the feature is being built, and gives the implement phase a structured task file to track progress slice by slice.
Prerequisites
- Phase
plan must be complete (check manifest.json)
Instructions
Locate the active spec directory:
source ~/.copilot/scripts/qrspi-utils.sh && qrspi_find_active_spec
If the user names a specific feature, use qrspi_spec_dir <feature-name> instead.
Read manifest.json and verify plan phase is complete:
source ~/.copilot/scripts/qrspi-utils.sh && qrspi_check_prereq <spec-dir> plan
Read the branch name and feature name from manifest.json.
Read plan.md from the spec directory.
Exception — skip the worktree entirely: Only if the user has explicitly stated they want to implement in-place on the current branch/checkout (e.g. "don't create a worktree", "implement here", "use my current branch") — skip straight to step 13, using the current working directory in place of {worktree-path} (i.e. write tasks.json to .copilot-qrspi-active/tasks.json in the repo root instead of a separate worktree, and skip branch/worktree creation). Never infer this on your own; only act on an explicit statement.
Determine the worktree path. By default:
repo=$(source ~/.copilot/scripts/qrspi-utils.sh && qrspi_repo_name)
worktree_path="../${repo}-${feature_name}"
Present the proposed worktree path to the user for confirmation or override.
Wait for user confirmation of the worktree location.
Ensure the branch exists:
git branch --list {branch-name}
If it doesn't exist, create it: git branch {branch-name}
Create the git worktree:
git worktree add {worktree-path} {branch-name}
Copy the spec directory into the worktree so artifacts are accessible during implementation:
mkdir -p {worktree-path}/.copilot-qrspi-active
cp -r <spec-dir>/* {worktree-path}/.copilot-qrspi-active/
Parse plan.md into a structured tasks.json file. Extract each slice and its steps:
{
"feature": "{feature-name}",
"repo": "{repo}",
"worktree": "{worktree-path}",
"slices": [
{
"name": "Slice 1: {slice name}",
"status": "pending",
"steps": [
"Step 1 description",
"Step 2 description"
],
"tests": ["path/to/test.ts — description"],
"checkpoint": {
"commands": ["npm test -- --grep slice-1"],
"passed": false
}
}
],
"current_slice": 0
}
If plan.md includes a Shared Setup section, include it as a special first entry in the slices array with "name": "Shared Setup".
Write tasks.json to {worktree-path}/.copilot-qrspi-active/tasks.json (or, in the in-place exception from step 5, to .copilot-qrspi-active/tasks.json in the current directory).
Update manifest.json in the original spec directory:
source ~/.copilot/scripts/qrspi-utils.sh && qrspi_update_manifest <spec-dir> worktree complete
Present to the user:
- Worktree path and how to
cd into it (or, if run in-place, confirm work will continue in the current directory)
- Task breakdown summary (number of slices, total steps)
- Instructions: "Open a new session in the worktree directory and invoke the qrspi-implement skill to start building" (or "run the qrspi-implement skill now" if in-place)
Output Format
tasks.json: JSON object as specified in step 11.
The worktree will contain:
{worktree-path}/
├── .copilot-qrspi-active/
│ ├── ticket.md
│ ├── manifest.json
│ ├── questions.md
│ ├── research.md
│ ├── design.md
│ ├── structure.md
│ ├── plan.md
│ └── tasks.json
├── (all repo files on the feature branch)
Human Checkpoint
Confirm the worktree location before creation. Optionally review the task breakdown. The user may adjust the worktree path if the default conflicts with their workspace layout.
1---2name: qrspi-worktree3description: QRSPI Phase 6: Worktree — Create a git worktree and machine-readable task hierarchy for implementation. Use when the user has completed qrspi-plan and wants to move to worktree, or explicitly says 'qrspi worktree'.4---56# QRSPI: Worktree78## Context910Create an isolated git worktree for implementation and parse the plan into a machine-readable task list. This keeps the main workspace clean while the feature is being built, and gives the implement phase a structured task file to track progress slice by slice.1112## Prerequisites1314- Phase `plan` must be complete (check manifest.json)1516## Instructions17181. Locate the active spec directory:19 ```bash20 source ~/.copilot/scripts/qrspi-utils.sh && qrspi_find_active_spec21 ```22 If the user names a specific feature, use `qrspi_spec_dir <feature-name>` instead.23242. Read `manifest.json` and verify `plan` phase is complete:25 ```bash26 source ~/.copilot/scripts/qrspi-utils.sh && qrspi_check_prereq <spec-dir> plan27 ```28293. Read the branch name and feature name from `manifest.json`.30314. Read `plan.md` from the spec directory.32335. **Exception — skip the worktree entirely:** Only if the user has explicitly stated they want to implement in-place on the current branch/checkout (e.g. "don't create a worktree", "implement here", "use my current branch") — skip straight to step 13, using the current working directory in place of `{worktree-path}` (i.e. write `tasks.json` to `.copilot-qrspi-active/tasks.json` in the repo root instead of a separate worktree, and skip branch/worktree creation). Never infer this on your own; only act on an explicit statement.34356. Determine the worktree path. By default:36 ```bash37 repo=$(source ~/.copilot/scripts/qrspi-utils.sh && qrspi_repo_name)38 worktree_path="../${repo}-${feature_name}"39 ```40 Present the proposed worktree path to the user for confirmation or override.41427. Wait for user confirmation of the worktree location.43448. Ensure the branch exists:45 ```bash46 git branch --list {branch-name}47 ```48 If it doesn't exist, create it: `git branch {branch-name}`49509. Create the git worktree:51 ```bash52 git worktree add {worktree-path} {branch-name}53 ```545510. Copy the spec directory into the worktree so artifacts are accessible during implementation:56 ```bash57 mkdir -p {worktree-path}/.copilot-qrspi-active58 cp -r <spec-dir>/* {worktree-path}/.copilot-qrspi-active/59 ```606111. Parse `plan.md` into a structured `tasks.json` file. Extract each slice and its steps:62 ```json63 {64 "feature": "{feature-name}",65 "repo": "{repo}",66 "worktree": "{worktree-path}",67 "slices": [68 {69 "name": "Slice 1: {slice name}",70 "status": "pending",71 "steps": [72 "Step 1 description",73 "Step 2 description"74 ],75 "tests": ["path/to/test.ts — description"],76 "checkpoint": {77 "commands": ["npm test -- --grep slice-1"],78 "passed": false79 }80 }81 ],82 "current_slice": 083 }84 ```858612. If `plan.md` includes a **Shared Setup** section, include it as a special first entry in the slices array with `"name": "Shared Setup"`.878813. Write `tasks.json` to `{worktree-path}/.copilot-qrspi-active/tasks.json` (or, in the in-place exception from step 5, to `.copilot-qrspi-active/tasks.json` in the current directory).899014. Update `manifest.json` in the original spec directory:91 ```bash92 source ~/.copilot/scripts/qrspi-utils.sh && qrspi_update_manifest <spec-dir> worktree complete93 ```949515. Present to the user:96 - Worktree path and how to `cd` into it (or, if run in-place, confirm work will continue in the current directory)97 - Task breakdown summary (number of slices, total steps)98 - Instructions: "Open a new session in the worktree directory and invoke the qrspi-implement skill to start building" (or "run the qrspi-implement skill now" if in-place)99100## Output Format101102**tasks.json:** JSON object as specified in step 11.103104The worktree will contain:105```106{worktree-path}/107├── .copilot-qrspi-active/108│ ├── ticket.md109│ ├── manifest.json110│ ├── questions.md111│ ├── research.md112│ ├── design.md113│ ├── structure.md114│ ├── plan.md115│ └── tasks.json116├── (all repo files on the feature branch)117```118119## Human Checkpoint120121Confirm the worktree location before creation. Optionally review the task breakdown. The user may adjust the worktree path if the default conflicts with their workspace layout.