codebyplan 1.13.61 → 1.13.63

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 (76) hide show
  1. package/dist/cli.js +1140 -2065
  2. package/package.json +1 -1
  3. package/templates/agents/cbp-e2e-maestro.md +1 -1
  4. package/templates/agents/cbp-e2e-playwright.md +11 -11
  5. package/templates/agents/cbp-e2e-tauri.md +1 -1
  6. package/templates/agents/cbp-e2e-vscode.md +1 -1
  7. package/templates/agents/cbp-e2e-xcuitest.md +1 -1
  8. package/templates/hooks/cbp-mcp-round-sync.sh +4 -15
  9. package/templates/hooks/cbp-test-hooks.sh +0 -81
  10. package/templates/hooks/hooks.json +0 -9
  11. package/templates/rules/cbp-operating-gotchas.md +8 -10
  12. package/templates/rules/effort-and-ultracode.md +70 -0
  13. package/templates/rules/model-invocation-convention.md +1 -0
  14. package/templates/rules/supabase-branch-lifecycle.md +2 -2
  15. package/templates/rules/todo-backend.md +11 -8
  16. package/templates/rules/workflow-orchestration.md +59 -0
  17. package/templates/settings.project.base.json +0 -5
  18. package/templates/skills/cbp-build-cc-agent/SKILL.md +1 -0
  19. package/templates/skills/cbp-build-cc-claude-file/SKILL.md +1 -0
  20. package/templates/skills/cbp-build-cc-mode/SKILL.md +25 -17
  21. package/templates/skills/cbp-build-cc-rule/SKILL.md +1 -0
  22. package/templates/skills/cbp-build-cc-settings/SKILL.md +1 -0
  23. package/templates/skills/cbp-build-cc-settings/reference/cbp-permission-policy.md +1 -1
  24. package/templates/skills/cbp-build-cc-settings/reference/settings-fields.md +1 -1
  25. package/templates/skills/cbp-build-cc-skill/SKILL.md +2 -1
  26. package/templates/skills/cbp-build-cc-skill/reference/frontmatter-fields.md +1 -1
  27. package/templates/skills/cbp-build-cc-skill/scripts/validate-skill.sh +12 -9
  28. package/templates/skills/cbp-checkpoint-check/SKILL.md +5 -0
  29. package/templates/skills/cbp-checkpoint-complete/SKILL.md +1 -0
  30. package/templates/skills/cbp-checkpoint-create/SKILL.md +13 -22
  31. package/templates/skills/cbp-checkpoint-end/SKILL.md +42 -0
  32. package/templates/skills/cbp-checkpoint-plan/SKILL.md +15 -8
  33. package/templates/skills/cbp-checkpoint-start/SKILL.md +28 -19
  34. package/templates/skills/cbp-checkpoint-update/SKILL.md +3 -2
  35. package/templates/skills/cbp-clear-continue/SKILL.md +2 -1
  36. package/templates/skills/cbp-clear-prep/SKILL.md +2 -1
  37. package/templates/skills/cbp-finalize/SKILL.md +3 -2
  38. package/templates/skills/cbp-frontend-design/SKILL.md +1 -0
  39. package/templates/skills/cbp-frontend-ui/SKILL.md +2 -1
  40. package/templates/skills/cbp-frontend-ux/SKILL.md +2 -1
  41. package/templates/skills/cbp-git-branch-feat-create/SKILL.md +1 -0
  42. package/templates/skills/cbp-git-commit/SKILL.md +1 -0
  43. package/templates/skills/cbp-map-architecture/SKILL.md +5 -0
  44. package/templates/skills/cbp-merge-main/SKILL.md +1 -0
  45. package/templates/skills/cbp-refresh-arch-map/SKILL.md +1 -0
  46. package/templates/skills/cbp-round-build/SKILL.md +5 -0
  47. package/templates/skills/cbp-round-complete/SKILL.md +4 -24
  48. package/templates/skills/cbp-round-plan/SKILL.md +6 -1
  49. package/templates/skills/cbp-session-end/SKILL.md +42 -31
  50. package/templates/skills/cbp-session-start/SKILL.md +8 -7
  51. package/templates/skills/cbp-session-start/qa-regression.md +32 -25
  52. package/templates/skills/cbp-setup-cd/SKILL.md +2 -1
  53. package/templates/skills/cbp-setup-ci/SKILL.md +2 -1
  54. package/templates/skills/cbp-setup-e2e/SKILL.md +2 -1
  55. package/templates/skills/cbp-setup-eslint/SKILL.md +2 -1
  56. package/templates/skills/cbp-ship/SKILL.md +5 -0
  57. package/templates/skills/cbp-ship-configure/SKILL.md +2 -1
  58. package/templates/skills/cbp-ship-main/SKILL.md +1 -0
  59. package/templates/skills/cbp-standalone-task-check/SKILL.md +1 -0
  60. package/templates/skills/cbp-standalone-task-complete/SKILL.md +3 -5
  61. package/templates/skills/cbp-standalone-task-create/SKILL.md +7 -14
  62. package/templates/skills/cbp-standalone-task-start/SKILL.md +12 -11
  63. package/templates/skills/cbp-standalone-task-testing/SKILL.md +2 -1
  64. package/templates/skills/cbp-stripe/SKILL.md +2 -1
  65. package/templates/skills/cbp-supabase-branch-check/SKILL.md +2 -1
  66. package/templates/skills/cbp-supabase-migrate/SKILL.md +1 -0
  67. package/templates/skills/cbp-supabase-setup/SKILL.md +2 -1
  68. package/templates/skills/cbp-task-create/SKILL.md +3 -2
  69. package/templates/skills/cbp-task-start/SKILL.md +11 -10
  70. package/templates/skills/cbp-todo/SKILL.md +25 -39
  71. package/templates/skills/cbp-todo/qa-regression.md +21 -27
  72. package/templates/skills/cbp-verify/SKILL.md +5 -0
  73. package/templates/skills/cbp-verify/reference/round-scope.md +1 -2
  74. package/templates/skills/supabase/SKILL.md +2 -0
  75. package/templates/skills/supabase-postgres-best-practices/SKILL.md +2 -0
  76. package/templates/hooks/cbp-mcp-caller-worktree-inject.sh +0 -78
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebyplan",
3
- "version": "1.13.61",
3
+ "version": "1.13.63",
4
4
  "description": "CLI for CodeByPlan — AI-powered development planning and tracking",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,7 +3,7 @@ name: cbp-e2e-maestro
