codebyplan 1.5.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/cli.js +4462 -748
  2. package/package.json +5 -1
  3. package/templates/.gitkeep +0 -0
  4. package/templates/README.md +20 -0
  5. package/templates/agents/cbp-cc-executor.md +213 -0
  6. package/templates/agents/cbp-database-agent.md +229 -0
  7. package/templates/agents/cbp-improve-claude.md +245 -0
  8. package/templates/agents/cbp-improve-round.md +284 -0
  9. package/templates/agents/cbp-mechanical-edits.md +111 -0
  10. package/templates/agents/cbp-research.md +282 -0
  11. package/templates/agents/cbp-round-executor.md +604 -0
  12. package/templates/agents/cbp-security-agent.md +134 -0
  13. package/templates/agents/cbp-task-check.md +213 -0
  14. package/templates/agents/cbp-task-planner.md +582 -0
  15. package/templates/agents/cbp-test-e2e-agent.md +363 -0
  16. package/templates/agents/cbp-testing-qa-agent.md +400 -0
  17. package/templates/context/mcp-docs.md +139 -0
  18. package/templates/hooks/README.md +236 -0
  19. package/templates/hooks/cbp-auto-test-hooks.sh +44 -0
  20. package/templates/hooks/cbp-lint-format-on-edit.sh +159 -0
  21. package/templates/hooks/cbp-maestro-yaml-validate.sh +100 -0
  22. package/templates/hooks/cbp-mcp-migration-guard.sh +32 -0
  23. package/templates/hooks/cbp-mcp-round-sync.sh +79 -0
  24. package/templates/hooks/cbp-mcp-worktree-inject.sh +76 -0
  25. package/templates/hooks/cbp-notify.sh +68 -0
  26. package/templates/hooks/cbp-plugin-dispatch.sh +29 -0
  27. package/templates/hooks/cbp-pre-commit-quality-gate.sh +204 -0
  28. package/templates/hooks/cbp-statusline.sh +347 -0
  29. package/templates/hooks/cbp-subagent-statusline.sh +182 -0
  30. package/templates/hooks/cbp-test-coverage-gate.sh +144 -0
  31. package/templates/hooks/cbp-test-hooks.sh +320 -0
  32. package/templates/hooks/hooks.json +85 -0
  33. package/templates/hooks/validate-context-usage.sh +59 -0
  34. package/templates/hooks/validate-git-commit.sh +78 -0
  35. package/templates/hooks/validate-git-stash-deny.sh +32 -0
  36. package/templates/hooks/validate-structure-lengths.sh +57 -0
  37. package/templates/hooks/validate-structure-lib.sh +104 -0
  38. package/templates/hooks/validate-structure-patterns.sh +54 -0
  39. package/templates/hooks/validate-structure-scope.sh +33 -0
  40. package/templates/hooks/validate-structure-smoke.sh +95 -0
  41. package/templates/hooks/validate-structure-templates.sh +34 -0
  42. package/templates/hooks/validate-structure.sh +69 -0
  43. package/templates/rules/.gitkeep +0 -0
  44. package/templates/rules/README.md +47 -0
  45. package/templates/rules/context-file-loading.md +52 -0
  46. package/templates/rules/scope-vocabulary.md +64 -0
  47. package/templates/rules/todo-backend.md +109 -0
  48. package/templates/settings.project.base.json +55 -0
  49. package/templates/settings.user.base.json +25 -0
  50. package/templates/skills/cbp-build-cc-agent/SKILL.md +139 -0
  51. package/templates/skills/cbp-build-cc-agent/examples/read-only-reviewer.md +32 -0
  52. package/templates/skills/cbp-build-cc-agent/examples/with-hooks.md +41 -0
  53. package/templates/skills/cbp-build-cc-agent/examples/with-skills-preload.md +25 -0
  54. package/templates/skills/cbp-build-cc-agent/reference/cbp-quality.md +153 -0
  55. package/templates/skills/cbp-build-cc-agent/reference/frontmatter-fields.md +37 -0
  56. package/templates/skills/cbp-build-cc-agent/reference/permission-modes.md +18 -0
  57. package/templates/skills/cbp-build-cc-agent/scripts/validate-agent.sh +67 -0
  58. package/templates/skills/cbp-build-cc-agent/templates/agent.md +66 -0
  59. package/templates/skills/cbp-build-cc-claude-file/SKILL.md +178 -0
  60. package/templates/skills/cbp-build-cc-claude-file/examples/minimal-project.md +33 -0
  61. package/templates/skills/cbp-build-cc-claude-file/examples/monorepo-with-imports.md +39 -0
  62. package/templates/skills/cbp-build-cc-claude-file/reference/imports.md +72 -0
  63. package/templates/skills/cbp-build-cc-claude-file/reference/what-belongs.md +39 -0
  64. package/templates/skills/cbp-build-cc-claude-file/templates/project-claude-md.md +48 -0
  65. package/templates/skills/cbp-build-cc-claude-file/templates/user-claude-md.md +22 -0
  66. package/templates/skills/cbp-build-cc-memory/SKILL.md +201 -0
  67. package/templates/skills/cbp-build-cc-memory/examples/feedback-memory.md +11 -0
  68. package/templates/skills/cbp-build-cc-memory/examples/project-memory.md +11 -0
  69. package/templates/skills/cbp-build-cc-memory/examples/reference-memory.md +13 -0
  70. package/templates/skills/cbp-build-cc-memory/examples/user-memory.md +14 -0
  71. package/templates/skills/cbp-build-cc-memory/reference/memory-types.md +59 -0
  72. package/templates/skills/cbp-build-cc-memory/reference/when-to-save.md +62 -0
  73. package/templates/skills/cbp-build-cc-memory/templates/MEMORY-index.md +4 -0
  74. package/templates/skills/cbp-build-cc-memory/templates/memory-entry.md +15 -0
  75. package/templates/skills/cbp-build-cc-mode/SKILL.md +99 -0
  76. package/templates/skills/cbp-build-cc-rule/SKILL.md +176 -0
  77. package/templates/skills/cbp-build-cc-rule/examples/global-rule.md +19 -0
  78. package/templates/skills/cbp-build-cc-rule/examples/scoped-rule.md +41 -0
  79. package/templates/skills/cbp-build-cc-rule/reference/paths-patterns.md +48 -0
  80. package/templates/skills/cbp-build-cc-rule/templates/rule.md +32 -0
  81. package/templates/skills/cbp-build-cc-settings/SKILL.md +220 -0
  82. package/templates/skills/cbp-build-cc-settings/examples/hooks-config.json +64 -0
  83. package/templates/skills/cbp-build-cc-settings/examples/permissions-config.json +34 -0
  84. package/templates/skills/cbp-build-cc-settings/examples/sandbox-config.json +42 -0
  85. package/templates/skills/cbp-build-cc-settings/reference/cbp-conventions.md +104 -0
  86. package/templates/skills/cbp-build-cc-settings/reference/permission-rules.md +61 -0
  87. package/templates/skills/cbp-build-cc-settings/reference/scope-precedence.md +73 -0
  88. package/templates/skills/cbp-build-cc-settings/reference/settings-fields.md +166 -0
  89. package/templates/skills/cbp-build-cc-settings/templates/settings.json +23 -0
  90. package/templates/skills/cbp-build-cc-settings/templates/settings.local.json +10 -0
  91. package/templates/skills/cbp-build-cc-skill/SKILL.md +154 -0
  92. package/templates/skills/cbp-build-cc-skill/examples/dynamic-context.md +31 -0
  93. package/templates/skills/cbp-build-cc-skill/examples/fork-skill.md +22 -0
  94. package/templates/skills/cbp-build-cc-skill/examples/knowledge-skill.md +25 -0
  95. package/templates/skills/cbp-build-cc-skill/examples/task-skill.md +29 -0
  96. package/templates/skills/cbp-build-cc-skill/reference/cbp-quality.md +157 -0
  97. package/templates/skills/cbp-build-cc-skill/reference/frontmatter-fields.md +35 -0
  98. package/templates/skills/cbp-build-cc-skill/reference/string-substitutions.md +60 -0
  99. package/templates/skills/cbp-build-cc-skill/scripts/validate-skill.sh +90 -0
  100. package/templates/skills/cbp-build-cc-skill/templates/skill.md +51 -0
  101. package/templates/skills/cbp-checkpoint-check/SKILL.md +156 -0
  102. package/templates/skills/cbp-checkpoint-complete/SKILL.md +109 -0
  103. package/templates/skills/cbp-checkpoint-create/SKILL.md +116 -0
  104. package/templates/skills/cbp-checkpoint-end/SKILL.md +241 -0
  105. package/templates/skills/cbp-checkpoint-plan/SKILL.md +137 -0
  106. package/templates/skills/cbp-checkpoint-plan/reference/alternative-comparison-template.md +54 -0
  107. package/templates/skills/cbp-checkpoint-plan/reference/dep-decision-rubric.md +50 -0
  108. package/templates/skills/cbp-checkpoint-plan/reference/e2e-discovery-probe.md +57 -0
  109. package/templates/skills/cbp-checkpoint-plan/reference/gap-analysis-playbook.md +47 -0
  110. package/templates/skills/cbp-checkpoint-start/SKILL.md +84 -0
  111. package/templates/skills/cbp-checkpoint-update/SKILL.md +115 -0
  112. package/templates/skills/cbp-frontend-a11y/SKILL.md +109 -0
  113. package/templates/skills/cbp-frontend-a11y/reference/aria-roles-states.md +130 -0
  114. package/templates/skills/cbp-frontend-a11y/reference/contrast-visual.md +122 -0
  115. package/templates/skills/cbp-frontend-a11y/reference/keyboard-patterns.md +154 -0
  116. package/templates/skills/cbp-frontend-a11y/reference/semantic-html.md +111 -0
  117. package/templates/skills/cbp-frontend-design/SKILL.md +145 -0
  118. package/templates/skills/cbp-frontend-design/reference/nextjs-scss.md +118 -0
  119. package/templates/skills/cbp-frontend-design/reference/rn-expo.md +101 -0
  120. package/templates/skills/cbp-frontend-design/reference/tauri-react.md +82 -0
  121. package/templates/skills/cbp-frontend-ui/SKILL.md +262 -0
  122. package/templates/skills/cbp-frontend-ui/reference/ui-label-maps.md +42 -0
  123. package/templates/skills/cbp-frontend-ui/reference/ui-layout-patterns.md +105 -0
  124. package/templates/skills/cbp-frontend-ui/reference/variant-defaults.md +149 -0
  125. package/templates/skills/cbp-frontend-ux/SKILL.md +181 -0
  126. package/templates/skills/cbp-git-branch-feat-create/SKILL.md +115 -0
  127. package/templates/skills/cbp-git-commit/SKILL.md +278 -0
  128. package/templates/skills/cbp-git-worktree-create/SKILL.md +226 -0
  129. package/templates/skills/cbp-git-worktree-remove/SKILL.md +145 -0
  130. package/templates/skills/cbp-merge-main/SKILL.md +228 -0
  131. package/templates/skills/cbp-round-check/SKILL.md +104 -0
  132. package/templates/skills/cbp-round-end/SKILL.md +183 -0
  133. package/templates/skills/cbp-round-end/reference/findings-presentation.md +44 -0
  134. package/templates/skills/cbp-round-end/reference/inline-fallback.md +35 -0
  135. package/templates/skills/cbp-round-execute/SKILL.md +211 -0
  136. package/templates/skills/cbp-round-execute/reference/inline-fallback.md +59 -0
  137. package/templates/skills/cbp-round-input/SKILL.md +165 -0
  138. package/templates/skills/cbp-round-start/SKILL.md +222 -0
  139. package/templates/skills/cbp-round-update/SKILL.md +163 -0
  140. package/templates/skills/cbp-session-end/SKILL.md +187 -0
  141. package/templates/skills/cbp-session-start/SKILL.md +155 -0
  142. package/templates/skills/cbp-ship/SKILL.md +332 -0
  143. package/templates/skills/cbp-ship/reference/changesets-overview.md +120 -0
  144. package/templates/skills/cbp-ship/reference/eas-cli-overview.md +60 -0
  145. package/templates/skills/cbp-ship/reference/gh-cli-overview.md +135 -0
  146. package/templates/skills/cbp-ship/reference/gh-cli-shipment-commands.md +283 -0
  147. package/templates/skills/cbp-ship/reference/npm-publish-monorepo.md +252 -0
  148. package/templates/skills/cbp-ship/reference/npm-publish-oidc-trusted.md +157 -0
  149. package/templates/skills/cbp-ship/reference/npm-publish-overview.md +171 -0
  150. package/templates/skills/cbp-ship/reference/preflight-checklist.md +88 -0
  151. package/templates/skills/cbp-ship/reference/railway-nestjs-deployment.md +169 -0
  152. package/templates/skills/cbp-ship/reference/railway-overview.md +120 -0
  153. package/templates/skills/cbp-ship/reference/railway-troubleshooting.md +168 -0
  154. package/templates/skills/cbp-ship/reference/release-please-overview.md +99 -0
  155. package/templates/skills/cbp-ship/reference/surface-expo-eas.md +155 -0
  156. package/templates/skills/cbp-ship/reference/surface-npm.md +180 -0
  157. package/templates/skills/cbp-ship/reference/surface-railway.md +152 -0
  158. package/templates/skills/cbp-ship/reference/surface-supabase.md +178 -0
  159. package/templates/skills/cbp-ship/reference/surface-tauri.md +138 -0
  160. package/templates/skills/cbp-ship/reference/surface-vercel.md +124 -0
  161. package/templates/skills/cbp-ship/reference/surface-vscode-ext.md +144 -0
  162. package/templates/skills/cbp-ship/reference/surfaces.md +60 -0
  163. package/templates/skills/cbp-ship/reference/testflight-automation.md +215 -0
  164. package/templates/skills/cbp-ship/reference/testflight-internal-vs-external.md +69 -0
  165. package/templates/skills/cbp-ship/reference/testflight-overview.md +98 -0
  166. package/templates/skills/cbp-ship/reference/versioning.md +116 -0
  167. package/templates/skills/cbp-ship/scripts/detect-surfaces.sh +217 -0
  168. package/templates/skills/cbp-ship/scripts/verify-expo-eas.sh +35 -0
  169. package/templates/skills/cbp-ship/scripts/verify-npm.sh +21 -0
  170. package/templates/skills/cbp-ship/scripts/verify-railway.sh +41 -0
  171. package/templates/skills/cbp-ship/scripts/verify-supabase.sh +19 -0
  172. package/templates/skills/cbp-ship/scripts/verify-tauri.sh +24 -0
  173. package/templates/skills/cbp-ship/scripts/verify-vercel.sh +32 -0
  174. package/templates/skills/cbp-ship/scripts/verify-vscode-ext.sh +25 -0
  175. package/templates/skills/cbp-ship/templates/eas.json +66 -0
  176. package/templates/skills/cbp-ship/templates/railway.toml +15 -0
  177. package/templates/skills/cbp-ship/templates/release-please-config.json +17 -0
  178. package/templates/skills/cbp-ship/templates/vercel.json +19 -0
  179. package/templates/skills/cbp-ship/templates/vscodeignore +21 -0
  180. package/templates/skills/cbp-ship/templates/workflow-changesets.yml +41 -0
  181. package/templates/skills/cbp-ship/templates/workflow-eas-submit.yml +53 -0
  182. package/templates/skills/cbp-ship/templates/workflow-npm-publish.yml +36 -0
  183. package/templates/skills/cbp-ship/templates/workflow-release-please.yml +21 -0
  184. package/templates/skills/cbp-ship/templates/workflow-tauri-release.yml +69 -0
  185. package/templates/skills/cbp-ship/templates/workflow-vsce-publish.yml +31 -0
  186. package/templates/skills/cbp-ship-configure/SKILL.md +296 -0
  187. package/templates/skills/cbp-ship-configure/reference/expo-mobile.md +204 -0
  188. package/templates/skills/cbp-ship-configure/reference/npm-package.md +165 -0
  189. package/templates/skills/cbp-ship-configure/reference/railway-backend.md +199 -0
  190. package/templates/skills/cbp-ship-configure/reference/supabase.md +200 -0
  191. package/templates/skills/cbp-ship-configure/reference/tauri-desktop.md +181 -0
  192. package/templates/skills/cbp-ship-configure/reference/vercel.md +117 -0
  193. package/templates/skills/cbp-ship-configure/reference/vscode-ext.md +155 -0
  194. package/templates/skills/cbp-ship-main/SKILL.md +65 -0
  195. package/templates/skills/cbp-supabase-branch-check/SKILL.md +337 -0
  196. package/templates/skills/cbp-supabase-branch-check/reference/dag-steps.md +29 -0
  197. package/templates/skills/cbp-supabase-migrate/SKILL.md +314 -0
  198. package/templates/skills/cbp-supabase-migrate/reference/advisor-triage.md +70 -0
  199. package/templates/skills/cbp-supabase-migrate/reference/cli-fallback.md +87 -0
  200. package/templates/skills/cbp-supabase-migrate/reference/preflight-dry-run.md +58 -0
  201. package/templates/skills/cbp-supabase-setup/SKILL.md +239 -0
  202. package/templates/skills/cbp-supabase-setup/reference/branching-setup.md +121 -0
  203. package/templates/skills/cbp-supabase-setup/reference/cli-fallback.md +109 -0
  204. package/templates/skills/cbp-task-check/SKILL.md +166 -0
  205. package/templates/skills/cbp-task-complete/SKILL.md +206 -0
  206. package/templates/skills/cbp-task-complete/reference/checkpoint-done-branching.md +48 -0
  207. package/templates/skills/cbp-task-complete/reference/next-step-heuristic.md +56 -0
  208. package/templates/skills/cbp-task-create/SKILL.md +167 -0
  209. package/templates/skills/cbp-task-start/SKILL.md +239 -0
  210. package/templates/skills/cbp-task-testing/SKILL.md +277 -0
  211. package/templates/skills/cbp-todo/SKILL.md +111 -0
