codebyplan 1.5.0 → 1.8.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 (206) hide show
  1. package/README.md +48 -5
  2. package/dist/cli.js +4578 -2709
  3. package/package.json +5 -1
  4. package/templates/.gitkeep +0 -0
  5. package/templates/README.md +20 -0
  6. package/templates/agents/cbp-cc-executor.md +213 -0
  7. package/templates/agents/cbp-database-agent.md +229 -0
  8. package/templates/agents/cbp-improve-claude.md +245 -0
  9. package/templates/agents/cbp-improve-round.md +284 -0
  10. package/templates/agents/cbp-mechanical-edits.md +111 -0
  11. package/templates/agents/cbp-research.md +282 -0
  12. package/templates/agents/cbp-round-executor.md +604 -0
  13. package/templates/agents/cbp-security-agent.md +134 -0
  14. package/templates/agents/cbp-task-check.md +213 -0
  15. package/templates/agents/cbp-task-planner.md +582 -0
  16. package/templates/agents/cbp-test-e2e-agent.md +363 -0
  17. package/templates/agents/cbp-testing-qa-agent.md +400 -0
  18. package/templates/context/mcp-docs.md +139 -0
  19. package/templates/hooks/README.md +236 -0
  20. package/templates/hooks/cbp-auto-test-hooks.sh +44 -0
  21. package/templates/hooks/cbp-lint-format-on-edit.sh +159 -0
  22. package/templates/hooks/cbp-maestro-yaml-validate.sh +100 -0
  23. package/templates/hooks/cbp-mcp-migration-guard.sh +32 -0
  24. package/templates/hooks/cbp-mcp-round-sync.sh +79 -0
  25. package/templates/hooks/cbp-mcp-worktree-inject.sh +76 -0
  26. package/templates/hooks/cbp-notify.sh +68 -0
  27. package/templates/hooks/cbp-plugin-dispatch.sh +29 -0
  28. package/templates/hooks/cbp-pre-commit-quality-gate.sh +204 -0
  29. package/templates/hooks/cbp-statusline.sh +347 -0
  30. package/templates/hooks/cbp-subagent-statusline.sh +182 -0
  31. package/templates/hooks/cbp-test-coverage-gate.sh +144 -0
  32. package/templates/hooks/cbp-test-hooks.sh +320 -0
  33. package/templates/hooks/hooks.json +85 -0
  34. package/templates/hooks/validate-context-usage.sh +59 -0
  35. package/templates/hooks/validate-git-commit.sh +78 -0
  36. package/templates/hooks/validate-git-stash-deny.sh +32 -0
  37. package/templates/hooks/validate-structure-lengths.sh +57 -0
  38. package/templates/hooks/validate-structure-lib.sh +104 -0
  39. package/templates/hooks/validate-structure-patterns.sh +54 -0
  40. package/templates/hooks/validate-structure-scope.sh +33 -0
  41. package/templates/hooks/validate-structure-smoke.sh +95 -0
  42. package/templates/hooks/validate-structure-templates.sh +34 -0
  43. package/templates/hooks/validate-structure.sh +69 -0
  44. package/templates/rules/.gitkeep +0 -0
  45. package/templates/rules/README.md +47 -0
  46. package/templates/rules/context-file-loading.md +52 -0
  47. package/templates/rules/scope-vocabulary.md +64 -0
  48. package/templates/rules/todo-backend.md +109 -0
  49. package/templates/settings.project.base.json +55 -0
  50. package/templates/settings.user.base.json +25 -0
  51. package/templates/skills/cbp-build-cc-agent/SKILL.md +139 -0
  52. package/templates/skills/cbp-build-cc-agent/examples/read-only-reviewer.md +32 -0
  53. package/templates/skills/cbp-build-cc-agent/examples/with-hooks.md +41 -0
  54. package/templates/skills/cbp-build-cc-agent/examples/with-skills-preload.md +25 -0
  55. package/templates/skills/cbp-build-cc-agent/reference/cbp-quality.md +153 -0
  56. package/templates/skills/cbp-build-cc-agent/reference/frontmatter-fields.md +37 -0
  57. package/templates/skills/cbp-build-cc-agent/reference/permission-modes.md +18 -0
  58. package/templates/skills/cbp-build-cc-agent/scripts/validate-agent.sh +67 -0
  59. package/templates/skills/cbp-build-cc-agent/templates/agent.md +66 -0
  60. package/templates/skills/cbp-build-cc-claude-file/SKILL.md +178 -0
  61. package/templates/skills/cbp-build-cc-claude-file/examples/minimal-project.md +33 -0
  62. package/templates/skills/cbp-build-cc-claude-file/examples/monorepo-with-imports.md +39 -0
  63. package/templates/skills/cbp-build-cc-claude-file/reference/imports.md +72 -0
  64. package/templates/skills/cbp-build-cc-claude-file/reference/what-belongs.md +39 -0
  65. package/templates/skills/cbp-build-cc-claude-file/templates/project-claude-md.md +48 -0
  66. package/templates/skills/cbp-build-cc-claude-file/templates/user-claude-md.md +22 -0
  67. package/templates/skills/cbp-build-cc-memory/SKILL.md +201 -0
  68. package/templates/skills/cbp-build-cc-memory/examples/feedback-memory.md +11 -0
  69. package/templates/skills/cbp-build-cc-memory/examples/project-memory.md +11 -0
  70. package/templates/skills/cbp-build-cc-memory/examples/reference-memory.md +13 -0
  71. package/templates/skills/cbp-build-cc-memory/examples/user-memory.md +14 -0
  72. package/templates/skills/cbp-build-cc-memory/reference/memory-types.md +59 -0
  73. package/templates/skills/cbp-build-cc-memory/reference/when-to-save.md +62 -0
  74. package/templates/skills/cbp-build-cc-memory/templates/MEMORY-index.md +4 -0
  75. package/templates/skills/cbp-build-cc-memory/templates/memory-entry.md +15 -0
  76. package/templates/skills/cbp-build-cc-mode/SKILL.md +99 -0
  77. package/templates/skills/cbp-build-cc-rule/SKILL.md +176 -0
  78. package/templates/skills/cbp-build-cc-rule/examples/global-rule.md +19 -0
  79. package/templates/skills/cbp-build-cc-rule/examples/scoped-rule.md +41 -0
  80. package/templates/skills/cbp-build-cc-rule/reference/paths-patterns.md +48 -0
  81. package/templates/skills/cbp-build-cc-rule/templates/rule.md +32 -0
  82. package/templates/skills/cbp-build-cc-settings/SKILL.md +220 -0
  83. package/templates/skills/cbp-build-cc-settings/examples/hooks-config.json +64 -0
  84. package/templates/skills/cbp-build-cc-settings/examples/permissions-config.json +34 -0
  85. package/templates/skills/cbp-build-cc-settings/examples/sandbox-config.json +42 -0
  86. package/templates/skills/cbp-build-cc-settings/reference/cbp-conventions.md +104 -0
  87. package/templates/skills/cbp-build-cc-settings/reference/permission-rules.md +61 -0
  88. package/templates/skills/cbp-build-cc-settings/reference/scope-precedence.md +73 -0
  89. package/templates/skills/cbp-build-cc-settings/reference/settings-fields.md +166 -0
  90. package/templates/skills/cbp-build-cc-settings/templates/settings.json +23 -0
  91. package/templates/skills/cbp-build-cc-settings/templates/settings.local.json +10 -0
  92. package/templates/skills/cbp-build-cc-skill/SKILL.md +154 -0
  93. package/templates/skills/cbp-build-cc-skill/examples/dynamic-context.md +31 -0
  94. package/templates/skills/cbp-build-cc-skill/examples/fork-skill.md +22 -0
  95. package/templates/skills/cbp-build-cc-skill/examples/knowledge-skill.md +25 -0
  96. package/templates/skills/cbp-build-cc-skill/examples/task-skill.md +29 -0
  97. package/templates/skills/cbp-build-cc-skill/reference/cbp-quality.md +157 -0
  98. package/templates/skills/cbp-build-cc-skill/reference/frontmatter-fields.md +35 -0
  99. package/templates/skills/cbp-build-cc-skill/reference/string-substitutions.md +60 -0
  100. package/templates/skills/cbp-build-cc-skill/scripts/validate-skill.sh +90 -0
  101. package/templates/skills/cbp-build-cc-skill/templates/skill.md +51 -0
  102. package/templates/skills/cbp-checkpoint-check/SKILL.md +156 -0
  103. package/templates/skills/cbp-checkpoint-complete/SKILL.md +109 -0
  104. package/templates/skills/cbp-checkpoint-create/SKILL.md +287 -0
  105. package/templates/skills/cbp-checkpoint-end/SKILL.md +241 -0
  106. package/templates/skills/cbp-checkpoint-update/SKILL.md +115 -0
  107. package/templates/skills/cbp-frontend-a11y/SKILL.md +109 -0
  108. package/templates/skills/cbp-frontend-a11y/reference/aria-roles-states.md +130 -0
  109. package/templates/skills/cbp-frontend-a11y/reference/contrast-visual.md +122 -0
  110. package/templates/skills/cbp-frontend-a11y/reference/keyboard-patterns.md +154 -0
  111. package/templates/skills/cbp-frontend-a11y/reference/semantic-html.md +111 -0
  112. package/templates/skills/cbp-frontend-design/SKILL.md +145 -0
  113. package/templates/skills/cbp-frontend-design/reference/nextjs-scss.md +118 -0
  114. package/templates/skills/cbp-frontend-design/reference/rn-expo.md +101 -0
  115. package/templates/skills/cbp-frontend-design/reference/tauri-react.md +82 -0
  116. package/templates/skills/cbp-frontend-ui/SKILL.md +262 -0
  117. package/templates/skills/cbp-frontend-ui/reference/ui-label-maps.md +42 -0
  118. package/templates/skills/cbp-frontend-ui/reference/ui-layout-patterns.md +105 -0
  119. package/templates/skills/cbp-frontend-ui/reference/variant-defaults.md +149 -0
  120. package/templates/skills/cbp-frontend-ux/SKILL.md +181 -0
  121. package/templates/skills/cbp-git-branch-feat-create/SKILL.md +115 -0
  122. package/templates/skills/cbp-git-commit/SKILL.md +278 -0
  123. package/templates/skills/cbp-git-worktree-create/SKILL.md +226 -0
  124. package/templates/skills/cbp-git-worktree-remove/SKILL.md +145 -0
  125. package/templates/skills/cbp-merge-main/SKILL.md +228 -0
  126. package/templates/skills/cbp-round-check/SKILL.md +104 -0
  127. package/templates/skills/cbp-round-end/SKILL.md +183 -0
  128. package/templates/skills/cbp-round-end/reference/findings-presentation.md +44 -0
  129. package/templates/skills/cbp-round-end/reference/inline-fallback.md +35 -0
  130. package/templates/skills/cbp-round-execute/SKILL.md +211 -0
  131. package/templates/skills/cbp-round-execute/reference/inline-fallback.md +59 -0
  132. package/templates/skills/cbp-round-input/SKILL.md +165 -0
  133. package/templates/skills/cbp-round-start/SKILL.md +222 -0
  134. package/templates/skills/cbp-round-update/SKILL.md +163 -0
  135. package/templates/skills/cbp-session-end/SKILL.md +187 -0
  136. package/templates/skills/cbp-session-start/SKILL.md +155 -0
  137. package/templates/skills/cbp-ship/SKILL.md +332 -0
  138. package/templates/skills/cbp-ship/reference/changesets-overview.md +120 -0
  139. package/templates/skills/cbp-ship/reference/eas-cli-overview.md +60 -0
  140. package/templates/skills/cbp-ship/reference/gh-cli-overview.md +135 -0
  141. package/templates/skills/cbp-ship/reference/gh-cli-shipment-commands.md +283 -0
  142. package/templates/skills/cbp-ship/reference/npm-publish-monorepo.md +252 -0
  143. package/templates/skills/cbp-ship/reference/npm-publish-oidc-trusted.md +157 -0
  144. package/templates/skills/cbp-ship/reference/npm-publish-overview.md +171 -0
  145. package/templates/skills/cbp-ship/reference/preflight-checklist.md +88 -0
  146. package/templates/skills/cbp-ship/reference/railway-nestjs-deployment.md +169 -0
  147. package/templates/skills/cbp-ship/reference/railway-overview.md +120 -0
  148. package/templates/skills/cbp-ship/reference/railway-troubleshooting.md +168 -0
  149. package/templates/skills/cbp-ship/reference/release-please-overview.md +99 -0
  150. package/templates/skills/cbp-ship/reference/surface-expo-eas.md +155 -0
  151. package/templates/skills/cbp-ship/reference/surface-npm.md +180 -0
  152. package/templates/skills/cbp-ship/reference/surface-railway.md +152 -0
  153. package/templates/skills/cbp-ship/reference/surface-supabase.md +178 -0
  154. package/templates/skills/cbp-ship/reference/surface-tauri.md +138 -0
  155. package/templates/skills/cbp-ship/reference/surface-vercel.md +124 -0
  156. package/templates/skills/cbp-ship/reference/surface-vscode-ext.md +144 -0
  157. package/templates/skills/cbp-ship/reference/surfaces.md +60 -0
  158. package/templates/skills/cbp-ship/reference/testflight-automation.md +215 -0
  159. package/templates/skills/cbp-ship/reference/testflight-internal-vs-external.md +69 -0
  160. package/templates/skills/cbp-ship/reference/testflight-overview.md +98 -0
  161. package/templates/skills/cbp-ship/reference/versioning.md +116 -0
  162. package/templates/skills/cbp-ship/scripts/detect-surfaces.sh +217 -0
  163. package/templates/skills/cbp-ship/scripts/verify-expo-eas.sh +35 -0
  164. package/templates/skills/cbp-ship/scripts/verify-npm.sh +21 -0
  165. package/templates/skills/cbp-ship/scripts/verify-railway.sh +41 -0
  166. package/templates/skills/cbp-ship/scripts/verify-supabase.sh +19 -0
  167. package/templates/skills/cbp-ship/scripts/verify-tauri.sh +24 -0
  168. package/templates/skills/cbp-ship/scripts/verify-vercel.sh +32 -0
  169. package/templates/skills/cbp-ship/scripts/verify-vscode-ext.sh +25 -0
  170. package/templates/skills/cbp-ship/templates/eas.json +66 -0
  171. package/templates/skills/cbp-ship/templates/railway.toml +15 -0
  172. package/templates/skills/cbp-ship/templates/release-please-config.json +17 -0
  173. package/templates/skills/cbp-ship/templates/vercel.json +19 -0
  174. package/templates/skills/cbp-ship/templates/vscodeignore +21 -0
  175. package/templates/skills/cbp-ship/templates/workflow-changesets.yml +41 -0
  176. package/templates/skills/cbp-ship/templates/workflow-eas-submit.yml +53 -0
  177. package/templates/skills/cbp-ship/templates/workflow-npm-publish.yml +36 -0
  178. package/templates/skills/cbp-ship/templates/workflow-release-please.yml +21 -0
  179. package/templates/skills/cbp-ship/templates/workflow-tauri-release.yml +69 -0
  180. package/templates/skills/cbp-ship/templates/workflow-vsce-publish.yml +31 -0
  181. package/templates/skills/cbp-ship-configure/SKILL.md +296 -0
  182. package/templates/skills/cbp-ship-configure/reference/expo-mobile.md +204 -0
  183. package/templates/skills/cbp-ship-configure/reference/npm-package.md +165 -0
  184. package/templates/skills/cbp-ship-configure/reference/railway-backend.md +199 -0
  185. package/templates/skills/cbp-ship-configure/reference/supabase.md +200 -0
  186. package/templates/skills/cbp-ship-configure/reference/tauri-desktop.md +181 -0
  187. package/templates/skills/cbp-ship-configure/reference/vercel.md +117 -0
  188. package/templates/skills/cbp-ship-configure/reference/vscode-ext.md +155 -0
  189. package/templates/skills/cbp-ship-main/SKILL.md +65 -0
  190. package/templates/skills/cbp-supabase-branch-check/SKILL.md +337 -0
  191. package/templates/skills/cbp-supabase-branch-check/reference/dag-steps.md +29 -0
  192. package/templates/skills/cbp-supabase-migrate/SKILL.md +314 -0
  193. package/templates/skills/cbp-supabase-migrate/reference/advisor-triage.md +70 -0
  194. package/templates/skills/cbp-supabase-migrate/reference/cli-fallback.md +87 -0
  195. package/templates/skills/cbp-supabase-migrate/reference/preflight-dry-run.md +58 -0
  196. package/templates/skills/cbp-supabase-setup/SKILL.md +239 -0
  197. package/templates/skills/cbp-supabase-setup/reference/branching-setup.md +121 -0
  198. package/templates/skills/cbp-supabase-setup/reference/cli-fallback.md +109 -0
  199. package/templates/skills/cbp-task-check/SKILL.md +166 -0
  200. package/templates/skills/cbp-task-complete/SKILL.md +206 -0
  201. package/templates/skills/cbp-task-complete/reference/checkpoint-done-branching.md +48 -0
  202. package/templates/skills/cbp-task-complete/reference/next-step-heuristic.md +56 -0
  203. package/templates/skills/cbp-task-create/SKILL.md +167 -0
  204. package/templates/skills/cbp-task-start/SKILL.md +239 -0
  205. package/templates/skills/cbp-task-testing/SKILL.md +277 -0
  206. package/templates/skills/cbp-todo/SKILL.md +97 -0