3
3
  description: Maestro E2E flow authoring + execution for Expo/React Native mobile apps (android + ios). Spawned by /cbp-round-build Step 5 and /cbp-checkpoint-check Step 5b when framework is 'maestro'.
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, mcp__codebyplan__get_repos
5
5
  model: sonnet
6
- effort: xhigh
6
+ effort: high
7
7
  ---
8
8
 
9
9
  # Maestro E2E Agent
@@ -3,7 +3,7 @@ name: cbp-e2e-playwright
3
3
  description: Playwright E2E test authoring + execution for web app routes. Spawned by /cbp-round-build Step 5 and /cbp-checkpoint-check Step 5b when framework is 'playwright'.
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, mcp__codebyplan__get_repos
5
5
  model: sonnet
6
- effort: xhigh
6
+ effort: high
7
7
  ---
8
8
 
9
9
  # Playwright E2E Agent
@@ -31,20 +31,20 @@ pnpm exec playwright install --with-deps chromium
31
31
 
32
32
  Resolve the apps/{app} dev-server port at config-read time via the shared resolver
33
33
  `apps/{app}/e2e/resolve-web-dev-port.ts` — imported by BOTH `playwright.config.ts` and
34
- `e2e/auth.setup.ts` (single source of truth). It reads the per-worktree
34
+ `e2e/auth.setup.ts` (single source of truth). It reads the per-checkout, branch-keyed
35
35
  `.codebyplan/server.local.json` overlay first, then the committed `.codebyplan/server.json`.
36
36
  Match by label rather than array position — a monorepo can have several Next.js allocations
37
37
  with similar label prefixes.
38
38
 
39
39
  **Label-matching rules** (`findWebDevPort`):
40
40
 
41
- - `server.local.json` overlay: each label has the worktree name appended as the last
42
- parenthetical group (e.g. `"Web Dev (<worktree-name>)"`). Strip exactly ONE trailing
41
+ - `server.local.json` overlay: each label has a branch-keyed suffix appended as the last
42
+ parenthetical group (e.g. `"Web Dev (<branch-keyed-suffix>)"`). Strip exactly ONE trailing
43
43
  `" (…)"` group, then require the result `=== "Web Dev"`.
44
- - `"Web Dev (<worktree-name>)"` → strip → `"Web Dev"` ✓
45
- - `"Web Dev (<other-worktree>) (<worktree-name>)"` → strip → `"Web Dev (<other-worktree>)"` ✗
44
+ - `"Web Dev (<branch-keyed-suffix>)"` → strip → `"Web Dev"` ✓
45
+ - `"Web Dev (<other-suffix>) (<branch-keyed-suffix>)"` → strip → `"Web Dev (<other-suffix>)"` ✗
46
46
  - `server.json` committed base: require `label === "Web Dev"` exactly (do NOT strip —
47
- `"Web Dev (<other-worktree>)"` must not match).
47
+ `"Web Dev (<other-suffix>)"` must not match).
48
48
 
49
49
  **Resolution order** (first hit wins):
50
50
 
@@ -108,7 +108,7 @@ import { resolveWebDevPort } from "./e2e/resolve-web-dev-port";
108
108
  // findWebDevPort, parsePortFromUrl, and resolveWebDevPort live in the shared
109
109
  // module ./e2e/resolve-web-dev-port.ts (imported above) — single source of
110
110
  // truth, also consumed by e2e/auth.setup.ts. Resolution order:
111
- // 0. PLAYWRIGHT_BASE_URL → 1. server.local.json → 2. server.json
111
+ // 0. PLAYWRIGHT_BASE_URL → 1. server.local.json (branch-keyed overlay) → 2. server.json
112
112
  // → 3. E2E_BASE_URL → 4. 3010.
113
113
  const port = resolveWebDevPort();
114
114
 
@@ -198,7 +198,7 @@ timing**: it loads creds from `.env.local` + `.codebyplan/e2e.env`, calls
198
198
  the project ref from `NEXT_PUBLIC_SUPABASE_URL`, and writes a `sb-<projectref>-auth-token`
199
199
  cookie (domain `localhost`) into `state.json` using the same `encodeAuthCookie` from
200
200
  `e2e/auth-cookie.ts` that global-setup consumes. This makes seeding deterministic in any
201
- worktree — run `pnpm e2e:auth-setup` (optionally `--port N`) when `state.json` is missing or
201
+ checkout — run `pnpm e2e:auth-setup` (optionally `--port N`) when `state.json` is missing or
202
202
  its refresh token has expired. Do NOT reintroduce a browser-login flow (the `(auth)/login`
203
203
  page is a client component whose `onSubmit` only attaches after hydration — clicking submit
204
204
  pre-hydration falls through to a native GET and never authenticates).
@@ -261,8 +261,8 @@ any already-running process, so the dev-server readiness probe is the active gua
261
261
  path.
262
262
 
263
263
  **Port alignment**: parse `playwright.config.ts` `baseURL` port; compare to the resolved
