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,206 @@
1
+ ---
2
+ scope: org-shared
3
+ name: cbp-task-complete
4
+ description: Complete current task
5
+ argument-hint: [chk-task | task]
6
+ effort: xhigh
7
+ ---
8
+
9
+ # Task Complete Command
10
+
11
+ Complete the current task. Auto-triggered by `/cbp-task-testing` when all tests pass. Can also be run manually.
12
+
13
+ ## Instructions
14
+
15
+ ### Step 1: Parse `$ARGUMENTS`
16
+
17
+ Parse the argument using the canonical chk-task-round notation (see `.claude/rules/notation-consistency.md`):
18
+
19
+ | Shape | Regex | Resolves to |
20
+ |-------|-------|-------------|
21
+ | `{chk}-{task}` (e.g. `108-1`) | `^[0-9]+-[0-9]+$` | Checkpoint-bound: CHK-{chk} TASK-{task} |
22
+ | `{task}` (e.g. `45`) | `^[0-9]+$` | Standalone: standalone TASK-{task} **only** |
23
+ | _(empty)_ | — | Use MCP `get_current_task` to find the active in-progress task |
24
+
25
+ Anything else is malformed — surface this error and stop:
26
+
27
+ ```
28
+ task-complete: invalid argument `{value}`. Expected:
29
+ 108-1 → CHK-108 TASK-1 (checkpoint-bound)
30
+ 45 → standalone TASK-45
31
+ (empty) → active in-progress task
32
+
33
+ For a specific round, use `/cbp-round-update 108-1-2`.
34
+ ```
35
+
36
+ Error cases: `108-1-2` (that is round-update's shape), `abc`, `108-`, `-1`, `108--1`, anything with whitespace or non-numeric characters.
37
+
38
+ #### Worked examples
39
+
40
+ - `task-complete 108-1` → CHK-108 TASK-1
41
+ - `task-complete 45` → standalone TASK-45
42
+ - `task-complete` (no arg) → active in-progress task via `get_current_task`
43
+ - `task-complete 108-1-2` → error: "use `/cbp-round-update 108-1-2`"
44
+ - `task-complete abc` → error: malformed
45
+
46
+ ### Step 1.5: Get Current Task
47
+
48
+ Given the parse from Step 1:
49
+
50
+ | Parse | Resolution path |
51
+ |-------|-----------------|
52
+ | `{chk}-{task}` | MCP `get_checkpoints(repo_id)` → filter `number === {chk}`. MCP `get_tasks(checkpoint_id)` → filter `number === {task}`. |
53
+ | `{task}` | MCP `get_tasks(repo_id, standalone: true)` → filter `number === {task}`. |
54
+ | _(empty)_ | MCP `get_current_task(repo_id)` — finds the active in-progress task. |
55
+
56
+ If no in-progress task, show error and stop.
57
+
58
+ ### Step 2: Verify Rounds Complete and Validated
59
+
60
+ Use MCP `get_rounds` for the task. Verify all rounds are `completed`.
61
+
62
+ If any round is `in_progress`:
63
+
64
+ ```
65
+ ## Cannot Complete Task
66
+
67
+ TASK-[N] has an active round (Round [N]). Run `/cbp-round-update` to finish it.
68
+ ```
69
+
70
+ Stop here.
71
+
72
+ Verify at least one round has `testing_qa_output` in its context. If not:
73
+
74
+ ```
75
+ ## Cannot Complete Task
76
+
77
+ No testing-qa-agent validation found. Run `/cbp-round-start` to execute a validated round.
78
+ ```
79
+
80
+ Stop here.
81
+
82
+ ### Step 2.5: Verify `/cbp-task-check` Has Run
83
+
84
+ `task.context.check_verdict` must exist and have `verdict: 'READY'`. If not, surface "Run `/cbp-task-check` first" and stop.
85
+
86
+ ### Step 2.6: Verify `/cbp-task-testing` Has Run
87
+
88
+ `task.context.task_testing_output` must exist with `all_passed: true`. If not, surface "Run `/cbp-task-testing` first" and stop.
89
+
90
+ ### Step 3: Verify QA and File Approval
91
+
92
+ Load `task.qa` and `task.files_changed`:
93
+
94
+ 1. **QA**: count items by status (pass / fail / pending / skipped) across all types. If any item has status `fail` or `pending` (including default checklists), warn the user.
95
+ 2. **Files**: list any file with `user_approved === false` and warn.
96
+
97
+ **If issues exist**, AskUserQuestion: `Complete anyway` / `Run QA first` (suggest `/cbp-task-check`) / `Cancel`. On `Run QA first` or `Cancel`, stop. On `Complete anyway`, continue.
98
+
99
+ **If no issues**, AskUserQuestion to confirm: `Ready to complete TASK-[N]: [title] — [N] rounds, [N] files. Proceed?`
100
+
101
+ ### Step 4: Aggregate Files Changed
102
+
103
+ Collect all files_changed from task. Deduplicate (latest action wins).
104
+
105
+ ### Step 4.5: Merge Production Branch Before Commit (mandatory)
106
+
107
+ Before committing task work, ensure the feat branch is current with the latest production (main) work. This prevents shipping a stale PR and surfaces conflicts at task-complete time rather than at PR review.
108
+
109
+ 1. Trigger `/cbp-merge-main`.
110
+ 2. If the skill exits with failure (offline, unresolved conflicts, user-aborted): surface the failure and STOP — do NOT proceed to Step 5 (commit). The user resolves and re-invokes `/cbp-task-complete`.
111
+ 3. If the skill exits with QA warnings the user chose to commit-as-is: continue to Step 5; surface a soft warning in the Step 9 output (`⚠ Merged with QA failures pending fix in follow-up`).
112
+ 4. On clean success: continue to Step 5.
113
+
114
+ ### Step 5: Git Commit and Push
115
+
116
+ **Zero-file guard**: if `aggregated_files` is empty (investigative or DB-only tasks), skip commit and push. Record "No git commit: zero files changed" in the Step 9 summary.
117
+
118
+ Otherwise: invoke `/cbp-git-commit` to stage approved files and create the commit. Claude does NOT git add directly. After commit:
119
+
120
+ ```bash
121
+ git push origin $(git branch --show-current)
122
+ ```
123
+
124
+ If push fails, investigate and fix per migration-infrastructure rule — never skip.
125
+
126
+ ### Step 6: Update Task Files
127
+
128
+ `update_task(task_id, files_changed: aggregated_files)`.
129
+
130
+ ### Step 7: Complete Task
131
+
132
+ If `CALLER_WT` is non-empty, call `complete_task(task_id, caller_worktree_id: CALLER_WT)`. Otherwise call `complete_task(task_id)` with no worktree id — the pre-guard is skipped (backwards-compat).
133
+
134
+ **When calling `complete_task`**: pass `caller_worktree_id` resolved from `npx codebyplan resolve-worktree`. The MCP server's pre-guard rejects mutations from non-matching worktrees; supplying `caller_worktree_id` ensures legitimate completion succeeds. The server auto-clears `assigned_user_id` + `assigned_worktree_id` on the task; if this was the last sibling task, it also clears the parent checkpoint's assignment. (Per CHK-104 TASK-2 hard-lock.)
135
+
136
+ ### Step 7.5: Standalone Task Branch Merge
137
+
138
+ **Standalone tasks only** (no checkpoint). Checkpoint tasks ship via `/cbp-checkpoint-end`.
139
+
140
+ If `checkpoint_id === null` AND current branch is `feat/*`:
141
+
142
+ 1. Read `.codebyplan/git.json` `branch_config.production` (default `main`).
143
+ 2. Merge: `git checkout {production} && git merge {feat-branch} --no-ff -m "Merge {feat-branch}: {task title}"`
144
+ 3. Push: `git push origin {production}`
145
+ 4. Delete feat branch (local + remote).
146
+
147
+ If merge has conflicts, stop and ask the user. If current branch is not `feat/*`, skip.
148
+
149
+ ### Step 8: Run Cleanup + Migration (inline)
150
+
151
+ Apply the `cleanup` skill inline to remove orphan references to deleted/modified files. Then apply `migration` to propagate renames/moves to consumers. Both run without sub-agent spawns. Skip cleanup if no deletions/modifications; skip migration if cleanup handled everything.
152
+
153
+ ### Step 9: Show Result and Route (User-Confirmed)
154
+
155
+ Show the completion summary:
156
+
157
+ ```
158
+ ## Task Completed
159
+
160
+ **TASK-[N]**: [title]
161
+ **Rounds**: [N] completed
162
+ **Files**: [N] changed
163
+ **Commit**: [hash]
164
+ ```
165
+
166
+ Then route. Same-context transitions (next task in this checkpoint) auto-trigger via the Skill tool. Cross-context transitions (checkpoint done → /cbp-checkpoint-check, session end) surface as a single directive 'Next: /clear, then /cbp-X' for the user to invoke after refreshing context.
167
+
168
+ #### 9a — Determine routing context
169
+
170
+ ```
171
+ checkpoint_id := current_task.checkpoint_id
172
+ if checkpoint_id is null → STANDALONE; go to 9b
173
+ else
174
+ siblings := get_tasks(checkpoint_id) minus current_task
175
+ all_done := every sibling has status === 'completed'
176
+ if all_done → CHECKPOINT-DONE; go to 9c
177
+ else → MORE-TASKS-IN-CHECKPOINT; go to 9b
178
+ ```
179
+
180
+ #### 9b — Next-task routing (more tasks pending OR standalone fall-through)
181
+
182
+ Identify the next pending task: the lowest-numbered pending task in the same checkpoint, or — for standalone fall-through — the next standalone or in-progress-checkpoint task. Use `{N}` as the chk-task-round identifier form of that task (e.g. `111-5` for CHK-111 TASK-5, or `45` for standalone TASK-45).
183
+
184
+ Use the Skill tool with `skill: cbp-task-start` and `args: "{NEXT_CHK}-{NEXT_TASK}"` (or `args: "{NEXT_TASK}"` for standalone) to auto-trigger the next task. Same-context transition; no `/clear` needed.
185
+
186
+ If no next task is found (no pending work anywhere in the repo), emit directive and stop: `Next: Run /clear, then /cbp-session-end.`
187
+
188
+ #### 9c — Checkpoint-done directive (last task in checkpoint)
189
+
190
+ The checkpoint has no remaining tasks. Emit this directive and stop:
191
+
192
+ ```
193
+ CHK-{NNN} is fully tasked. Run /clear, then /cbp-checkpoint-check to verify and ship.
194
+ Alternatives: /cbp-checkpoint-update {NNN} to expand the checkpoint with more tasks, or /cbp-session-end to wrap up here.
195
+ ```
196
+
197
+ Do NOT use AskUserQuestion here — this is a directive, not a menu. The user runs whichever command fits their intent.
198
+
199
+ ## Integration
200
+
201
+ - **Triggered by**: `/cbp-task-testing` (auto, when ALL PASS) — NOT directly from `/cbp-task-check`
202
+ - **Chain**: `/cbp-task-check` → `/cbp-task-testing` → `/cbp-task-complete`
203
+ - **Reads**: MCP `get_current_task`, `get_rounds`, `get_tasks`
204
+ - **Writes**: MCP `update_task`, `complete_task`
205
+ - **Uses skills (inline, no sub-agent)**: `cleanup` (if deletions), `migration` (if exports renamed)
206
+ - **Triggers**: Same-context transitions auto-trigger via the Skill tool (next task in checkpoint → `/cbp-task-start {N}`). Cross-context transitions emit a directive `Next: /clear, then /cbp-X` for the user to invoke.
@@ -0,0 +1,48 @@
1
+ # Checkpoint-Done Branching in `/cbp-task-complete` Step 9
2
+
3
+ When the just-completed task was the LAST pending task in its checkpoint (every sibling task has `status === 'completed'`), Step 9c emits a directive instead of a routing menu. The user reads the directive and runs whichever command fits their intent — no AskUserQuestion.
4
+
5
+ This file describes the detection logic, the directive form, and the standalone fall-through.
6
+
7
+ ## Detection
8
+
9
+ The skill detects "checkpoint done" at Step 9 by:
10
+
11
+ 1. Reading `current_task.checkpoint_id`. If `null` → standalone — see "Standalone Fall-Through" below.
12
+ 2. Calling `get_tasks(checkpoint_id)` and checking that EVERY task other than the just-completed one has `status === 'completed'`.
13
+ 3. If yes, the checkpoint has no pending or in-progress siblings — emit the Step 9c directive.
14
+
15
+ ## Step 9c Directive Form
16
+
17
+ When all siblings are done, the skill emits:
18
+
19
+ ```
20
+ CHK-{NNN} is fully tasked. Run /clear, then /cbp-checkpoint-check to verify and ship.
21
+ Alternatives: /cbp-checkpoint-update {NNN} to expand the checkpoint with more tasks, or /cbp-session-end to wrap up here.
22
+ ```
23
+
24
+ This is a directive, not a menu. No AskUserQuestion. The user runs whichever command fits their intent:
25
+
26
+ - `/clear` then `/cbp-checkpoint-check` — verify deliverables and begin the shipment chain
27
+ - `/cbp-checkpoint-update {NNN}` — expand the checkpoint with more tasks (routes through `checkpoint-update` FIRST, not directly to `task-create`)
28
+ - `/cbp-session-end` — wrap up here
29
+
30
+ The skill does NOT auto-invoke any of these. Emit the directive, then stop.
31
+
32
+ ## Standalone Fall-Through
33
+
34
+ When the just-completed task is standalone (`checkpoint_id === null`):
35
+
36
+ - The Step 9c directive does NOT apply. There is no checkpoint to ship, expand, or defer.
37
+ - Step 9 falls through to next-task routing per `next-step-heuristic.md` "Standalone Variant":
38
+ - If a next pending task is found (standalone or in-progress checkpoint): auto-trigger via Skill tool — no AskUserQuestion, no /clear.
39
+ - If no pending tasks remain anywhere: emit single directive `**Next**: Run /clear, then /cbp-session-end.` — all known work complete.
40
+
41
+ ## What the Skill Does NOT Do
42
+
43
+ Never auto-trigger `/cbp-checkpoint-check`, `/cbp-checkpoint-update`, or auto-mark the checkpoint complete — those are cross-context transitions that emit a single directive, not auto-invocations. Never combine the Step 9c directive with the Step 9b auto-trigger in the same response — one or the other based on detection, not both.
44
+
45
+ ## Pairs With
46
+
47
+ - `next-step-heuristic.md` — sibling reference for non-last-task-in-checkpoint case (Step 9b auto-trigger)
48
+ - `.claude/skills/cbp-checkpoint-update/SKILL.md` — destination of the expand path; accepts the entry-context preamble described in Step 9c
@@ -0,0 +1,56 @@
1
+ # Next-Step Heuristic for `/cbp-task-complete` Step 9
2
+
3
+ Close-out routing splits into two cases by context-continuity.
4
+
5
+ ## Case 1 — Same-Context (next task in same checkpoint)
6
+
7
+ When a sibling task remains pending in the same checkpoint, auto-trigger the next task without asking. The context window already holds the checkpoint scope; a `/clear` would discard useful state.
8
+
9
+ Use the Skill tool:
10
+
11
+ ```
12
+ skill: cbp-task-start
13
+ args: "{N}" # e.g. "111-5" for CHK-111 TASK-5, or "45" for standalone TASK-45
14
+ ```
15
+
16
+ No AskUserQuestion, no `/clear`. The skill fires immediately.
17
+
18
+ ## Case 2 — Cross-Context (checkpoint done, session end)
19
+
20
+ When the checkpoint is fully done or no pending tasks exist in the current context, emit a single directive line at the end of skill output and stop:
21
+
22
+ ```
23
+ **Next**: Run /clear, then /cbp-checkpoint-check.
24
+ ```
25
+
26
+ Or for session-end:
27
+
28
+ ```
29
+ **Next**: Run /clear, then /cbp-session-end.
30
+ ```
31
+
32
+ The user runs the command after refreshing context. No menu, no options — just one directive.
33
+
34
+ ## Rule
35
+
36
+ NEVER present a multi-option AskUserQuestion menu for routing between known-next skills. Branching AskUserQuestion is reserved for real branching decisions (errors, data conflicts, multiple-valid-approaches). When the next step is deterministic from context, either auto-trigger it (same-context) or surface a single directive (cross-context).
37
+
38
+ ## Standalone Variant
39
+
40
+ When the just-completed task is standalone (`current_task.checkpoint_id === null`):
41
+
42
+ - "Next pending" candidates are picked from BOTH:
43
+ - Standalone tasks (`get_tasks(repo_id, standalone: true, status: 'pending')`)
44
+ - In-progress checkpoints' next pending task
45
+ - Prefer in-progress-checkpoint tasks over fresh standalone candidates (continuing committed work first).
46
+ - If a next task is found: auto-trigger via Skill tool (same-context rule).
47
+ - If no pending tasks remain anywhere: emit directive `**Next**: Run /clear, then /cbp-session-end.` — all known work complete.
48
+
49
+ ## Reference
50
+
51
+ - Auto-memory: `[[feedback_long-lived-branch-integration]]` — related skill-clarity preference (same author feedback thread)
52
+ - Auto-memory: `feedback-close-out-routing` — the rule that drives this heuristic
53
+
54
+ ## Pairs With
55
+
56
+ - `checkpoint-done-branching.md` — sibling reference for the LAST-task-in-checkpoint case (Step 9c directive)
@@ -0,0 +1,167 @@
1
+ ---
2
+ scope: org-shared
3
+ name: cbp-task-create
4
+ description: Create a new task within the active checkpoint
5
+ effort: xhigh
6
+ ---
7
+
8
+ # Task Create Command
9
+
10
+ Create a new task within the active checkpoint. Gathers user context, analyzes existing work, and creates a well-positioned task. Runs inline (no subagent) to preserve Q&A conversation flow.
11
+
12
+ ## When Used
13
+
14
+ - Suggested by `/cbp-task-check` when scope issues require a new task
15
+ - Suggested by `/cbp-task-testing` when major problems need a separate task
16
+ - User manually wants to add a task to the current checkpoint
17
+
18
+ ## Identifier Notation
19
+
20
+ This skill operates on the **active** checkpoint resolved via MCP `get_current_task` and does not accept a positional identifier argument. The task it creates gets its `number` from the next-available slot within the active checkpoint (checkpoint-bound) or repo-wide standalone numbering (standalone). Canonical chk-task-round notation — used in prose, error messages, and cross-references — follows `.claude/rules/notation-consistency.md` "CHK / TASK / ROUND Identifier Notation": `108-1` (CHK-108 TASK-1), `45` (standalone TASK-45), `108-1-2` (round 2 of CHK-108 TASK-1), `45-2` (round 2 of standalone TASK-45).
21
+
22
+ ## Instructions
23
+
24
+ ### Step 1: Get Current Checkpoint
25
+
26
+ Use MCP `get_current_task` with repo_id to find the active checkpoint.
27
+
28
+ If no active checkpoint, show error and stop.
29
+
30
+ ### Step 2: Gather User Context
31
+
32
+ Use AskUserQuestion to understand the new task:
33
+
34
+ ```
35
+ ## New Task for CHK-[NNN]: [checkpoint title]
36
+
37
+ Why is this task needed? What should it accomplish?
38
+
39
+ If this was triggered by `/cbp-task-check` or `/cbp-task-testing`, the findings are:
40
+ [pre-loaded context from check/testing findings if available]
41
+
42
+ Please describe:
43
+ 1. What the task should accomplish
44
+ 2. Any specific requirements or constraints
45
+ 3. Priority relative to other tasks
46
+ ```
47
+
48
+ ### Step 3: Load Existing Tasks
49
+
50
+ Use MCP `get_tasks` for the checkpoint. Review:
51
+ - Existing task titles and requirements
52
+ - Task statuses (completed, in_progress, pending)
53
+ - Dependencies between tasks
54
+
55
+ ### Step 3.5: Dedup Against Pending Standalone Tasks (MANDATORY)
56
+
57
+ Per `rules/immediate-issue-capture.md` "Consolidation Before Creation", before creating ANY new task, also check pending standalone tasks for overlap:
58
+
59
+ ```
60
+ mcp__codebyplan__get_tasks(repo_id, standalone=true, status="pending")
61
+ ```
62
+
63
+ Compare the proposed task to each pending standalone task on these match dimensions:
64
+
65
+ | Match dimension | Action if matched |
66
+ |-----------------|-------------------|
67
+ | Same target file(s) | STOP — `update_task` to append, do not create new |
68
+ | Same feature / module | STOP — `update_task` to append, do not create new |
69
+ | Same root cause (e.g. "prettier drift", "router bug") | STOP — `update_task` to append, do not create new |
70
+ | Same dependency / advisory | STOP — `update_task` to append, do not create new |
71
+
72
+ If a match is found, surface it to the user before appending:
73
+
74
+ ```
75
+ Found existing pending task TASK-[N]: [title]
76
+ This finding overlaps on [dimension]. Append to TASK-[N] instead of creating new? (yes / no — create separately)
77
+ ```
78
+
79
+ Default to append. Only create a separate task if the user explicitly says no, OR if the existing task is in_progress / completed (in which case use `context.related_task_ids[]` on the new task to cross-reference).
80
+
81
+ ### Step 4: Analyze Codebase Context
82
+
83
+ Brief inline analysis:
84
+ 1. Check checkpoint.context for relevant decisions and discoveries
85
+ 2. Grep/Glob for files related to the user's described work
86
+ 3. Understand what prior tasks have already built
87
+
88
+ ### Step 5: Clarify Ambiguities (if needed)
89
+
90
+ If the task scope is unclear after Steps 2-4, ask up to 4 clarifying questions via AskUserQuestion:
91
+
92
+ ```
93
+ To create the best task definition, I need to clarify:
94
+
95
+ 1. [question about scope]
96
+ 2. [question about approach]
97
+ [max 4 questions]
98
+ ```
99
+
100
+ Skip if requirements are already clear from Step 2.
101
+
102
+ ### Step 6: Determine Task Position
103
+
104
+ Find logical position in task order:
105
+ - After which existing task should this go?
106
+ - Consider dependencies (does this depend on other tasks?)
107
+ - Consider checkpoint goal alignment
108
+
109
+ ### Step 7: Create Task
110
+
111
+ Use MCP `create_task` with:
112
+ - **title**: Concise task title
113
+ - **requirements**: Numbered requirements list
114
+ - **context**: Include decisions from Q&A, dependencies, source findings
115
+
116
+ **For standalone tasks** (no `checkpoint_id` parameter): resolve worktree_id via `npx codebyplan resolve-worktree 2>/dev/null` and, if non-empty, pass as `assigned_worktree_id`. The `chk_assignment_pair` CHECK constraint permits `assigned_user_id` to be NULL when `assigned_worktree_id` is set — `create_task` does not expose an `assigned_user_id` parameter and none is required. This engages the CHK-104 TASK-2 hard-lock from creation.
117
+
118
+ **If `worktree_id` is empty AND the task is standalone**: warn the user that the task will be unassigned (no hard-lock from creation) and offer to run `npx codebyplan setup` first from the current directory to register the worktree. After setup, re-resolve the worktree_id and proceed. If the user declines, create the task without `assigned_worktree_id`.
119
+
120
+ **For checkpoint-bound tasks**, an empty `worktree_id` is fine — no caller-worktree stamping is needed because the parent checkpoint's `worktree_id` governs.
121
+
122
+ ```
123
+ ## Task Created
124
+
125
+ **TASK-[N]**: [title]
126
+
127
+ ### Requirements:
128
+ 1. [requirement 1]
129
+ 2. [requirement 2]
130
+ ...
131
+
132
+ ### Context:
133
+ - Dependencies: [any task dependencies]
134
+ - Decisions: [key decisions from Q&A]
135
+ - Position: After TASK-[X] in checkpoint order
136
+ ```
137
+
138
+ ### Step 8: Route
139
+
140
+ ```
141
+ Task TASK-[N] created successfully.
142
+ ```
143
+
144
+ ---
145
+
146
+ **Next:**
147
+ Run `/cbp-task-start [N]` to:
148
+ - Start working on the new task
149
+ - Or run `/cbp-todo` to see the full task queue
150
+
151
+ ---
152
+ Waiting for user to decide next step.
153
+
154
+ ## Key Rules
155
+
156
+ - **Runs inline** — no subagent, preserves Q&A flow
157
+ - **Gather context first** — understand before creating
158
+ - **Consider existing tasks** — avoid duplication
159
+ - **Respect checkpoint goal** — new task must contribute to checkpoint goal
160
+ - **Does NOT auto-trigger** — user decides when to start
161
+
162
+ ## Integration
163
+
164
+ - **Reads**: MCP `get_current_task`, `get_tasks`
165
+ - **Writes**: MCP `create_task`
166
+ - **Triggered by**: `/cbp-task-check` (suggested), `/cbp-task-testing` (suggested), user manual
167
+ - **Does NOT auto-trigger** next command — user decides