@@ -0,0 +1,155 @@
1
+ # Configure: vscode-ext
2
+
3
+ Walkthrough for first-time VS Code Marketplace publish setup.
4
+
5
+ ## Prerequisites
6
+
7
+ - Microsoft account (free) — for Azure DevOps + marketplace publisher
8
+ - Azure DevOps organization (free) — https://dev.azure.com
9
+ - Marketplace publisher account — https://marketplace.visualstudio.com/manage
10
+
11
+ ## Probe
12
+
13
+ ```bash
14
+ test -f package.json && jq -e '.engines.vscode' package.json >/dev/null || { echo "Not a VS Code extension"; exit 1; }
15
+ which npx
16
+ npx @vscode/vsce --version || { echo "Will install vsce on first use (npm i -g @vscode/vsce)"; }
17
+ ```
18
+
19
+ ## Setup walkthrough
20
+
21
+ ### Step 1/6: Create publisher (if first time)
22
+
23
+ Direct user to:
24
+
25
+ ```
26
+ 1. Go to https://marketplace.visualstudio.com/manage/createpublisher
27
+ 2. Choose a publisher ID (lowercase, hyphens — must be globally unique)
28
+ 3. Enter display name + email
29
+
30
+ Reply with the publisher ID when done.
31
+ ```
32
+
33
+ ### Step 2/6: Generate Personal Access Token (PAT)
34
+
35
+ ```
36
+ 1. Go to https://dev.azure.com/<your-org>/_usersSettings/tokens
37
+ 2. Click 'New Token'
38
+ 3. Name: 'vsce publish'
39
+ 4. Organization: 'All accessible organizations' (CRITICAL — not just your org)
40
+ 5. Expiration: 1 year (note: PATs expire; you'll need to rotate)
41
+ 6. Scopes: Custom Defined → Marketplace → Manage
42
+
43
+ Click Create. Copy the token.
44
+
45
+ Reply 'done' when copied. Keep the token in a safe place — you can't see it again.
46
+ ```
47
+
48
+ ### Step 3/6: Verify PAT works
49
+
50
+ ```bash
51
+ PUBLISHER=$(jq -r .publisher package.json)
52
+ npx @vscode/vsce verify-pat "$PUBLISHER"
53
+ # Will prompt for the PAT
54
+ ```
55
+
56
+ If verification fails, walk the user through:
57
+
58
+ - Wrong scope (not Marketplace → Manage) — most common
59
+ - Token belongs to wrong organization (must be "All accessible")
60
+ - Token expired
61
+
62
+ ### Step 4/6: Verify package.json metadata
63
+
64
+ VS Code Marketplace requires more metadata than npm:
65
+
66
+ ```
67
+ Required:
68
+ name ✓
69
+ displayName ✓ (human-readable name)
70
+ description ✓ (1-2 sentences)
71
+ publisher ✓ (matches step 1)
72
+ version ✓
73
+ engines.vscode ✓ (minimum version, e.g., "^1.85.0")
74
+ categories ✓ (e.g., ["Programming Languages", "Linters"])
75
+ icon ✓ (PNG ≥128×128, in repo root)
76
+ repository ✓ (public GH URL)
77
+
78
+ Recommended:
79
+ keywords (improves search)
80
+ galleryBanner (color theme)
81
+ activationEvents (when extension activates)
82
+ contributes (commands, settings, etc.)
83
+ ```
84
+
85
+ ### Step 5/6: Validate `.vscodeignore`
86
+
87
+ VS Code packages can balloon if `.vscodeignore` is too lax:
88
+
89
+ ```bash
90
+ cd "$EXT_PATH"
91
+ if [ ! -f .vscodeignore ]; then
92
+ cp ${CLAUDE_PLUGIN_ROOT}/skills/ship/templates/vscodeignore .vscodeignore
93
+ fi
94
+
95
+ npx @vscode/vsce ls
96
+ # Lists what would be packaged. If size > 5MB or includes node_modules, fix .vscodeignore
97
+ ```
98
+
99
+ A reasonable `.vscodeignore`:
100
+
101
+ ```
102
+ .vscode/**
103
+ .vscode-test/**
104
+ src/**
105
+ .gitignore
106
+ .yarnrc
107
+ vsc-extension-quickstart.md
108
+ **/tsconfig.json
109
+ **/.eslintrc.*
110
+ **/*.map
111
+ **/*.ts
112
+ node_modules
113
+ .git/**
114
+ *.test.*
115
+ *.spec.*
116
+ ```
117
+
118
+ ### Step 6/6: Persist + dry-run
119
+
120
+ ```json
121
+ {
122
+ "surfaces": {
123
+ "vscode-ext": {
124
+ "configured_at": "<now>",
125
+ "ext_path": "apps/vscode",
126
+ "publisher": "<publisher>",
127
+ "extension_id": "<publisher>.<name>",
128
+ "marketplace_url": "https://marketplace.visualstudio.com/items?itemName=<publisher>.<name>",
129
+ "versioning": "manual"
130
+ }
131
+ }
132
+ }
133
+ ```
134
+
135
+ Dry-run package:
136
+
137
+ ```bash
138
+ cd "$EXT_PATH"
139
+ npx @vscode/vsce package --no-yarn -o /tmp/dryrun.vsix
140
+ ls -lh /tmp/dryrun.vsix
141
+ # Sanity-check size
142
+ ```
143
+
144
+ ## Done
145
+
146
+ Surface is ready. `/cbp-ship` will offer marketplace publish when version bumps.
147
+
148
+ ## Common setup issues
149
+
150
+ | Symptom | Fix |
151
+ |---|---|
152
+ | `vsce verify-pat` fails | PAT scope wrong: must be Marketplace → Manage, not Code → Read |
153
+ | Icon validation fails | PNG, ≥128×128 (256×256 recommended), no transparency in marketplace listing |
154
+ | README rendering broken in marketplace | Marketplace renders GitHub-flavored markdown but with limited image hosts; use raw.githubusercontent.com URLs |
155
+ | "Extension contains script" warning | Inline `<script>` in webview HTML — use CSP nonces |
@@ -0,0 +1,65 @@
1
+ ---
2
+ scope: org-shared
3
+ name: cbp-ship-main
4
+ description: Ship feat branch to production branch via PR — thin wrapper around `codebyplan ship`
5
+ model: sonnet
6
+ effort: high
7
+ ---
8
+
9
+ # Ship Main Command
10
+
11
+ Compose a PR body from checkpoint context, then delegate all git/gh mechanics to `codebyplan ship`.
12
+
13
+ ## Instructions
14
+
15
+ ### Step 1: Read Checkpoint Context
16
+
17
+ Use MCP `get_current_task` (repo_id) to get the active checkpoint. Collect `checkpoint.title`, completed task titles (`get_tasks(checkpoint_id)` filtered to `status === 'completed'`), and key decisions from `checkpoint.context.decisions[]`.
18
+
19
+ ### Step 2: Compose PR Body
20
+
21
+ Write to `/tmp/cbp-ship-main-body.md`:
22
+
23
+ ```markdown
24
+ ## Summary
25
+
26
+ {checkpoint.title}
27
+
28
+ ## Tasks Completed
29
+
30
+ {bullet list of completed task titles}
31
+
32
+ ## Key Changes
33
+
34
+ {2–5 bullets from decisions or task requirements}
35
+
36
+ ## Test Plan
37
+
38
+ - All rounds passed testing-qa
39
+ - /cbp-checkpoint-check passed
40
+ ```
41
+
42
+ ### Step 3: Invoke `codebyplan ship`
43
+
44
+ ```bash
45
+ # DRY_RUN is non-empty when the skill was invoked with a dry-run arg; otherwise empty.
46
+ codebyplan ship --body-file /tmp/cbp-ship-main-body.md --json${DRY_RUN:+ --dry-run}
47
+ ```
48
+
49
+ Pass `--dry-run` through if the skill was invoked with a dry-run arg.
50
+
51
+ ### Step 4: Report
52
+
53
+ Parse JSON from Step 3. Report `pr_url`, `merge_commit`, `branch_deleted`. If `checks_failed: true`, surface `checks_failure_reason` and stop.
54
+
55
+ ## Key Rules
56
+
57
+ - **Read branch names from config** — never hardcode "main"
58
+ - **Never force push** — always via PR (enforced by `codebyplan ship`)
59
+ - **Pass --dry-run through** when skill is invoked with dry-run arg
60
+
61
+ ## Integration
62
+
63
+ - **Called by**: `/cbp-checkpoint-end`
64
+ - **Delegates to**: `codebyplan ship` CLI
65
+ - **Reads**: MCP `get_current_task`, `get_tasks`
@@ -0,0 +1,337 @@
1
+ ---
2
+ scope: org-shared
3
+ name: cbp-supabase-branch-check
4
+ description: Gate skill called by /cbp-ship-main (pre-merge) to verify the Supabase preview branch health check is green before allowing a PR to be merged; skips when no DB-path changes are detected.
5
+ argument-hint: "[--mode pre_pr_create|pre_merge] [--target integration|production]"
6
+ allowed-tools: Bash(git *), Bash(gh *), Bash(jq *), Bash(supabase *), Bash(sleep *), Bash(echo *), Read, mcp__supabase__list_branches, mcp__supabase__get_logs
7
+ model: sonnet
8
+ effort: xhigh
9
+ ---
10
+
11
+ # Supabase Branch Check
12
+
13
+ Gate skill invoked by `/cbp-ship-main` to verify the Supabase preview branch GitHub check
14
+ is green before allowing a PR to be merged. When no DB-path changes exist on the current
15
+ branch, the skill emits `skipped` immediately — no polling occurs.
16
+
17
+ ## Arguments
18
+
19
+ Inspect `$ARGUMENTS`:
20
+
21
+ - `--mode pre_pr_create` — soft mode; `pending_pr` is a pass-through (PR not open yet). Default target: `integration`.
22
+ - `--mode pre_merge` — hard mode (default); `pending_pr` or `blocked` refuse merge. Default target: auto-detect from PR base.
23
+ - `--target integration|production` — override target branch lookup.
24
+
25
+ ## Return Contract
26
+
27
+ Every exit path emits a fenced JSON block in chat output so callers can parse deterministically:
28
+
29
+ ```json
30
+ { "status": "passed|skipped|pending_pr|blocked",
31
+ "reason": "human-readable string",
32
+ "failed_step": "clone|pull|health|configure|migrate|seed|deploy",
33
+ "log_excerpt": "verbatim first ~500 chars" }
34
+ ```
35
+
36
+ `failed_step` and `log_excerpt` are only included on `blocked` triggered by a DAG failure.
37
+
38
+ ## Step 0 — Parse Arguments
39
+
40
+ ```bash
41
+ MODE="pre_merge"
42
+ TARGET=""
43
+
44
+ while [[ $# -gt 0 ]]; do
45
+ case "$1" in
46
+ --mode) MODE="$2"; shift 2 ;;
47
+ --target) TARGET="$2"; shift 2 ;;
48
+ *) shift ;;
49
+ esac
50
+ done
51
+ ```
52
+
53
+ Validate `MODE`: must be `pre_pr_create` or `pre_merge`. If invalid, stop with error:
54
+
55
+ ```
56
+ Invalid --mode value: <value>. Valid values: pre_pr_create, pre_merge.
57
+ ```
58
+
59
+ Infer `TARGET` when absent:
60
+ - `pre_pr_create` → `integration`
61
+ - `pre_merge` → detect via `gh pr view --json baseRefName --jq '.baseRefName'`; fallback to `integration` if no PR is open.
62
+
63
+ ## Step 1 — Read DB Paths Config
64
+
65
+ Read `.codebyplan.json` to obtain the configured DB path globs:
66
+
67
+ ```bash
68
+ DB_PATHS=$(jq -r '.shipment.surfaces.supabase.db_paths[]? // empty' .codebyplan.json 2>/dev/null)
69
+ ```
70
+
71
+ If `DB_PATHS` is empty, fall back to defaults:
72
+
73
+ ```bash
74
+ if [ -z "$DB_PATHS" ]; then
75
+ DB_PATHS=$(printf '%s\n' 'supabase/**' 'apps/backend/**' 'packages/**/db/**')
76
+ fi
77
+ ```
78
+
79
+ Store each pattern as a separate entry for matching in Step 2.
80
+
81
+ ## Step 2 — Detect DB-Path Changes
82
+
83
+ Resolve the BASE branch from `TARGET`. Read `.codebyplan.json`:
84
+
85
+ ```bash
86
+ INTEGRATION=$(jq -r '.branch_config.integration // "development"' .codebyplan.json)
87
+ PRODUCTION=$(jq -r '.branch_config.production // "main"' .codebyplan.json)
88
+ ```
89
+
90
+ Set `BASE`:
91
+ - `TARGET=integration` → `BASE="$INTEGRATION"`
92
+ - `TARGET=production` → `BASE="$PRODUCTION"`
93
+
94
+ Run git diff to list changed files:
95
+
96
+ ```bash
97
+ git fetch origin "$BASE" 2>/dev/null
98
+ CHANGED_FILES=$(git diff --name-only "origin/$BASE"...HEAD)
99
+ ```
100
+
101
+ ```bash
102
+ if [ -z "$CHANGED_FILES" ]; then
103
+ # No files changed at all — soft-skip
104
+ emit { "status": "skipped", "reason": "No file changes against $BASE" } and exit
105
+ fi
106
+ ```
107
+
108
+ Match each changed file against each DB path pattern using bash globstar:
109
+
110
+ ```bash
111
+ shopt -s globstar
112
+ MATCHED=false
113
+ while IFS= read -r file; do
114
+ for pattern in $DB_PATHS; do
115
+ # bash 4+ supports ** in [[ ]] glob matching
116
+ if [[ "$file" == $pattern ]]; then
117
+ MATCHED=true
118
+ break 2
119
+ fi
120
+ done
121
+ done <<< "$CHANGED_FILES"
122
+ ```
123
+
124
+ If `MATCHED=false`, emit and exit:
125
+
126
+ ```json
127
+ {
128
+ "status": "skipped",
129
+ "reason": "No DB-path changes detected against <BASE>"
130
+ }
131
+ ```
132
+
133
+ ## Step 3 — Resolve project_ref
134
+
135
+ ```bash
136
+ BRANCH=$(git branch --show-current)
137
+ ```
138
+
139
+ **MCP path (preferred)**: Call `mcp__supabase__list_branches`. Filter the returned array for the
140
+ entry where the git-branch field matches `$BRANCH`. The field name varies by API version —
141
+ check `git_branch`, `branch_name`, or `ref` at runtime; use the first non-null value.
142
+ Extract `project_ref` from the matched entry.
143
+
144
+ **CLI fallback** (when MCP unavailable):
145
+
146
+ ```bash
147
+ if ! command -v supabase >/dev/null 2>&1; then
148
+ # CLI not installed — explicit blocked status (avoids misleading "no preview")
149
+ emit { "status": "blocked", "reason": "supabase CLI not installed — run: npm i -g supabase" } and exit
150
+ fi
151
+ supabase --experimental branches get "$BRANCH" -o env \
152
+ | grep 'SUPABASE_PROJECT_REF' | cut -d= -f2
153
+ ```
154
+
155
+ Store as `PROJECT_REF`.
156
+
157
+ ## Step 4 — Handle Missing project_ref
158
+
159
+ If `PROJECT_REF` is empty after Step 3:
160
+
161
+ - `MODE=pre_pr_create`:
162
+
163
+ ```json
164
+ {
165
+ "status": "pending_pr",
166
+ "reason": "Push commit + open PR — Supabase creates the preview branch when the PR opens"
167
+ }
168
+ ```
169
+
170
+ Exit (soft pass — caller proceeds to create the PR).
171
+
172
+ - `MODE=pre_merge`:
173
+
174
+ ```json
175
+ {
176
+ "status": "blocked",
177
+ "reason": "No Supabase preview branch found for <BRANCH>. Push commit and open a PR first."
178
+ }
179
+ ```
180
+
181
+ Exit (hard block).
182
+
183
+ ## Step 5 — PR Existence Check
184
+
185
+ Verify an open PR exists for this branch:
186
+
187
+ ```bash
188
+ PR_JSON=$(gh pr view --json number,baseRefName 2>/dev/null)
189
+ PR_NUMBER=$(echo "$PR_JSON" | jq -r '.number // empty')
190
+ ```
191
+
192
+ ```bash
193
+ if [ -z "$PR_NUMBER" ] && [ "$MODE" = "pre_pr_create" ]; then
194
+ # No PR yet — Supabase will create the preview branch when the PR opens
195
+ emit { "status": "pending_pr", "reason": "No PR open yet for branch <BRANCH>; open a PR and re-run" } and exit
196
+ fi
197
+ ```
198
+
199
+ If `PR_NUMBER` is empty AND `MODE=pre_merge`:
200
+
201
+ ```json
202
+ {
203
+ "status": "blocked",
204
+ "reason": "No PR open for branch <BRANCH>; cannot verify Supabase Preview check"
205
+ }
206
+ ```
207
+
208
+ Exit. (With the pre_pr_create guard above, pre_merge is the only mode that reaches this point with an empty PR_NUMBER.)
209
+
210
+ ## Step 6 — Bounded Poll: Supabase Preview Check
211
+
212
+ Poll the GitHub PR checks for the `Supabase Preview` status check. Cap at 20 iterations
213
+ with 15 seconds between each (5-minute ceiling total).
214
+
215
+ ```bash
216
+ FAILED=false
217
+
218
+ for i in $(seq 1 20); do
219
+ # Primary: gh ≥2.32 (Jul 2023) supports `bucket` (pass|fail|pending|skipping|cancel).
220
+ # Fallback: older gh omits bucket — request name,state and let jq derive bucket from state.
221
+ CHECK_JSON=$(gh pr checks "$PR_NUMBER" --json name,bucket,state 2>/dev/null \
222
+ || gh pr checks "$PR_NUMBER" --json name,state 2>/dev/null)
223
+
224
+ BUCKET=$(echo "$CHECK_JSON" \
225
+ | jq -r '.[] | select(.name == "Supabase Preview") |
226
+ (.bucket //
227
+ (.state |
228
+ if . == "SUCCESS" then "pass"
229
+ elif . == "SKIPPED" or . == "NEUTRAL" then "skipping"
230
+ elif . == "FAILURE" or . == "ERROR" or . == "CANCELLED"
231
+ or . == "STALE" or . == "ACTION_REQUIRED"
232
+ or . == "TIMED_OUT" then "fail"
233
+ else "pending" end))
234
+ // empty')
235
+
236
+ case "$BUCKET" in
237
+ pass)
238
+ break
239
+ ;;
240
+ skipping)
241
+ break
242
+ ;;
243
+ pending)
244
+ echo "poll $i/20: Supabase Preview bucket=$BUCKET, sleeping 15s"
245
+ sleep 15
246
+ ;;
247
+ fail)
248
+ FAILED=true
249
+ break
250
+ ;;
251
+ cancel)
252
+ FAILED=true
253
+ break
254
+ ;;
255
+ "")
256
+ echo "poll $i/20: Supabase Preview not yet in check list, sleeping 15s"
257
+ sleep 15
258
+ ;;
259
+ esac
260
+ done
261
+ ```
262
+
263
+ After the loop, dispatch on the final `$BUCKET` and `$FAILED` state:
264
+
265
+ ```bash
266
+ if [ "$FAILED" = "true" ]; then
267
+ : # proceed to Step 7 (failure path)
268
+ elif [ "$BUCKET" = "pass" ] || [ "$BUCKET" = "skipping" ]; then
269
+ : # proceed to Step 8 (success path — pass/skipping branches differ below)
270
+ else
271
+ # Loop exhausted with $BUCKET still "pending" or empty — emit timeout.
272
+ if [ -n "$BUCKET" ]; then
273
+ REASON="Supabase Preview still $BUCKET after 5 min (20 polls)"
274
+ else
275
+ REASON="Supabase Preview not found in check list after 5 min (20 polls)"
276
+ fi
277
+ fi
278
+ ```
279
+
280
+ Timeout emit (when loop exhausted):
281
+
282
+ ```json
283
+ {
284
+ "status": "blocked",
285
+ "reason": "<REASON computed above>"
286
+ }
287
+ ```
288
+
289
+ ## Step 7 — Failure: Fetch Logs and Map DAG Step
290
+
291
+ Read `reference/dag-steps.md` for DAG step → service mapping. Attempt to read the failed
292
+ step name from the check output (`description` or `name` field).
293
+
294
+ Query logs in priority order until a non-empty result is obtained:
295
+ 1. `mcp__supabase__get_logs(project_ref=PROJECT_REF, service="postgres")` — migrate/seed/health
296
+ 2. `mcp__supabase__get_logs(project_ref=PROJECT_REF, service="api")` — clone/pull/configure
297
+ 3. `mcp__supabase__get_logs(project_ref=PROJECT_REF, service="edge-function")` — deploy only
298
+
299
+ Cap excerpt at first 500 chars of the first non-empty result.
300
+
301
+ ```json
302
+ {
303
+ "status": "blocked",
304
+ "reason": "<human-readable description of the failure>",
305
+ "failed_step": "<clone|pull|health|configure|migrate|seed|deploy>",
306
+ "log_excerpt": "<verbatim first ~500 chars of logs>"
307
+ }
308
+ ```
309
+
310
+ ## Step 8 — Success
311
+
312
+ Two sub-cases distinguished by `$BUCKET`:
313
+
314
+ When `$BUCKET = pass` (check ran and passed):
315
+
316
+ ```json
317
+ {
318
+ "status": "passed",
319
+ "reason": "Supabase Preview check green for branch <BRANCH>"
320
+ }
321
+ ```
322
+
323
+ When `$BUCKET = skipping` (check skipped at CI level — e.g. Supabase decided no preview was needed despite this skill's earlier DB-path check passing):
324
+
325
+ ```json
326
+ {
327
+ "status": "passed",
328
+ "reason": "Supabase Preview check skipped at CI for branch <BRANCH>"
329
+ }
330
+ ```
331
+
332
+ Both emit `status: passed` so callers proceed; the `reason` differs for traceability.
333
+
334
+ ## Integration
335
+
336
+ **Callers**: `/cbp-ship-main` invokes this skill pre-merge (mode=`pre_merge`, target=`production`, no override).
337
+ **Tools used**: `mcp__supabase__list_branches` for project_ref resolution; `mcp__supabase__get_logs` for failure diagnostics; `gh pr checks` for status polling; `supabase --experimental branches get` as CLI fallback.
@@ -0,0 +1,29 @@
1
+ ---
2
+ scope: org-shared
3
+ ---
4
+
5
+ # DAG Steps — Supabase Preview Branch
6
+
7
+ Reference for cbp-supabase-branch-check Step 7. Maps each Supabase branching DAG step
8
+ to its likely root cause, recommended user action, and the get_logs service to query.
9
+
10
+ ## Mapping Table
11
+
12
+ | DAG Step | Likely Root Cause | User Action | get_logs service |
13
+ |------------|--------------------------------------------------------|--------------------------------------------------------------------|------------------|
14
+ | clone | Repository not accessible to Supabase app | Re-authorize GitHub app in Supabase dashboard | api |
15
+ | pull | Branch not pushed to remote | git push origin <branch> | api |
16
+ | health | Preview DB failed to provision | Check Supabase status page; retry via dashboard | postgres |
17
+ | configure | supabase/config.toml parse error or missing block | Check config.toml syntax; verify [remotes.*] block | api |
18
+ | migrate | Migration SQL error (syntax, constraint) | Fix migration file, re-push branch | postgres |
19
+ | seed | seed.sql error or timeout | Check supabase/seed.sql; reduce seed size | postgres |
20
+ | deploy | Edge function deploy failure | Check edge function logs; verify function syntax | edge-function |
21
+
22
+ ## Service Selection Logic
23
+
24
+ When the DAG step name is not visible in the log, query in this order:
25
+ 1. `postgres` — covers migration, seed, and health failures (most common)
26
+ 2. `api` — covers clone, pull, configure failures
27
+ 3. `edge-function` — only for deploy step failures
28
+
29
+ Provide the first non-empty log result to the user as the `log_excerpt`.