264
- port from `.codebyplan/server.local.json` (worktree overlay, checked first) then
265
- `.codebyplan/server.json` (committed base). On mismatch ask which is correct, then propose
264
+ port from `.codebyplan/server.local.json` (per-checkout branch-keyed overlay, checked first)
265
+ then `.codebyplan/server.json` (committed base). On mismatch ask which is correct, then propose
266
266
  an Edit to align them.
267
267
 
268
268
  ## Quality Fixture (MANDATORY)
@@ -3,7 +3,7 @@ name: cbp-e2e-tauri
3
3
  description: WebDriverIO + tauri-driver E2E test authoring + execution for Tauri desktop apps. Spawned by /cbp-round-build Step 5 and /cbp-checkpoint-check Step 5b when framework is 'webdriverio'.
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, mcp__codebyplan__get_repos
5
5
  model: sonnet
6
- effort: xhigh
6
+ effort: high
7
7
  ---
8
8
 
9
9
  # Tauri E2E Agent
@@ -3,7 +3,7 @@ name: cbp-e2e-vscode
3
3
  description: VS Code extension E2E test authoring + execution using @vscode/test-cli and @vscode/test-electron. Spawned by /cbp-round-build Step 5 and /cbp-checkpoint-check Step 5b when framework is 'vscode-test'.
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, mcp__codebyplan__get_repos
5
5
  model: sonnet
6
- effort: xhigh
6
+ effort: high
7
7
  ---
8
8
 
9
9
  # VS Code Extension E2E Agent
@@ -3,7 +3,7 @@ name: cbp-e2e-xcuitest
3
3
  description: XCUITest native iOS E2E test authoring + execution for Expo apps targeting system dialogs, HealthKit, watchOS, or other areas Maestro cannot reach. Spawned by /cbp-round-build Step 5 and /cbp-checkpoint-check Step 5b when framework is 'xcuitest'.
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, mcp__codebyplan__get_repos
5
5
  model: sonnet
6
- effort: xhigh
6
+ effort: high
7
7
  ---
8
8
 
9
9
  # XCUITest E2E Agent
@@ -20,13 +20,10 @@
20
20
  # - Web-UI flag (app_file_approval_by_user) consumption + reset
21
21
  # - Writes both PATCH /api/rounds/${ROUND_ID} and PATCH /api/tasks/${TASK_ID}
22
22
  #
23
- # Caller worktree identity:
24
- # The CLI auto-resolves caller_worktree_id (override flag cache
25
- # in-process tuple API) and hard-fails with exit 1 if it cannot resolve
26
- # on the write path. This hook resolves the worktree id before invoking the
27
- # CLI and passes it via --caller-worktree-id so the server can honor the
28
- # feat-worktree lock. The hook itself stays non-fatal (exits 0) and surfaces
29
- # the CLI's stderr output to the user.
23
+ # Caller identity:
24
+ # Worktree-based caller injection was retired in CHK-225. The hook no longer
25
+ # resolves or threads any worktree id; user identity travels via the MCP JWT.
26
+ # The hook stays fail-open and exits 0.
30
27
  #
31
28
  # Flags:
32
29
  # --dry-run Pass through to CLI (prints merged payload, no API writes).
@@ -83,16 +80,8 @@ if [ -z "$TASK_ID" ]; then
83
80
  exit 0
84
81
  fi
85
82
 
86
- # Resolve worktree id before invoking the CLI so the server can honor the
87
- # feat-worktree lock. On miss (unregistered worktree) the CLI falls back to
88
- # its in-process resolve and hard-fails with guidance if still unresolved.
89
- WORKTREE_ID=$(npx codebyplan resolve-worktree 2>/dev/null)
90
-
91
83
  # Delegate to the codebyplan CLI (single source of truth for merge semantics)
92
84
  CMD_ARGS=("round" "sync-approvals" "--round-id" "$ROUND_ID" "--task-id" "$TASK_ID")
93
- if [ -n "$WORKTREE_ID" ]; then
94
- CMD_ARGS+=("--caller-worktree-id" "$WORKTREE_ID")
95
- fi
96
85
  [ "$DRY_RUN" = "true" ] && CMD_ARGS+=("--dry-run")
97
86
 
98
87
  if npx codebyplan "${CMD_ARGS[@]}"; then
@@ -374,87 +374,6 @@ fi
374
374
 
375
375
  echo ""
376
376
 