@@ -0,0 +1,278 @@
1
+ ---
2
+ scope: org-shared
3
+ name: cbp-git-commit
4
+ description: Create scoped commit with conventional format
5
+ argument-hint: "[--task|--all] [type]: [description]"
6
+ effort: low
7
+ ---
8
+
9
+ # Git Commit Command
10
+
11
+ Create a commit using conventional commits format, then push to origin.
12
+
13
+ ## When to Use
14
+
15
+ - Called by `/cbp-session-end` after files are staged
16
+ - Direct use when user provides explicit commit message
17
+
18
+ ## Arguments
19
+
20
+ `$ARGUMENTS`: [options] [type]: [description]
21
+
22
+ **Scope Flags (one optional):**
23
+ - `--task` - Commit all staged files (semantic: task context)
24
+ - `--all` - Commit all staged files (explicit, same as no scope flag)
25
+ - `--scope-task` - Commit ONLY files in the active task's `files_changed[]` (intersected with currently-staged files); leaves foreign-staged files alone
26
+
27
+ **Other Options:**
28
+ - `--files [file1] [file2] ...` - **Manual override**: commit ONLY these specific files
29
+ - `--no-push` - Skip push to remote
30
+
31
+ **Scope Flag Behavior:**
32
+
33
+ | Flag | File Source | Use Case |
34
+ |------|-------------|----------|
35
+ | `--task` | All staged files | `/cbp-task-complete` |
36
+ | `--all` | All staged files | Explicit full commit |
37
+ | `--scope-task` | Intersection of `task.files_changed[].path` and `git diff --cached --name-only` | Foreign-staged files exist alongside task work; user wants to commit only the task's files in this commit |
38
+ | (none) | All staged files | Default behavior |
39
+
40
+ When a scope flag is used:
41
+ - All staged files are committed (except `--scope-task`, which intersects with task files)
42
+ - Semantic distinction only (for context in calling commands)
43
+
44
+ **`--scope-task` Behavior:**
45
+
46
+ When `--scope-task` is used:
47
+ 1. Read `task.files_changed[].path` via MCP `get_current_task`
48
+ 2. Read currently-staged files via `git diff --cached --name-only`
49
+ 3. Compute intersection — only those paths are committed
50
+ 4. Foreign-staged files (in staged set but NOT in task) remain staged after the commit; user handles them in a separate commit
51
+ 5. If intersection is empty → error "No staged files belong to TASK-N. Either use --all to commit foreign-staged files, or stage task files first."
52
+
53
+ This is the right scope flag when `git status` shows foreign-staged batches alongside task work (e.g., a parallel `.claude/` sync staged simultaneously with TASK-N's work) and the commit narrative belongs to the task only.
54
+
55
+ **Manual Override: --files**
56
+
57
+ When `--files` is used (overrides scope flags):
58
+ - Only the specified files are committed
59
+ - Other staged files remain staged (not committed)
60
+ - Specified files MUST be staged, otherwise error
61
+ - This enables manual control when scoped flags don't fit
62
+
63
+ **Message formats:**
64
+ - `[type]: [description]`
65
+ - `[type](scope): [description]`
66
+
67
+ **Examples:**
68
+ - `feat: add user authentication` - Commit all staged, auto-push
69
+ - `--task feat(CHK-022): complete TASK-1` - Commit all staged in task context
70
+ - `--all fix(api): resolve timeout` - Explicit all-staged commit
71
+ - `--files path/to/file.md feat: add feature` - Manual specific file
72
+ - `--no-push chore: update deps` - Commit without pushing
73
+
74
+ If no message provided, analyze staged changes and generate message automatically.
75
+
76
+ ## Instructions
77
+
78
+ ### Step 1: Determine Repo Path
79
+
80
+ **CRITICAL**: The shell working directory may not match the session's repo.
81
+
82
+ Determine repo path from session context:
83
+
84
+ The repo path is the current working directory root:
85
+
86
+ ```bash
87
+ REPO_PATH="$(git rev-parse --show-toplevel)"
88
+ ```
89
+
90
+ ### Step 2: Parse Scope and Options
91
+
92
+ **Parse `$ARGUMENTS` for flags:**
93
+
94
+ 1. **Check for scope flag** (mutually exclusive):
95
+ - `--task` -> scope = "task" (commits all staged)
96
+ - `--all` -> scope = "all"
97
+ - `--scope-task` -> scope = "scope-task" (intersection of task.files_changed[] and staged)
98
+ - (none) -> scope = "all" (default)
99
+
100
+ 2. **Check for --files** (overrides scope):
101
+ - If `--files` present -> use manual file list, ignore scope
102
+
103
+ 3. **Check for --no-push**
104
+
105
+ 4. **Extract commit message** (remaining arguments after flags)
106
+
107
+ ### Step 2a: Collect Files (if --files or --scope-task used)
108
+
109
+ **If `--files` provided:** Use the manual file list.
110
+
111
+ **If `--scope-task`:** Resolve via MCP + intersection.
112
+
113
+ ```bash
114
+ # 1. Read task.files_changed[]
115
+ task_paths=$(mcp get_current_task | jq -r '.files_changed[].path')
116
+ # 2. Read staged paths
117
+ staged_paths=$(git diff --cached --name-only)
118
+ # 3. Compute intersection
119
+ intersect=$(comm -12 <(echo "$task_paths" | sort) <(echo "$staged_paths" | sort))
120
+ ```
121
+
122
+ If `intersect` is empty: emit error and STOP.
123
+
124
+ ```
125
+ ## Error: No Task Files Staged
126
+
127
+ Scope: --scope-task
128
+ TASK-N has [M] files in files_changed[]; none are currently staged.
129
+
130
+ Options:
131
+ - Stage task files: git add [path1] [path2] ...
132
+ - Or use --all to commit the foreign-staged files instead.
133
+ ```
134
+
135
+ If non-empty: use `intersect` as the file list for Step 5.
136
+
137
+ **If `--task`, `--all`, or no scope:** No filtering — all staged files committed.
138
+
139
+ ### Step 3: Check Staged Changes
140
+
141
+ ```bash
142
+ cd "$REPO_PATH" && git diff --cached --name-only
143
+ ```
144
+
145
+ **If nothing staged:**
146
+ - Show "No changes to commit."
147
+ - Stop here.
148
+
149
+ ### Step 4: Analyze Changes (if no message)
150
+
151
+ If no commit message provided:
152
+ 1. Read staged file diffs
153
+ 2. Determine commit type:
154
+ - New files with features -> `feat`
155
+ - Bug fixes -> `fix`
156
+ - Config/deps changes -> `chore`
157
+ - Documentation -> `docs`
158
+ - Refactoring -> `refactor`
159
+ 3. Generate message automatically
160
+
161
+ ### Step 4a: Verify Manual Files Are Staged
162
+
163
+ **If `--files`:** Verify each specified file is staged.
164
+
165
+ ```bash
166
+ cd "$REPO_PATH" && git diff --cached --name-only
167
+ ```
168
+
169
+ **If any specified files not staged:** Show error with missing files list and STOP.
170
+
171
+ **If `--task`, `--all`, or no scope:** Skip verification, use all staged.
172
+
173
+ ### Step 5: Create Commit
174
+
175
+ **For `--scope-task`:** commit only the intersection list from Step 2a:
176
+
177
+ ```bash
178
+ cd "$REPO_PATH" && git commit [intersect-file1] [intersect-file2] ... -m "$(cat <<'EOF'
179
+ [type]: [description]
180
+ EOF
181
+ )"
182
+ ```
183
+
184
+ Foreign-staged files remain in the index (not committed). The commit attribution covers only TASK-N's files.
185
+
186
+ **Determine commit mode:**
187
+
188
+ | Scope | Commit Command |
189
+ |-------|----------------|
190
+ | `--files [list]` | `git commit [file1] [file2] ...` |
191
+ | `--task` | `git commit` (all staged) |
192
+ | `--all` or (none) | `git commit` (all staged) |
193
+
194
+ **If --files (manual file list):**
195
+
196
+ Commit ONLY the specified files:
197
+
198
+ ```bash
199
+ cd "$REPO_PATH" && git commit [file1] [file2] ... -m "$(cat <<'EOF'
200
+ [type]: [description]
201
+ EOF
202
+ )"
203
+ ```
204
+
205
+ **If --task, --all, or no scope (commit all staged):**
206
+
207
+ ```bash
208
+ cd "$REPO_PATH" && git commit -m "$(cat <<'EOF'
209
+ [type]: [description]
210
+ EOF
211
+ )"
212
+ ```
213
+
214
+ ### Step 6: Push to Remote
215
+
216
+ **If `--no-push` option provided:**
217
+ - Skip this step
218
+ - Show "Push skipped (--no-push)"
219
+
220
+ **Otherwise:** push the current branch to origin.
221
+
222
+ ```bash
223
+ cd "$REPO_PATH" && BRANCH=$(git rev-parse --abbrev-ref HEAD) && git push origin "$BRANCH"
224
+ ```
225
+
226
+ **If push fails with "no upstream":** retry with `-u`.
227
+
228
+ ```bash
229
+ cd "$REPO_PATH" && git push -u origin "$BRANCH"
230
+ ```
231
+
232
+ **If push fails because remote is ahead:** report to user and stop — do not auto-pull. User resolves by running `git pull --rebase origin "$BRANCH"` and retrying.
233
+
234
+ ### Step 7: Show Result
235
+
236
+ Display output per Output Format section below.
237
+
238
+ ## Output Format
239
+
240
+ **Standard commit (all staged):**
241
+ ```
242
+ **Committed**: [short-hash]
243
+ **Message**: [type]: [description]
244
+ **Scope**: [--task / --all / --files]
245
+ **Files**: N files changed
246
+ **Pushed**: origin/[branch-name]
247
+ ```
248
+
249
+ **If no changes to commit:**
250
+ ```
251
+ No changes to commit.
252
+ ```
253
+
254
+ **If manual files not staged:**
255
+ ```
256
+ ## Error: Files Not Staged
257
+
258
+ Scope: --files
259
+ Missing: [N] files not staged
260
+
261
+ Stage the missing files or use --all.
262
+ ```
263
+
264
+ ## Integration
265
+
266
+ - **Called by**: `/cbp-session-end`, `/cbp-task-complete`, `/cbp-checkpoint-complete`, manual
267
+ - **Scope usage by commands**:
268
+ - `/cbp-task-complete` -> `--no-push` (commit all staged)
269
+ - `/cbp-checkpoint-complete` -> no scope needed
270
+ - `/cbp-session-end` -> `--all` or no scope (commit all staged)
271
+ - **Rules**: `/.claude/rules/git-workflow.md`
272
+
273
+ ## Key Points
274
+
275
+ 1. **Simplified scopes** - `--task` and `--all` both commit all staged files
276
+ 2. **Manual override** - `--files` takes precedence over scope flags
277
+ 3. **Verification** - Only `--files` needs staged verification
278
+ 4. **Default is --all** - No scope flag = commit all staged (backward compatible)
@@ -0,0 +1,226 @@
1
+ ---
2
+ scope: org-shared
3
+ name: cbp-git-worktree-create
4
+ description: Create git worktree with clean command setup and register in CodeByPlan
5
+ argument-hint: <branch-name> e.g. codebyplan-app
6
+ effort: low
7
+ ---
8
+
9
+ # Git Worktree Create
10
+
11
+ Create a git worktree as a sibling folder and register it in CodeByPlan. The worktree gets its own full copy of `.claude/` files on disk (rules, skills, hooks, agents, context) — git deduplicates at the object level so there's no real cost.
12
+
13
+ ## Arguments
14
+
15
+ `$ARGUMENTS`: branch name — becomes both the branch name and the folder name.
16
+
17
+ Examples:
18
+ - `codebyplan-app` → folder `../codebyplan-app/`, branch `codebyplan-app`
19
+ - `codebyplan-package` → folder `../codebyplan-package/`, branch `codebyplan-package`
20
+
21
+ ## Prerequisites
22
+
23
+ - Must run from the **main repo** (the non-worktree checkout)
24
+ - Working tree should be clean
25
+ - Branch should not already exist as a worktree
26
+
27
+ ## Instructions
28
+
29
+ ### Step 1: Verify Main Repo
30
+
31
+ ```bash
32
+ MAIN_REPO="$(git rev-parse --show-toplevel)"
33
+ ```
34
+
35
+ Verify this is the main repo (not itself a worktree):
36
+
37
+ ```bash
38
+ git rev-parse --git-dir
39
+ ```
40
+
41
+ If the result is a file (not `.git` directory), this is already a worktree. Stop:
42
+
43
+ ```
44
+ ## Error
45
+
46
+ Run this command from the main repo, not from a worktree.
47
+ Main repo: [path from git-common-dir parent]
48
+ ```
49
+
50
+ ### Step 2: Validate Arguments
51
+
52
+ If `$ARGUMENTS` is empty, ask the user:
53
+
54
+ ```
55
+ What should the worktree be called? (e.g. codebyplan-app)
56
+ ```
57
+
58
+ Set:
59
+ - `BRANCH_NAME` = `$ARGUMENTS`
60
+ - `WORKTREE_PATH` = `$MAIN_REPO/../$BRANCH_NAME`
61
+
62
+ ### Step 3: Check for Conflicts
63
+
64
+ Check if the worktree already exists:
65
+
66
+ ```bash
67
+ git worktree list | grep "$BRANCH_NAME"
68
+ ```
69
+
70
+ If it exists:
71
+ ```
72
+ ## Worktree Already Exists
73
+
74
+ Branch `[name]` is already checked out at [path].
75
+
76
+ Use `/cbp-git-worktree-remove [name]` to remove it first.
77
+ ```
78
+ Stop here.
79
+
80
+ Check if the folder already exists:
81
+
82
+ ```bash
83
+ ls -d "$WORKTREE_PATH" 2>/dev/null
84
+ ```
85
+
86
+ If it exists, stop and inform the user.
87
+
88
+ ### Step 4: Create Branch If Needed
89
+
90
+ Check if branch exists:
91
+
92
+ ```bash
93
+ git branch --list "$BRANCH_NAME"
94
+ ```
95
+
96
+ If branch does NOT exist, create it from current HEAD:
97
+
98
+ ```bash
99
+ git branch "$BRANCH_NAME"
100
+ ```
101
+
102
+ ### Step 5: Create Worktree
103
+
104
+ ```bash
105
+ git worktree add "$WORKTREE_PATH" "$BRANCH_NAME"
106
+ ```
107
+
108
+ ### Step 6: Set Up MCP Connection
109
+
110
+ Copy `.mcp.json` from the main repo to the worktree. The config points at the remote MCP endpoint (`https://codebyplan.com/mcp`) and reads the API key from the environment, so no path rewriting is needed:
111
+
112
+ ```bash
113
+ cp "$MAIN_REPO/.mcp.json" "$WORKTREE_PATH/.mcp.json"
114
+ ```
115
+
116
+ Expected shape (do NOT rewrite paths — this is remote HTTP):
117
+
118
+ ```json
119
+ {
120
+ "mcpServers": {
121
+ "codebyplan": {
122
+ "url": "https://codebyplan.com/mcp",
123
+ "headers": {
124
+ "x-api-key": "${CODEBYPLAN_API_KEY}"
125
+ }
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### Step 7: Set Up Environment
132
+
133
+ Copy `.env.local` from the main repo to the worktree (contains `CODEBYPLAN_API_KEY` and any other local env):
134
+
135
+ ```bash
136
+ cp "$MAIN_REPO/.env.local" "$WORKTREE_PATH/.env.local"
137
+ ```
138
+
139
+ Verify `.env.local` is already in `.gitignore` (it should be via `.env.local` pattern). If not, add it.
140
+
141
+ ### Step 8: Push Branch
142
+
143
+ ```bash
144
+ cd "$WORKTREE_PATH" && git push -u origin "$BRANCH_NAME"
145
+ ```
146
+
147
+ ### Step 9: Register Worktree in CodeByPlan
148
+
149
+ Get the repo ID from CLAUDE.md (`Repo ID` in Key References table).
150
+
151
+ Use MCP `create_worktree` to register the worktree in the CodeByPlan database:
152
+
153
+ ```
154
+ MCP create_worktree:
155
+ repo_id: [repo-id from CLAUDE.md]
156
+ name: $BRANCH_NAME
157
+ path: $WORKTREE_PATH
158
+ status: "active"
159
+ ```
160
+
161
+ Save the returned `worktree_id` for reference.
162
+
163
+ ### Step 10: Write `.codebyplan/` directory
164
+
165
+ Create the `.codebyplan/` directory in the worktree root and write per-concern config stubs:
166
+
167
+ ```bash
168
+ mkdir -p "$WORKTREE_PATH/.codebyplan"
169
+ ```
170
+
171
+ Write `.codebyplan/repo.json` with the correct `repo_id`:
172
+
173
+ ```json
174
+ {
175
+ "repo_id": "[repo-id from CLAUDE.md]"
176
+ }
177
+ ```
178
+
179
+ Write stubs for the other per-concern files (populated by `npx codebyplan sync` on first run):
180
+
181
+ ```bash
182
+ # .codebyplan/server.json — server port and type config
183
+ echo '{}' > "$WORKTREE_PATH/.codebyplan/server.json"
184
+
185
+ # .codebyplan/git.json — branch config
186
+ echo '{}' > "$WORKTREE_PATH/.codebyplan/git.json"
187
+
188
+ # .codebyplan/shipment.json — surface shipment config
189
+ echo '{}' > "$WORKTREE_PATH/.codebyplan/shipment.json"
190
+
191
+ # .codebyplan/vendor.json — vendor docs path
192
+ echo '{}' > "$WORKTREE_PATH/.codebyplan/vendor.json"
193
+ ```
194
+
195
+ The `.codebyplan/device.local.json` file is created by `npx codebyplan setup` on the device (gitignored). The `worktree_id` is never persisted in any of these files — it is resolved at runtime via `npx codebyplan resolve-worktree` based on the device_id, filesystem path, and current git branch.
196
+
197
+ No need to mark as `skip-worktree` — the committed files are merge-safe per CHK-108 and CHK-120.
198
+
199
+ ### Step 11: Show Result
200
+
201
+ ```
202
+ ## Worktree Created
203
+
204
+ **Branch**: [branch-name]
205
+ **Path**: [worktree-path]
206
+ **Main repo**: [main-repo-path]
207
+ **CodeByPlan**: Registered (worktree ID: [id])
208
+
209
+ ### Setup
210
+ - MCP: connected (remote endpoint)
211
+ - API key: copied from main repo `.env.local`
212
+ - `.claude/` files: full copy on disk (rules, skills, hooks, agents, context)
213
+
214
+ ### Next Steps
215
+ - Open `[worktree-path]` in your editor
216
+ - Run `/cbp-session-start` to begin working
217
+ - Checkpoints can be assigned to this worktree via `worktree_id`
218
+
219
+ ### Existing Worktrees
220
+ [output of git worktree list]
221
+ ```
222
+
223
+ ## Integration
224
+
225
+ - **Related**: `/cbp-git-worktree-remove` (cleanup and deregister)
226
+ - **MCP tools**: `create_worktree`
@@ -0,0 +1,145 @@
1
+ ---
2
+ scope: org-shared
3
+ name: cbp-git-worktree-remove
4
+ description: Remove git worktree and deregister from CodeByPlan
5
+ argument-hint: <name> e.g. codebyplan-app
6
+ effort: low
7
+ ---
8
+
9
+ # Git Worktree Remove
10
+
11
+ Remove a git worktree folder, deregister it from CodeByPlan, and optionally delete its branch.
12
+
13
+ ## Arguments
14
+
15
+ `$ARGUMENTS`: worktree name or path to remove.
16
+
17
+ ## Prerequisites
18
+
19
+ - Must run from the **main repo** (not from the worktree being removed)
20
+
21
+ ## Instructions
22
+
23
+ ### Step 1: Verify Main Repo
24
+
25
+ ```bash
26
+ MAIN_REPO="$(git rev-parse --show-toplevel)"
27
+ ```
28
+
29
+ Verify not in a worktree (`.git` should be a directory, not a file).
30
+
31
+ ### Step 2: List Worktrees
32
+
33
+ ```bash
34
+ git worktree list
35
+ ```
36
+
37
+ If `$ARGUMENTS` is empty, show the list and ask which to remove.
38
+
39
+ ### Step 3: Resolve Worktree
40
+
41
+ Find matching worktree from the list. Match by:
42
+ 1. Exact path
43
+ 2. Folder name (e.g. `codebyplan-app`)
44
+ 3. Branch name
45
+
46
+ If no match found, show available worktrees and stop.
47
+
48
+ Set:
49
+ - `WORKTREE_PATH` = resolved path
50
+ - `BRANCH_NAME` = branch checked out in that worktree
51
+
52
+ ### Step 4: Look Up Worktree in CodeByPlan
53
+
54
+ Get the repo ID from CLAUDE.md (`Repo ID` in Key References table).
55
+
56
+ Use MCP `get_worktrees` to find the worktree record:
57
+
58
+ ```
59
+ MCP get_worktrees:
60
+ repo_id: [repo-id from CLAUDE.md]
61
+ status: "active"
62
+ ```
63
+
64
+ Match by `name` = `$BRANCH_NAME` or `path` = `$WORKTREE_PATH`.
65
+
66
+ Set `WORKTREE_ID` = matched worktree's `id`.
67
+
68
+ If not found in CodeByPlan, note it and continue with local removal.
69
+
70
+ ### Step 5: Check for Assigned Checkpoints
71
+
72
+ If `WORKTREE_ID` was found, warn if any checkpoints are assigned to this worktree:
73
+
74
+ ```
75
+ ⚠ This worktree has [N] checkpoint(s) assigned. They will become unassigned.
76
+ ```
77
+
78
+ ### Step 6: Confirm with User
79
+
80
+ ```
81
+ ## Remove Worktree
82
+
83
+ **Path**: [worktree-path]
84
+ **Branch**: [branch-name]
85
+ **CodeByPlan**: [registered | not registered]
86
+
87
+ Remove worktree and delete the branch? (The main repo is not affected)
88
+ ```
89
+
90
+ Ask:
91
+ 1. Remove worktree only (keep branch)
92
+ 2. Remove worktree and delete branch
93
+ 3. Cancel
94
+
95
+ ### Step 7: Deregister from CodeByPlan
96
+
97
+ If `WORKTREE_ID` was found, delete the worktree record:
98
+
99
+ ```
100
+ MCP delete_worktree:
101
+ worktree_id: [worktree-id]
102
+ ```
103
+
104
+ ### Step 8: Remove Git Worktree
105
+
106
+ ```bash
107
+ git worktree remove "$WORKTREE_PATH"
108
+ ```
109
+
110
+ If force needed (uncommitted changes):
111
+ ```bash
112
+ git worktree remove --force "$WORKTREE_PATH"
113
+ ```
114
+
115
+ Only use `--force` if the user confirms.
116
+
117
+ ### Step 9: Delete Branch (if requested)
118
+
119
+ **Protected branch check:** If `$BRANCH_NAME` is `main`, `development`, or `preview` — refuse deletion and stop.
120
+
121
+ **Checkpoint verification:** Before deleting a feat branch, verify that the associated checkpoint has completed via `/cbp-checkpoint-end`. If the checkpoint is still active, warn the user that unshipped work may be lost.
122
+
123
+ ```bash
124
+ git branch -d "$BRANCH_NAME" && git push origin --delete "$BRANCH_NAME"
125
+ ```
126
+
127
+ Use `-d` (not `-D`) to prevent deleting unmerged work. If it fails because the branch is not fully merged, inform the user and ask if they want to force delete with `-D`.
128
+
129
+ ### Step 10: Show Result
130
+
131
+ ```
132
+ ## Worktree Removed
133
+
134
+ **Removed**: [worktree-path]
135
+ **Branch**: [deleted | kept]
136
+ **CodeByPlan**: [deregistered | was not registered]
137
+
138
+ ### Remaining Worktrees
139
+ [output of git worktree list]
140
+ ```
141
+
142
+ ## Integration
143
+
144
+ - **Related**: `/cbp-git-worktree-create` (create and register)
145
+ - **MCP tools**: `get_worktrees`, `delete_worktree`