377
- # ===== HOOK SMOKE TESTS — cbp-mcp-caller-worktree-inject =====
378
- echo "## Hook Smoke Tests — cbp-mcp-caller-worktree-inject (CHK-198)"
379
-
380
- INJECT_HOOK="$HOOKS_DIR/cbp-mcp-caller-worktree-inject.sh"
381
- # Absolute path — the fail-open test runs the hook from a temp cwd (to isolate it
382
- # from this repo's git context), where the relative "$HOOKS_DIR" no longer resolves.
383
- INJECT_HOOK_ABS="$(cd "$HOOKS_DIR" 2>/dev/null && pwd)/cbp-mcp-caller-worktree-inject.sh"
384
-
385
- if [ ! -f "$INJECT_HOOK" ]; then
386
- test_result "cbp-mcp-caller-worktree-inject.sh present" "passed" "missing"
387
- else
388
- test_result "cbp-mcp-caller-worktree-inject.sh present" "passed" "passed"
389
-
390
- FIRST_LINE=$(head -1 "$INJECT_HOOK")
391
- if echo "$FIRST_LINE" | grep -q '^#!/'; then
392
- test_result "cbp-mcp-caller-worktree-inject.sh has shebang" "passed" "passed"
393
- else
394
- test_result "cbp-mcp-caller-worktree-inject.sh has shebang" "passed" "missing"
395
- fi
396
-
397
- if grep -q '@scope: org-shared' "$INJECT_HOOK"; then
398
- test_result "cbp-mcp-caller-worktree-inject.sh has @scope: org-shared" "passed" "passed"
399
- else
400
- test_result "cbp-mcp-caller-worktree-inject.sh has @scope: org-shared" "passed" "missing"
401
- fi
402
-
403
- # Fail-open: run from a non-repo temp dir with no worktree cache and no
404
- # CLAUDE_PROJECT_DIR — neither the cache nor the CLI fallback can resolve a
405
- # worktree, so the hook must exit 0 with empty stdout (no updatedInput).
406
- ISO=$(mktemp -d)
407
- OUTPUT=$( (cd "$ISO" && env -u CLAUDE_PROJECT_DIR bash "$INJECT_HOOK_ABS" <<< '{"tool_input":{"task_id":"x"}}') 2>/dev/null )
408
- EXIT_CODE=$?
409
- if [ "$EXIT_CODE" = "0" ] && [ -z "$OUTPUT" ]; then
410
- test_result "cbp-mcp-caller-worktree-inject.sh fail-open (unresolvable) exits 0 + empty stdout" "passed" "passed"
411
- else
412
- test_result "cbp-mcp-caller-worktree-inject.sh fail-open (unresolvable) exits 0 + empty stdout" "passed" "failed (exit=$EXIT_CODE)"
413
- fi
414
- rm -rf "$ISO"
415
-
416
- # C6 — input already carries a non-empty caller_worktree_id → never overwrite;
417
- # early-return with exit 0 and empty stdout (no resolution attempted).
418
- OUTPUT=$(echo '{"tool_input":{"caller_worktree_id":"11111111-1111-1111-1111-111111111111"}}' | bash "$INJECT_HOOK" 2>/dev/null)
419
- EXIT_CODE=$?
420
- if [ "$EXIT_CODE" = "0" ] && [ -z "$OUTPUT" ]; then
421
- test_result "cbp-mcp-caller-worktree-inject.sh C6 keeps existing caller_worktree_id (exit 0 + empty stdout)" "passed" "passed"
422
- else
423
- test_result "cbp-mcp-caller-worktree-inject.sh C6 keeps existing caller_worktree_id (exit 0 + empty stdout)" "passed" "failed (exit=$EXIT_CODE)"
424
- fi
425
-
426
- # Injection — a worktree.local.json whose .branch matches the current git branch
427
- # makes the cache fast-path resolve. Use a synthetic UUID so the assertion proves
428
- # the cache value (not the live CLI) was injected. Skipped when no concrete git
429
- # branch resolves (detached HEAD / non-git checkout) or jq is unavailable.
430
- CUR_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
431
- if [ -n "$CUR_BRANCH" ] && [ "$CUR_BRANCH" != "HEAD" ] && command -v jq >/dev/null 2>&1; then
432
- ISO=$(mktemp -d)
433
- mkdir -p "$ISO/.codebyplan"
434
- FAKE_WT="abcdef01-2345-6789-abcd-ef0123456789"
435
- jq -n --arg b "$CUR_BRANCH" --arg w "$FAKE_WT" \
436
- '{worktree_id:$w, branch:$b}' > "$ISO/.codebyplan/worktree.local.json"
437
- OUTPUT=$(CLAUDE_PROJECT_DIR="$ISO" bash "$INJECT_HOOK" <<< '{"tool_input":{"task_id":"x"}}' 2>/dev/null)
438
- EXIT_CODE=$?
439
- INJECTED=$(echo "$OUTPUT" | jq -r '.hookSpecificOutput.updatedInput.caller_worktree_id // empty' 2>/dev/null)
440
- # Sibling-key survival — CC's updatedInput REPLACES tool_input wholesale (it is
441
- # not a partial merge), so the hook must echo back every original field merged
442
- # with caller_worktree_id. Assert the non-target sibling key (task_id) survives;
443
- # this is the assertion gap that let the replace-vs-merge bug ship in round 2.
444
- PRESERVED=$(echo "$OUTPUT" | jq -r '.hookSpecificOutput.updatedInput.task_id // empty' 2>/dev/null)
445
- if [ "$EXIT_CODE" = "0" ] && [ "$INJECTED" = "$FAKE_WT" ] && [ "$PRESERVED" = "x" ]; then
446
- test_result "cbp-mcp-caller-worktree-inject.sh injects caller_worktree_id AND preserves sibling keys" "passed" "passed"
447
- else
448
- test_result "cbp-mcp-caller-worktree-inject.sh injects caller_worktree_id AND preserves sibling keys" "passed" "failed (exit=$EXIT_CODE injected=$INJECTED preserved=$PRESERVED)"
449
- fi
450
- rm -rf "$ISO"
451
- else
452
- test_result "cbp-mcp-caller-worktree-inject.sh injection test (no branch resolvable — skipped)" "passed" "passed"
453
- fi
454
- fi
455
-
456
- echo ""
457
-
458
377
  # ===== HOOK SMOKE TESTS — cbp-session-start-hook =====
459
378
  echo "## Hook Smoke Tests — cbp-session-start-hook (CHK-178)"
460
379
 
@@ -69,15 +69,6 @@
69
69
  "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/cbp-mcp-migration-guard.sh"
70
70
  }
71
71
  ]
72
- },
73
- {
74
- "matcher": "mcp__codebyplan__(update_checkpoint|complete_checkpoint|update_task|complete_task|add_round|update_round|complete_round|create_standalone_task|update_standalone_task|complete_standalone_task|add_standalone_round|update_standalone_round|complete_standalone_round|update_standalone_file_change)",
75
- "hooks": [
76
- {
77
- "type": "command",
78
- "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/cbp-mcp-caller-worktree-inject.sh"
79
- }
80
- ]
81
72
  }
82
73
  ],
83
74
  "PostToolUse": [
@@ -25,11 +25,13 @@ SHARED tooling behavior only — repo-specific gotchas belong in that repo's own
25
25
  clobbers existing `decisions` / `discoveries` / `check_results`. Always read the current row,
26
26
  merge your change into the full object/array, then write the whole thing back.
27
27
 
28
- - **`resolve-worktree` empty output = a NULL `(device, path, branch)` tuple, not a broken
29
- resolver.** When identity is unresolved the server can collapse the caller to the repo's main
30
- worktree, so feat-locked writes get rejected. Pass `caller_worktree_id` on every MCP mutation,
31
- and confirm ownership by matching the row's repo path + branch to the current directory before
32
- mutating.
28
+ - **User-level locks are invisible until a mutation they block.** `get_checkpoints` /
29
+ `get_tasks` succeed even when another user holds the assignment; the 403 fires only on
30
+ `update_*` / `complete_*`. The lock keys on the JWT user (`ctx.userId`) vs the row's
31
+ `assigned_user_id` (null = open). `caller_worktree_id` / `worktree_id` params are
32
+ accepted-and-ignored — do not thread them. Verify `assigned_user_id` matches
33
+ `npx codebyplan whoami` before mutating; recover a stale assignment with
34
+ `release_assignment` (maintainer).
33
35
 
34
36
  - **Full-repo lint/type baselines are often pre-existing red.** A round must gate on the files
35
37
  it changed, not the whole-repo baseline — scope lint/tsc checks to the round's changed set so a
@@ -40,14 +42,10 @@ SHARED tooling behavior only — repo-specific gotchas belong in that repo's own
40
42
  `update_task` alone — updating only the task leaves the round entries unapproved and
41
43
  `complete_task` rejects with "files are not approved".
42
44
 
43
- - **CLI transport uses REST (reads) and OAuth+MCP (writes) — a 502 from `codebyplan round sync-approvals` is transient MCP churn, not an outage.** The CLI exits 0 with a warning and MCP tools still work. A missing `CODEBYPLAN_API_KEY` surfaces as an `ApiError`, not a 502. `sync-approvals` can also drag untracked per-device dirs into `files_changed` — run it from the repo root or pass `--caller-worktree-id`.
45
+ - **CLI transport uses REST (reads) and OAuth+MCP (writes) — a 502 from `codebyplan round sync-approvals` is transient MCP churn, not an outage.** The CLI exits 0 with a warning and MCP tools still work. A missing `CODEBYPLAN_API_KEY` surfaces as an `ApiError`, not a 502. `sync-approvals` can also drag untracked per-device dirs into `files_changed` — run it from the repo root.
44
46
 
45
47
  - **`codebyplan claude update` requires a TTY.** On non-TTY stdin (CI, piped) it half-applies then errors. Re-run with `--yes` to accept defaults non-interactively.
46
48
 
47
- - **Checkpoint locks are invisible until a mutation they block.** `get_checkpoints` / `get_tasks` succeed even when another worktree holds the lock; the 403 fires only on `update_*` / `complete_*`. Verify the row's `worktree_id` matches the caller before mutating. A null-`worktree_id` checkpoint can still be actively shipped by whichever worktree physically holds its feat branch — check `git worktree list` first.
48
-
49
- - **`update_task` accepts `caller_worktree_id` for lock-verify only — it does NOT assign ownership.** Ownership assignment goes through the web UI or the dedicated assignment path. Don't conflate `caller_worktree_id` with `assigned_worktree_id`.
50
-
51
49
  - **Re-run config-driven gates after merging main into a feat branch.** A merge can add or change `.codebyplan/shipment.json`, ports, branch config, `e2e.json`, and `eslint.json` — treat the post-merge state as a fresh baseline before continuing.
52
50
 
53
51
  ## Behavioral Preferences
@@ -0,0 +1,70 @@
1
+ ---
2
+ description: Effort ladder (low..max), per-model support, frontmatter usage, and the session-only ultracode mode.
3
+ ---
4
+
5
+ # Effort and Ultracode
6
+
7
+ On-demand reference for effort levels and the ultracode mode in Claude Code.
8
+
9
+ ## Effort Ladder
10
+
11
+ | Level | Gloss |
12
+ |-------|-------|
13
+ | `low` | Latency-sensitive, trivial tasks — minimal reasoning |
14
+ | `medium` | Standard tasks — moderate reasoning |
15
+ | `high` | Default for most models — solid reasoning budget |
16
+ | `xhigh` | Extended reasoning — slower, better for complex multi-step work |
17
+ | `max` | Deepest reasoning available — session-only, can overthink simple tasks |
18
+
19
+ ## Per-Model Support
20
+
21
+ | Model | Supported levels | Default effort |
22
+ |-------|-----------------|----------------|
23
+ | Opus 4.8, Fable 5 | `low` `medium` `high` `xhigh` `max` | `high` |
24
+ | Opus 4.7 | `low` `medium` `high` `xhigh` `max` | `xhigh` |
25
+ | Opus 4.6, Sonnet 4.6 | `low` `medium` `high` `max` (`xhigh` → falls back to `high`) | `high` |
26
+
27
+ ## Precedence (highest → lowest)
28
+
29
+ 1. `CLAUDE_CODE_EFFORT_LEVEL` env var
30
+ 2. Frontmatter `effort:` (while a skill/agent is active)
31
+ 3. `effortLevel` in `settings.json`
32
+ 4. Model default
33
+
34
+ ## Frontmatter Usage
35
+
36
+ Skills set `model: inherit` + `effort: <level>`. Subagents pin `model: <id>` + `effort: <level>`.
37
+ Both override the session level only while active.
38
+
39
+ `effort: ultracode` is **invalid** in frontmatter — `validate-skill.sh` errors on it. Use
40
+ `effort: max` for the heaviest per-skill reasoning budget; enable ultracode session-wide with
41
+ `/effort ultracode`.
42
+
43
+ ## settings.json `effortLevel`
44
+
45
+ Accepts `low | medium | high | xhigh` **only**. `max` and `ultracode` are session-only and
46
+ rejected by the settings validator.
47
+
48
+ This repo's default is `xhigh` (`.claude/settings.json`). You **cannot** default ultracode
49
+ in settings.json — enable it per-session instead.
50
+
51
+ ## Ultracode Mode
52
+
53
+ ultracode = `xhigh` reasoning + automatic Workflow orchestration for substantive tasks.
54
+ It is a **session-only** Claude Code mode, NOT a frontmatter `effort` value, NOT `effortLevel`,
55
+ NOT `--effort`, NOT `CLAUDE_CODE_EFFORT_LEVEL`.
56
+
57
+ **Enable via:**
58
+ - `/effort ultracode` (in-session slash command)
59
+ - `claude --settings '{"ultracode": true}'`
60
+ - An Agent SDK control request
61
+
62
+ Applies to the current session only — resets on a new session.
63
+
64
+ **When to enable:** heavy multi-step checkpoints where deterministic multi-agent fan-out
65
+ helps. See `rules/workflow-orchestration.md` for full orchestration guidance.
66
+
67
+ ## Related
68
+
69
+ - `rules/model-invocation-convention.md` — model pinning in skill/agent frontmatter
70
+ - `rules/workflow-orchestration.md` — Workflow tool pattern, opt-in gate, and when to use it instead of ad-hoc Task/Agent spawns
@@ -38,3 +38,4 @@ See `.claude/skills/cbp-build-cc-settings/reference/cbp-permission-policy.md` fo
38
38
 
39
39
  - `rules/scope-vocabulary.md` — scope marker conventions for managed vs user-created files
40
40
  - `cbp-build-cc-settings/reference/cbp-permission-policy.md` — allow/ask tiers
41
+ - `rules/effort-and-ultracode.md` — effort ladder, per-model support, and the session-only ultracode mode
@@ -47,7 +47,7 @@ The Supabase branch is removed wherever the git branch is deleted:
47
47
  | Skill | Trigger |
48
48
  |---|---|
49
49
  | `cbp-checkpoint-end` | stale-branch cleanup + current feat-branch delete on ship |
50
- | `codebyplan worktree remove CHK-NNN` | worktree teardown removes the coupled Supabase branch |
50
+ | `codebyplan worktree remove <path>` | git-worktree teardown removes the coupled Supabase branch (branch-keyed, not identity-keyed) |
51
51
  | `cbp-ship-main` | `branch_deleted` event after PR merge |
52
52
  | `cbp-standalone-task-complete` | `branch_deleted` event after standalone PR merge (Step 7.3) |
53
53
 
@@ -93,7 +93,7 @@ or auto-created by the GitHub integration — both paths use the same branch nam
93
93
  | Role | Skill |
94
94
  |---|---|
95
95
  | Create (lazy) | `cbp-supabase-migrate` (Step 2.3) |
96
- | Delete | `cbp-checkpoint-end`, `cbp-standalone-task-complete`, `codebyplan worktree remove`, `cbp-ship-main` |
96
+ | Delete | `cbp-checkpoint-end`, `cbp-standalone-task-complete`, `codebyplan worktree remove <path>`, `cbp-ship-main` |
97
97
  | PR gate | `cbp-supabase-branch-check` |
98
98
 
99
99
  Each skill in the Skill Map above carries an inline back-reference to this rule at its create or teardown step.
@@ -12,16 +12,16 @@ The todos queue is materialised by `apps/todo-worker` (CHK-122) and consumed by
12
12
 
13
13
  ## 1. Six workflow invariants — DB-layer guards, never bypassable
14
14
 
15
- Defined in `supabase/migrations/20260511211900_chk111_workflow_invariants.sql`. These are `BEFORE UPDATE` triggers — they refuse invalid state transitions and produce structured `RAISE EXCEPTION` errors with `HINT` pointing at the offending row. **Do NOT port these to TS.** The DB layer is the bypass-proof contract.
15
+ Defined in `supabase/migrations/20260511211900_chk111_workflow_invariants.sql` (updated by `supabase/migrations/20260612000000_chk225_task1_user_locks.sql`). These are `BEFORE UPDATE` triggers — they refuse invalid state transitions and produce structured `RAISE EXCEPTION` errors with `HINT` pointing at the offending row. **Do NOT port these to TS.** The DB layer is the bypass-proof contract.
16
16
 
17
17
  | # | Trigger | What it enforces |
18
18
  |---|---------|------------------|
19
- | 1 | `trg_enforce_checkpoint_activation_worktree` | A checkpoint cannot be activated without `worktree_id` set |
20
- | 2 | `enforce_standalone_task_worktree` (via task workflow) | A standalone task cannot be moved to `in_progress` without `assigned_worktree_id` |
19
+ | 1 | `trg_enforce_checkpoint_activation_worktree` | A checkpoint cannot be activated without `assigned_user_id` set (CHK-225: was `worktree_id`) |
20
+ | 2 | `trg_enforce_standalone_task_workflow_invariants` | A standalone task cannot be moved to `in_progress` without `assigned_user_id` (CHK-225: was `assigned_worktree_id`) |
21
21
  | 3 | `trg_enforce_task_workflow_invariants` | ≤ 1 `in_progress` task per checkpoint |
22
22
  | 4 | `trg_enforce_single_in_progress_round_per_task` | ≤ 1 `in_progress` round per task |
23
- | 5 | `trg_enforce_single_active_scope_per_worktree` | ≤ 1 active (checkpoint OR standalone task) per worktree |
24
- | 6 | `trg_enforce_standalone_task_scope_per_worktree` | ≤ 1 `in_progress` standalone task per worktree |
23
+ | 5 | `trg_enforce_single_active_scope_per_worktree` | ≤ 1 active (checkpoint OR standalone task) per `assigned_user_id` (CHK-225: was per `worktree_id`) |
24
+ | 6 | `trg_enforce_standalone_task_scope_per_worktree` | ≤ 1 `in_progress` standalone task per `assigned_user_id` (CHK-225: was per `assigned_worktree_id`) |
25
25
 
26
26
  The worker is a passive cross-checker (`apps/todo-worker/src/invariants/check.ts`) — if its check disagrees with the DB, the DB wins.
27
27
 
@@ -34,7 +34,7 @@ MCP write → enqueueTodosJob → todos_jobs (status='pending')
34
34
 
35
35
  worker claim_todos_job (SELECT … FOR UPDATE SKIP LOCKED)
36
36
 
37
- computeTodos(repo, worktree, user) → desired rows
37
+ computeTodos(repo, user) → desired rows
38
38
 
39
39
  apply_todos RPC → todos table (status='current' / 'pending')
40
40
 
@@ -71,7 +71,7 @@ The queue head (`get_todos` `rows[0]`) maps to one of these slash commands. The
71
71
 
72
72
  ## 5. Heartbeat policy
73
73
 
74
- The worker's `node-cron` heartbeat runs at `0 0 * * *` (UTC midnight). It enumerates every `(repo, worktree, user)` tuple with an active checkpoint OR in-progress standalone task and enqueues a `HEARTBEAT_SWEEP` todos_jobs row for each. This catches drift from missed `enqueueTodosJob` calls in MCP writers.
74
+ The worker's `node-cron` heartbeat runs at `0 0 * * *` (UTC midnight). It enumerates every `(repo, user)` pair with an active checkpoint OR in-progress standalone task (via `assigned_user_id`) and enqueues a `HEARTBEAT_SWEEP` todos_jobs row for each. This catches drift from missed `enqueueTodosJob` calls in MCP writers.
75
75
 
76
76
  Backoff: a failed job retries at `now + 2^attempts minutes` (cap 60min). After 3 attempts, the job stays `failed` and the heartbeat picks it up again at the next sweep.
77
77
 
@@ -83,7 +83,6 @@ The shared enqueue helper lives at `packages/mcp-tools/src/tools/enqueue-todos.t
83
83
  enqueueTodosJob(
84
84
  client: SupabaseClient,
85
85
  repoId: string,
86
- callerWorktreeId: string | undefined,
87
86
  userId: string | null,
88
87
  reason: string
89
88
  ): Promise<void>
@@ -108,6 +107,8 @@ Every workflow mutator MUST call `void enqueueTodosJob(...)` after the mutation
108
107
 
109
108
  CHK-111 shipped the original todos queue as Postgres triggers + a 583-LOC `regenerate_todos_for_repo` PL/pgSQL function. CHK-122 ported the regen to `apps/todo-worker` (Node) for shared infrastructure with `apps/docs-ingest` (CHK-116), easier testing, and per-user fanout. The 10 `trg_*_todos` triggers and the 4 `wrap_*` wrappers were dropped in migration `20260521000000_chk122_drop_legacy_todos_regen.sql`. The 6 BEFORE-UPDATE invariant triggers stayed.
110
109
 
110
+ CHK-225 updated the invariant triggers from worktree-scoped to user-scoped (`assigned_user_id`). The trigger names were preserved for continuity; only the function bodies changed. Migration: `20260612000000_chk225_task1_user_locks.sql`.
111
+
111
112
  ## 8. Deployment — Railway
112
113
 
113
114
  `apps/todo-worker` runs as a Railway service alongside `apps/backend`. Setup:
@@ -119,3 +120,5 @@ CHK-111 shipped the original todos queue as Postgres triggers + a 583-LOC `regen
119
120
  5. Save the resulting `project_ref` to `.codebyplan.json` `shipment.surfaces.railway-todo-worker.project_ref`.
120
121
 
121
122
  Smoke after deploy: run `/cbp-finalize` in any worktree → tail Railway logs → expect a `claim → apply` cycle within `WORKER_POLL_MS`.
123
+
124
+ **CHK-225 deploy note**: apply migration `20260612100000` (drops `worktree_id` from `todos` + `todos_jobs`, dedup todos rows, updates `apply_todos` RPC) BEFORE running `railway up` for the worker. Until the migration lands, the worker's 3-arg `apply_todos` call fails with a function-not-found error.
@@ -0,0 +1,59 @@
1
+ ---
2
+ description: Workflow tool — deterministic JS multi-agent orchestration for heavy fan-out. What it is, when to reach for it, the opt-in gate, and how it relates to ad-hoc Task/Agent spawning.
3
+ ---
4
+
5
+ # Workflow Orchestration
6
+
7
+ On-demand reference for the `Workflow` tool — the structured alternative to ad-hoc `Task`/`Agent`
8
+ spawning when a step fans out across many independent units of work.
9
+
10
+ ## What It Is
11
+
12
+ `Workflow` runs a deterministic JavaScript orchestration script that spawns and coordinates
13
+ subagents. The control flow (loops, conditionals, fan-out) lives in the script, not in model
14
+ judgement. Core primitives:
15
+
16
+ - `agent(prompt, opts)` — spawn a subagent; with a `schema` it returns a validated structured
17
+ object instead of raw text.
18
+ - `parallel(thunks)` — run tasks concurrently to a **barrier** (awaits all before returning).
19
+ - `pipeline(items, ...stages)` — stream each item through stages with **no barrier** between them
20
+ (the default for multi-stage work — wall-clock is the slowest single chain, not sum-of-stages).
21
+ - `phase(title)` / `log(message)` — progress grouping and narration.
22
+
23
+ Built in: per-agent structured-output validation, a concurrency cap, a shared token budget,
24
+ loop-until-done / loop-until-dry accumulation, and resume from a prior run.
25
+
26
+ ## When To Reach For It
27
+
28
+ - **Many independent items** — a per-module sweep, a per-file migration, a per-surface deploy.
29
+ - **Parallel waves with a barrier** — wave A must fully complete before wave B starts.
30
+ - **Adversarial / multi-vote verification** — N independent reviewers vote to confirm a finding.
31
+ - **Scale beyond one context** — coverage a single conversation cannot hold.
32
+
33
+ Contrast: a single one-off subagent stays on the plain `Task`/`Agent` tool. Workflow's setup
34
+ overhead only pays off at fan-out scale.
35
+
36
+ ## Opt-In Gate
37
+
38
+ `Workflow` is **not** invoked by default. Reach for it only when one holds:
39
+
40
+ - **ultracode** mode is active in the session (`/effort ultracode`) — under ultracode Claude
41
+ auto-reaches for Workflow on substantive fan-out tasks; **or**
42
+ - the **user explicitly opts in** ("use a workflow", "fan out agents", "orchestrate this"); **or**
43
+ - a skill or command's own instructions tell you to author one.
44
+
45
+ Outside those, do NOT call `Workflow` — use the existing `Task`/`Agent` spawn, or describe what a
46
+ workflow could do and ask first. The tool can spawn dozens of agents and is token-heavy — the scale
47
+ must be requested, not inferred.
48
+
49
+ ## Relationship to Task/Agent Spawning
50
+
51
+ `Task`/`Agent` spawning is the **default** for subagent work and is unchanged everywhere it is used.
52
+ `Workflow` is the **structured alternative** for heavy fan-out — additive, not a replacement. A
53
+ common shape is **hybrid**: scout inline first to discover the work-list, then author a `Workflow`
54
+ that pipelines over it.
55
+
56
+ ## Related
57
+
58
+ - `rules/effort-and-ultracode.md` — effort ladder, per-model support, and the session-only ultracode mode that auto-enables this orchestration path
59
+ - `rules/model-invocation-convention.md` — model pinning in skill/agent frontmatter
@@ -66,7 +66,6 @@
66
66
  "mcp__codebyplan__create_project",
67
67
  "mcp__codebyplan__create_repo",
68
68
  "mcp__codebyplan__delete_session_log",
69
- "mcp__codebyplan__delete_worktree",
70
69
  "mcp__codebyplan__release_assignment",
71
70
  "mcp__stripe__create_customer",
72
71
  "mcp__stripe__create_product",
@@ -161,7 +160,6 @@
161
160
  "mcp__codebyplan__get_task_templates",
162
161
  "mcp__codebyplan__get_tasks",
163
162
  "mcp__codebyplan__get_todos",
164
- "mcp__codebyplan__get_worktrees",
165
163
  "mcp__codebyplan__list_tech_stack_sync_sessions",
166
164
  "mcp__codebyplan__get_chunk",
167
165
  "mcp__codebyplan__get_library_toc",
@@ -183,7 +181,6 @@
183
181
  "mcp__codebyplan__create_session_log",
184
182
  "mcp__codebyplan__update_session_log",
185
183
  "mcp__codebyplan__update_session_state",
186
- "mcp__codebyplan__create_worktree",
187
184
  "mcp__codebyplan__flag_stale_chunk",
188
185
  "mcp__codebyplan__update_eslint_repo_config",
189
186
  "mcp__codebyplan__update_server_config",
@@ -196,8 +193,6 @@
196
193
  "Bash(npx codebyplan supabase:*)",
197
194
  "Bash(codebyplan whoami:*)",
198
195
  "Bash(npx codebyplan whoami:*)",
199
- "Bash(codebyplan resolve-worktree:*)",
200
- "Bash(npx codebyplan resolve-worktree:*)",
201
196
  "Bash(codebyplan version-status:*)",
202
197
  "Bash(npx codebyplan version-status:*)",
203
198
  "Bash(codebyplan worktree:*)",
@@ -3,6 +3,7 @@ name: cbp-build-cc-agent
3
3
  description: Build a Claude Code subagent at .claude/agents/{name}.md (flat form, per the official sub-agents spec) following the official sub-agents spec (frontmatter, tools, model, hooks, skills preload, permission modes, isolation).
4
4
  argument-hint: "[agent-name] [--scope=project|user] [--isolation=worktree]"
5
5
  allowed-tools: Read, Write, Edit, Glob, Grep, Bash(mkdir *), Bash(chmod *)
6
+ model: inherit
6
7
  effort: xhigh
7
8
  ---
8
9
 
@@ -3,6 +3,7 @@ name: cbp-build-cc-claude-file
3
3
  description: Create or update a CLAUDE.md file at any scope (managed, project, user, local) following the official memory spec — imports (@path), nested discovery, AGENTS.md bridge, comment stripping, and claudeMdExcludes.
4
4
  argument-hint: "[action] [--scope=managed|project|user|local]"
5
5
  allowed-tools: Read, Write, Edit, Glob, Grep
6
+ model: inherit
6
7
  effort: xhigh
7
8
  ---
8
9