codebyplan 1.13.38 → 1.13.40

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 (54) hide show
  1. package/dist/cli.js +25142 -425
  2. package/package.json +4 -2
  3. package/templates/agents/cbp-cc-executor.md +4 -4
  4. package/templates/agents/cbp-map-architecture.md +90 -0
  5. package/templates/agents/cbp-round-executor.md +2 -0
  6. package/templates/agents/cbp-task-check.md +2 -0
  7. package/templates/agents/cbp-task-planner.md +2 -0
  8. package/templates/context/architecture/arch-map-spec.md +204 -0
  9. package/templates/context/architecture-map.md +117 -0
  10. package/templates/hooks/README.md +14 -2
  11. package/templates/hooks/cbp-session-start-hook.sh +32 -0
  12. package/templates/hooks/cbp-test-coverage-gate.sh +20 -6
  13. package/templates/hooks/cbp-test-hooks.sh +72 -0
  14. package/templates/hooks/hooks.json +11 -0
  15. package/templates/hooks/validate-structure.sh +3 -2
  16. package/templates/rules/architecture-map.md +30 -0
  17. package/templates/rules/context-file-loading.md +3 -0
  18. package/templates/rules/supabase-branch-lifecycle.md +1 -1
  19. package/templates/settings.project.base.json +15 -1
  20. package/templates/skills/cbp-checkpoint-check/SKILL.md +10 -10
  21. package/templates/skills/cbp-checkpoint-complete/SKILL.md +7 -7
  22. package/templates/skills/cbp-checkpoint-create/SKILL.md +11 -9
  23. package/templates/skills/cbp-checkpoint-end/SKILL.md +4 -4
  24. package/templates/skills/cbp-checkpoint-plan/SKILL.md +10 -10
  25. package/templates/skills/cbp-checkpoint-start/SKILL.md +6 -6
  26. package/templates/skills/cbp-checkpoint-update/SKILL.md +9 -9
  27. package/templates/skills/cbp-git-commit/SKILL.md +8 -4
  28. package/templates/skills/cbp-git-worktree-remove/SKILL.md +3 -2
  29. package/templates/skills/cbp-map-architecture/SKILL.md +170 -0
  30. package/templates/skills/cbp-merge-main/SKILL.md +2 -5
  31. package/templates/skills/cbp-refresh-arch-map/SKILL.md +191 -0
  32. package/templates/skills/cbp-round-check/SKILL.md +12 -8
  33. package/templates/skills/cbp-round-complete/SKILL.md +16 -10
  34. package/templates/skills/cbp-round-end/SKILL.md +9 -10
  35. package/templates/skills/cbp-round-execute/SKILL.md +7 -6
  36. package/templates/skills/cbp-round-input/SKILL.md +24 -12
  37. package/templates/skills/cbp-round-start/SKILL.md +36 -16
  38. package/templates/skills/cbp-round-update/SKILL.md +14 -10
  39. package/templates/skills/cbp-session-end/SKILL.md +22 -12
  40. package/templates/skills/cbp-session-start/SKILL.md +19 -15
  41. package/templates/skills/cbp-ship/SKILL.md +4 -4
  42. package/templates/skills/cbp-ship/reference/surface-supabase.md +3 -3
  43. package/templates/skills/cbp-ship-configure/SKILL.md +1 -1
  44. package/templates/skills/cbp-ship-configure/reference/railway-backend.md +2 -2
  45. package/templates/skills/cbp-ship-configure/reference/vercel.md +1 -1
  46. package/templates/skills/cbp-ship-main/SKILL.md +2 -2
  47. package/templates/skills/cbp-standalone-task-complete/SKILL.md +3 -2
  48. package/templates/skills/cbp-supabase-migrate/SKILL.md +6 -7
  49. package/templates/skills/cbp-task-check/SKILL.md +10 -10
  50. package/templates/skills/cbp-task-complete/SKILL.md +11 -9
  51. package/templates/skills/cbp-task-create/SKILL.md +7 -5
  52. package/templates/skills/cbp-task-start/SKILL.md +15 -17
  53. package/templates/skills/cbp-task-testing/SKILL.md +18 -18
  54. package/templates/skills/cbp-todo/SKILL.md +21 -21
@@ -455,6 +455,78 @@ fi
455
455
 
456
456
  echo ""
457
457
 
458
+ # ===== HOOK SMOKE TESTS — cbp-session-start-hook =====
459
+ echo "## Hook Smoke Tests — cbp-session-start-hook (CHK-178)"
460
+
461
+ SESSION_START_HOOK="$HOOKS_DIR/cbp-session-start-hook.sh"
462
+
463
+ if [ ! -f "$SESSION_START_HOOK" ]; then
464
+ test_result "cbp-session-start-hook.sh present" "passed" "missing"
465
+ else
466
+ test_result "cbp-session-start-hook.sh present" "passed" "passed"
467
+
468
+ # Header/@scope check
469
+ FIRST_LINE=$(head -1 "$SESSION_START_HOOK")
470
+ if echo "$FIRST_LINE" | grep -q '^#!/'; then
471
+ test_result "cbp-session-start-hook.sh has shebang" "passed" "passed"
472
+ else
473
+ test_result "cbp-session-start-hook.sh has shebang" "passed" "missing"
474
+ fi
475
+
476
+ if grep -q '@scope: org-shared' "$SESSION_START_HOOK"; then
477
+ test_result "cbp-session-start-hook.sh has @scope: org-shared" "passed" "passed"
478
+ else
479
+ test_result "cbp-session-start-hook.sh has @scope: org-shared" "passed" "missing"
480
+ fi
481
+
482
+ # Syntax check
483
+ if bash -n "$SESSION_START_HOOK" 2>/dev/null; then
484
+ test_result "cbp-session-start-hook.sh bash -n syntax ok" "passed" "passed"
485
+ else
486
+ test_result "cbp-session-start-hook.sh bash -n syntax ok" "passed" "failed"
487
+ fi
488
+
489
+ # Graceful-degrade: run in a temp dir without .codebyplan/repo.json — hook
490
+ # must exit 0 (no-op) without invoking npx (stub npx as a no-op in PATH).
491
+ ISO=$(mktemp -d)
492
+ # Create a stub npx in a temp bin dir so npx invocations are harmless no-ops.
493
+ STUB_BIN=$(mktemp -d)
494
+ printf '#!/bin/bash\nexit 0\n' > "$STUB_BIN/npx"
495
+ chmod +x "$STUB_BIN/npx"
496
+ ACTUAL_EXIT=$(CLAUDE_PROJECT_DIR="$ISO" PATH="$STUB_BIN:$PATH" bash "$SESSION_START_HOOK" >/dev/null 2>&1; echo $?)
497
+ # In the no-repo.json path npx must NOT be invoked at all — use a recording
498
+ # stub marker dir to assert zero invocations.
499
+ rm -rf "$ISO" "$STUB_BIN"
500
+ if [ "$ACTUAL_EXIT" = "0" ]; then
501
+ test_result "cbp-session-start-hook.sh graceful-degrade (no repo.json) exits 0" "passed" "passed"
502
+ else
503
+ test_result "cbp-session-start-hook.sh graceful-degrade (no repo.json) exits 0" "passed" "failed (exit=$ACTUAL_EXIT)"
504
+ fi
505
+
506
+ # Positive path: with .codebyplan/repo.json present, the hook must invoke
507
+ # `npx codebyplan sync` AND `npx codebyplan watch start` (recording stub
508
+ # writes each invocation's args to a marker file), and still exit 0.
509
+ ISO=$(mktemp -d)
510
+ STUB_BIN=$(mktemp -d)
511
+ MARKER="$STUB_BIN/invocations.log"
512
+ mkdir -p "$ISO/.codebyplan"
513
+ printf '{}' > "$ISO/.codebyplan/repo.json"
514
+ printf '#!/bin/bash
515
+ echo "$@" >> "%s"
516
+ exit 0
517
+ ' "$MARKER" > "$STUB_BIN/npx"
518
+ chmod +x "$STUB_BIN/npx"
519
+ ACTUAL_EXIT=$(CLAUDE_PROJECT_DIR="$ISO" PATH="$STUB_BIN:$PATH" bash "$SESSION_START_HOOK" >/dev/null 2>&1; echo $?)
520
+ if [ "$ACTUAL_EXIT" = "0" ] && grep -q "codebyplan sync" "$MARKER" 2>/dev/null && grep -q "codebyplan watch start" "$MARKER" 2>/dev/null; then
521
+ test_result "cbp-session-start-hook.sh positive path invokes sync + watch start, exits 0" "passed" "passed"
522
+ else
523
+ test_result "cbp-session-start-hook.sh positive path invokes sync + watch start, exits 0" "passed" "failed (exit=$ACTUAL_EXIT)"
524
+ fi
525
+ rm -rf "$ISO" "$STUB_BIN"
526
+ fi
527
+
528
+ echo ""
529
+
458
530
  # ===== SUMMARY =====
459
531
  echo "=== TEST SUMMARY ==="
460
532
  echo -e "Passed: ${GREEN}$PASSED${NC}"
@@ -1,5 +1,16 @@
1
1
  {
2
2
  "hooks": {
3
+ "SessionStart": [
4
+ {
5
+ "hooks": [
6
+ {
7
+ "type": "command",
8
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/cbp-session-start-hook.sh",
9
+ "timeout": 30
10
+ }
11
+ ]
12
+ }
13
+ ],
3
14
  "UserPromptSubmit": [
4
15
  {
5
16
  "hooks": [
@@ -48,9 +48,10 @@ esac
48
48
  FILENAME=$(basename "$FILE_PATH" ".$EXT")
49
49
 
50
50
  if match_path '^/(\.claude|docs)/'; then
51
- # Skip special naming patterns (SKILL/AGENT/CLAUDE/MEMORY/TASK-N/CHK-NNN/date/week-N/research phase/README)
51
+ # Skip special naming patterns (SKILL/AGENT/CLAUDE/MEMORY/TASK-N/CHK-NNN/date/week-N/research phase/README/INDEX)
52
52
  # CHK formats: CHK-001 (generic) or CHK-H001/CHK-A001/CHK-B001 (launch: Homepage/Application/Backdoor)
53
- if ! echo "$FILENAME" | grep -qE '^(SKILL|AGENT|CLAUDE|MEMORY|TASK-[1-9]|[0-9]{2}-[0-9]{2}-[0-9]{2}-CHK-([0-9]{3}|[HAB][0-9]{3})|CHK-([0-9]{3}|[HAB][0-9]{3})|[0-9]{2}-[0-9]{2}-[0-9]{2}|week-[0-9]+|[1-8]-|README)'; then
53
+ # INDEX: grep-native registry filename used by the architecture-map pipeline (.claude/architecture/INDEX.md) and vendor docs
54
+ if ! echo "$FILENAME" | grep -qE '^(SKILL|AGENT|CLAUDE|MEMORY|TASK-[1-9]|[0-9]{2}-[0-9]{2}-[0-9]{2}-CHK-([0-9]{3}|[HAB][0-9]{3})|CHK-([0-9]{3}|[HAB][0-9]{3})|[0-9]{2}-[0-9]{2}-[0-9]{2}|week-[0-9]+|[1-8]-|README|INDEX)'; then
54
55
  if echo "$FILENAME" | grep -qE '[A-Z]|_'; then
55
56
  block "Filename must be kebab-case (lowercase with hyphens)" "Got: $FILENAME, Expected: $(echo "$FILENAME" | tr '[:upper:]' '[:lower:]' | tr '_' '-')"
56
57
  fi
@@ -0,0 +1,30 @@
1
+ ---
2
+ scope: org-shared
3
+ ---
4
+
5
+ # Architecture Map
6
+
7
+ When `.claude/architecture/` exists in this repo, per-module map files may be present.
8
+
9
+ ## Rule
10
+
11
+ - Before analyzing or editing files in a module, Glob `.claude/architecture/<module-slug>.md`.
12
+ - If a map file exists, read it before proceeding — it provides pre-computed structural
13
+ context (boundaries, public surface, internal layout, dependencies, landmarks) that
14
+ reduces the need for broad file-system scans.
15
+ - Map absence is **not a blocker** — continue with standard file-system analysis when no
16
+ map exists.
17
+ - The full consultation contract (when to read, how to parse, agent phases) is at
18
+ `.claude/context/architecture-map.md`.
19
+
20
+ ## Why
21
+
22
+ Architecture maps are pre-computed indexes of module structure. Reading one replaces
23
+ several individual file-reads and surfaces cross-module impact that point-in-time grep
24
+ may miss. A 10-second read prevents a scoping gap.
25
+
26
+ ## Generate / Refresh
27
+
28
+ - `/cbp-map-architecture` — generate or regenerate maps for all/selected modules.
29
+ - `/cbp-refresh-arch-map` — drift-scoped refresh (re-runs only stale modules).
30
+ - `codebyplan arch-map status` — list modules and their map freshness.
@@ -23,6 +23,9 @@ paths:
23
23
  | `context/testing/eslint.md` | `cbp-improve-round` | Phase 1.5 | Config-file compliance audit |
24
24
  | `context/mcp-docs.md` | `cbp-task-planner` | Phase 2.6 | MCP library doc lookup contract — per-dependency consultation via DocsByPlan MCP tools (resolve_library_id → search_chunks/lookup_symbol → get_chunk) |
25
25
  | `context/mcp-docs.md` | `cbp-round-executor` | Step 3.4 | Library-specific reference — pre-write API verification via DocsByPlan MCP tools |
26
+ | `context/architecture/arch-map-spec.md` | `cbp-map-architecture` | Entry | Canonical architecture-map artifact format — per-module frontmatter + sections, INDEX.md row format, dependency-graph format |
27
+ | `context/architecture-map.md` | `cbp-task-planner` | Phase 3 | Architecture map consultation contract — when + how to read per-module maps before finalizing scope |
28
+ | `context/architecture-map.md` | `cbp-round-executor` | Step 2.4 | Architecture map consultation contract — when + how to read per-module maps before editing files |
26
29
  | `rules/parallel-waves.md` | `cbp-task-planner` | Phase 5.6 | Wave schema, invariants (3..15 file-count), and the proximity-split algorithm (a `rules/` file, not `context/**`; listed here for consumer discoverability) |
27
30
 
28
31
  New context files MUST be added here in the same change that introduces the consumer — or the file is orphan infrastructure.
@@ -80,7 +80,7 @@ Skills that delete Supabase branches MUST:
80
80
 
81
81
  1. Verify the branch name matches the feat branch being removed (never delete by
82
82
  `project_ref` alone).
83
- 2. Never delete the parent/production project (`rrvtrumtkhrsbhcyrwvf`) itself.
83
+ 2. Never delete the branch where `is_default` is true in the `list_branches` response (the parent/production branch) or any other persistent/long-lived branch.
84
84
  3. Never delete a persistent/long-lived branch that does not correspond to the git branch
85
85
  being torn down.
86
86
 
@@ -110,7 +110,9 @@
110
110
  "Skill(cbp-git-commit)",
111
111
  "Skill(cbp-git-worktree-create)",
112
112
  "Skill(cbp-git-worktree-remove)",
113
+ "Skill(cbp-map-architecture)",
113
114
  "Skill(cbp-merge-main)",
115
+ "Skill(cbp-refresh-arch-map)",
114
116
  "Skill(cbp-refresh-infra)",
115
117
  "Skill(cbp-round-check)",
116
118
  "Skill(cbp-round-end)",
@@ -192,6 +194,16 @@
192
194
  "Bash(npx codebyplan lsp:*)",
193
195
  "Bash(codebyplan round:*)",
194
196
  "Bash(npx codebyplan round:*)",
197
+ "Bash(codebyplan sync:*)",
198
+ "Bash(npx codebyplan sync:*)",
199
+ "Bash(codebyplan watch:*)",
200
+ "Bash(npx codebyplan watch:*)",
201
+ "Bash(codebyplan checkpoint:*)",
202
+ "Bash(npx codebyplan checkpoint:*)",
203
+ "Bash(codebyplan task:*)",
204
+ "Bash(npx codebyplan task:*)",
205
+ "Bash(codebyplan session:*)",
206
+ "Bash(npx codebyplan session:*)",
195
207
  "Bash(codebyplan help:*)",
196
208
  "Bash(npx codebyplan help:*)",
197
209
  "Bash(codebyplan --version:*)",
@@ -199,7 +211,9 @@
199
211
  "Bash(codebyplan bump:*)",
200
212
  "Bash(npx codebyplan bump:*)",
201
213
  "Bash(codebyplan scaffold-publish-workflow:*)",
202
- "Bash(npx codebyplan scaffold-publish-workflow:*)"
214
+ "Bash(npx codebyplan scaffold-publish-workflow:*)",
215
+ "Bash(codebyplan arch-map:*)",
216
+ "Bash(npx codebyplan arch-map:*)"
203
217
  ]
204
218
  },
205
219
  "attribution": {
@@ -14,17 +14,17 @@ Full re-evaluation: compares initial ideas vs delivered work, aggregates files a
14
14
 
15
15
  ### Step 1: Identify Checkpoint
16
16
 
17
- **If arguments provided:** Parse `$ARGUMENTS` for CHK-NNN format, extract number. Use MCP `get_checkpoints` to find by number.
17
+ **If arguments provided:** Parse `$ARGUMENTS` for CHK-NNN format, extract number. Scan `.codebyplan/state/checkpoints/*.json` to find by `number` field (local-first; if missing/stale run `npx codebyplan sync` once; break-glass: MCP `get_checkpoints`).
18
18
 
19
- **If NO arguments:** Use MCP `get_current_task` to get the active checkpoint.
19
+ **If NO arguments:** Read `.codebyplan/state/session/current.json` to get the active checkpoint (fallback: MCP `get_current_task`).
20
20
 
21
21
  If no checkpoint found, show error and stop.
22
22
 
23
23
  ### Step 2: Load All Data
24
24
 
25
- 1. Get checkpoint details (context, research, qa, ideas, goal, user_context)
26
- 2. Use MCP `get_tasks` for the checkpoint
27
- 3. For each task, use MCP `get_rounds` to get all rounds
25
+ 1. Read `.codebyplan/state/checkpoints/<id>.json` for checkpoint details (context, research, qa, ideas, goal, user_context). Break-glass: MCP `get_checkpoints`.
26
+ 2. Read task files under `.codebyplan/state/checkpoints/<id>/tasks/*.json` (fallback: MCP `get_tasks`).
27
+ 3. For each task, read round files under `.codebyplan/state/checkpoints/<id>/tasks/<taskId>/rounds/*.json` (fallback: MCP `get_rounds`).
28
28
 
29
29
  ### Step 3: Before/After Comparison
30
30
 
@@ -109,7 +109,7 @@ Aggregate the files touched across all tasks (reusing Step 4's deduplicated tabl
109
109
  credential_vars: [from e2e.json — env var names only, never secrets]
110
110
  ```
111
111
 
112
- Hold each specialist's output keyed by framework (an `e2e_outputs[framework]` map) for this skill's aggregation — checkpoint-check has no MCP round, so this lives in-memory during the run (persist to `checkpoint.context` via `update_checkpoint` at Step 7 if a durable record is needed). `test_strategy` is intentionally omitted — the agent resolves it from `.codebyplan/e2e.json` and the DB tech-stack record.
112
+ Hold each specialist's output keyed by framework (an `e2e_outputs[framework]` map) for this skill's aggregation — checkpoint-check has no MCP round, so this lives in-memory during the run (persist to `checkpoint.context` via the Step 7 CLI write-through — `codebyplan checkpoint update` — if a durable record is needed). `test_strategy` is intentionally omitted — the agent resolves it from `.codebyplan/e2e.json` and the DB tech-stack record.
113
113
 
114
114
  3. **Wait for all specialists to complete.** Each agent's output carries `whole_checkpoint_aggregated: true` confirming whole-checkpoint formatting.
115
115
 
@@ -120,7 +120,7 @@ Aggregate the files touched across all tasks (reusing Step 4's deduplicated tabl
120
120
  Continue to Step 6.
121
121
 
122
122
  5. **On fail** (any framework `f`: `e2e_outputs[f].status === 'failed'` OR `e2e_outputs[f].test_results.failed > 0`): build a failure summary from `e2e_outputs[*].test_results.failures[]` aggregated and grouped by `category`. Surface via `AskUserQuestion`:
123
- - **(a) Create fix-task in CHK-{NNN} (recommended)** — invoke MCP `create_task` with `checkpoint_id=current_checkpoint_id`, `title="Fix checkpoint-level e2e failures (CHK-{NNN})"`, `requirements` containing the detailed failure breakdown (category counts, files involved, pages broken, screenshot paths from `e2e_outputs[*].screenshots[]`), AND `context: { source_checkpoint_id, e2e_failure_summary: { category_counts, pages_broken, screenshot_paths }, fix_type: "checkpoint_e2e" }` so downstream `cbp-task-planner` can verify failure premises. Per `cbp-round-end` reference `findings-presentation.md` "Infra Issue Absorption Contract — Resolve-in-Current-Scope by Default", checkpoint-level e2e failures absorb into the active checkpoint — not standalone.
123
+ - **(a) Create fix-task in CHK-{NNN} (recommended)** — run `codebyplan task create` (CLI write-through; break-glass: MCP `create_task`) with `checkpoint_id=current_checkpoint_id`, `title="Fix checkpoint-level e2e failures (CHK-{NNN})"`, `requirements` containing the detailed failure breakdown (category counts, files involved, pages broken, screenshot paths from `e2e_outputs[*].screenshots[]`), AND `context: { source_checkpoint_id, e2e_failure_summary: { category_counts, pages_broken, screenshot_paths }, fix_type: "checkpoint_e2e" }` so downstream `cbp-task-planner` can verify failure premises. Per `cbp-round-end` reference `findings-presentation.md` "Infra Issue Absorption Contract — Resolve-in-Current-Scope by Default", checkpoint-level e2e failures absorb into the active checkpoint — not standalone.
124
124
  - **(b) Surface as warning only — proceed to checkpoint-end** — append `| Checkpoint E2E | warning | N failures (deferred) |` to Step 5 QA Summary; continue to Step 6.
125
125
  - **(c) Halt — review manually** — STOP and wait for the user.
126
126
 
@@ -145,7 +145,7 @@ If unapproved files exist:
145
145
 
146
146
  ### Step 7: Save Results
147
147
 
148
- Update checkpoint via MCP `update_checkpoint`:
148
+ Update checkpoint via `codebyplan checkpoint update --id <id> --qa <json> --context <json>` (CLI write-through; break-glass: MCP `update_checkpoint`):
149
149
  - `qa`: aggregated QA results
150
150
  - `context`: add `check_results` with before/after, file summary, assessment
151
151
 
@@ -155,6 +155,6 @@ If all clear, auto-trigger `/cbp-checkpoint-end`.
155
155
 
156
156
  ## Integration
157
157
 
158
- - **Reads**: MCP `get_checkpoints`, `get_tasks`, `get_rounds`, `get_current_task`
159
- - **Writes**: MCP `update_checkpoint` (qa, context)
158
+ - **Reads**: `.codebyplan/state/checkpoints/<id>.json`, `checkpoints/<id>/tasks/*.json`, `checkpoints/<id>/tasks/<taskId>/rounds/*.json`, `session/current.json` (local-first; `npx codebyplan sync` if stale; break-glass: MCP `get_checkpoints`, `get_tasks`, `get_rounds`, `get_current_task`)
159
+ - **Writes**: `codebyplan checkpoint update --qa ... --context ...` (CLI write-through; break-glass: MCP `update_checkpoint`)
160
160
  - **Triggers**: `/cbp-checkpoint-end` (auto, if ready) or STOPS for `/cbp-task-create` (if issues)
@@ -19,7 +19,7 @@ Parse the argument:
19
19
  | Shape | Regex | Resolves to |
20
20
  |-------|-------|-------------|
21
21
  | `{chk}` (e.g. `108`) | `^[0-9]+$` | Target CHK-{chk} |
22
- | _(empty)_ | — | Use MCP `get_current_task` to find the active checkpoint |
22
+ | _(empty)_ | — | Resolve from local state per Step 1.5/2 (MCP `get_current_task` break-glass) the active checkpoint |
23
23
 
24
24
  Anything else is malformed — surface this error and stop:
25
25
 
@@ -42,8 +42,8 @@ Given the parse from Step 0.5:
42
42
 
43
43
  | Parse | Resolution path |
44
44
  |-------|-----------------|
45
- | `{chk}` | MCP `get_checkpoints(repo_id)` filter `number === {chk}` (must exist). |
46
- | _(empty)_ | MCP `get_current_task` with repo_id. Get the active checkpoint. If no active checkpoint, show error and stop. |
45
+ | `{chk}` | Scan `.codebyplan/state/checkpoints/*.json` for `number === {chk}` (local-first; if missing/stale run `npx codebyplan sync` once; break-glass: MCP `get_checkpoints`). |
46
+ | _(empty)_ | Read `.codebyplan/state/session/current.json` for the active checkpoint (fallback: MCP `get_current_task`). If no active checkpoint, show error and stop. |
47
47
 
48
48
  ### Step 2: Verify Checkpoint End Has Run
49
49
 
@@ -59,7 +59,7 @@ Stop here.
59
59
 
60
60
  ### Step 2.5: Verify All Tasks Complete
61
61
 
62
- Use MCP `get_tasks` for the checkpoint. Verify all tasks have status `completed`.
62
+ Read task files under `.codebyplan/state/checkpoints/<id>/tasks/*.json` (fallback: MCP `get_tasks`). Verify all tasks have status `completed`.
63
63
 
64
64
  If incomplete tasks remain:
65
65
  ```
@@ -82,7 +82,7 @@ If any critical failures, warn the user but don't block.
82
82
 
83
83
  ### Step 4: Complete Checkpoint
84
84
 
85
- Use MCP `complete_checkpoint(checkpoint_id)`.
85
+ Run `codebyplan checkpoint complete --id <checkpoint-id>` (CLI write-through: updates `.codebyplan/state/checkpoints/<id>.json` + REST; break-glass: MCP `complete_checkpoint`).
86
86
 
87
87
  This automatically:
88
88
  - Sets status to `completed`
@@ -105,5 +105,5 @@ This automatically:
105
105
  ## Integration
106
106
 
107
107
  - **Triggered by**: `/cbp-checkpoint-end` (auto, after successful shipment)
108
- - **Reads**: MCP `get_current_task`, `get_tasks`, `get_rounds`
109
- - **Writes**: MCP `complete_checkpoint`
108
+ - **Reads**: `.codebyplan/state/session/current.json`, `checkpoints/<id>.json`, `checkpoints/<id>/tasks/*.json` (local-first; `npx codebyplan sync` if stale; break-glass: MCP `get_current_task`, `get_tasks`, `get_rounds`)
109
+ - **Writes**: `codebyplan checkpoint complete --id <id>` (CLI write-through; break-glass: MCP `complete_checkpoint`)
@@ -20,7 +20,7 @@ Runs INLINE. This is the **mechanical** stage only: capture raw user input, infe
20
20
 
21
21
  ### Step 1: Check for Existing Checkpoint Data
22
22
 
23
- Source `repo_id` from `.codebyplan/repo.json`. If `$ARGUMENTS` contains a checkpoint number, load it via MCP `get_checkpoints`. If the checkpoint already has `ideas[]` with descriptions, reuse `ideas[].description` (do not re-ask) and skip Step 2.
23
+ Source `repo_id` from `.codebyplan/repo.json`. If `$ARGUMENTS` contains a checkpoint number, read `.codebyplan/state/checkpoints/` to find the matching file by `number` field (local-first). If missing/stale, run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_checkpoints` when the state dir is absent and sync fails. If the checkpoint already has `ideas[]` with descriptions, reuse `ideas[].description` (do not re-ask) and skip Step 2.
24
24
 
25
25
  ### Step 2: Get Checkpoint Description
26
26
 
@@ -71,14 +71,16 @@ Record the choice; it drives both the create call (Step 8) and the plan→start
71
71
 
72
72
  ### Step 7: Determine Next Checkpoint Number
73
73
 
74
- MCP `get_checkpoints` for the repo; highest `number` + 1.
74
+ Scan `.codebyplan/state/checkpoints/*.json` for the highest `number` field + 1. If state dir is absent, run `npx codebyplan sync` once. Break-glass fallback: MCP `get_checkpoints` when sync fails.
75
75
 
76
76
  ### Step 8: Create Checkpoint Row
77
77
 
78
- MCP `create_checkpoint`:
79
- - `repo_id` (from `.codebyplan/repo.json`), `number`, `title`, `goal`, `deadline`, `status: "pending"`
80
- - `ideas`: `[{ description: <raw user text> }]`
81
- - `worktree_id`: the resolved worktree from Step 6 **only if the user chose "claim"**; omit when "leave open"
78
+ `codebyplan checkpoint create` (CLI write-through: writes `.codebyplan/state/checkpoints/<id>.json` + REST). Pass flags:
79
+ - `--repo-id` (from `.codebyplan/repo.json`), `--number`, `--title`, `--goal`, `--deadline`, `--status pending`
80
+ - `--ideas` JSON `[{ description: <raw user text> }]`
81
+ - `--worktree-id` the resolved worktree **only if the user chose "claim"**; omit when "leave open"
82
+
83
+ Break-glass fallback: MCP `create_checkpoint` when the CLI is unavailable.
82
84
 
83
85
  This is the first identity-stamping point — when claiming, passing `worktree_id` here engages the CHK-104 hard-lock from birth. No `context`, `research`, `plan`, or tasks are written here.
84
86
 
@@ -93,7 +95,7 @@ git checkout -b "feat/CHK-{NNN}-{slug}" "origin/$BASE" 2>/dev/null \
93
95
  git push -u origin "feat/CHK-{NNN}-{slug}"
94
96
  ```
95
97
 
96
- Slug: lowercase, dash-joined, punctuation dropped, ≤40 chars. Persist the branch via MCP `update_checkpoint(checkpoint_id, branch_name: "feat/CHK-{NNN}-{slug}")`. (The dedicated `/cbp-git-branch-feat-create` skill is the canonical config-driven helper if you prefer to delegate.)
98
+ Slug: lowercase, dash-joined, punctuation dropped, ≤40 chars. Persist the branch via `codebyplan checkpoint update --id <checkpoint-id> --branch-name "feat/CHK-{NNN}-{slug}"` (CLI write-through; break-glass: MCP `update_checkpoint`). (The dedicated `/cbp-git-branch-feat-create` skill is the canonical config-driven helper if you prefer to delegate.)
97
99
 
98
100
  **Note — Supabase preview branch**: no Supabase branch is created here. Creation is lazy — it happens on the first DB change when `/cbp-supabase-migrate` runs on this feat branch, which provisions a Supabase branch named identically to the git branch. See `cbp-supabase-migrate` Step 2.3 for the creation protocol.
99
101
 
@@ -113,6 +115,6 @@ Auto-trigger `/cbp-checkpoint-plan {NNN}` in the same context. This skill create
113
115
  ## Integration
114
116
 
115
117
  - **Runs inline**: mechanical setup only — no assessment, research, Q&A, plan, or tasks
116
- - **Reads**: MCP `get_checkpoints`; `.codebyplan/repo.json`, `.codebyplan/git.json`; `npx codebyplan resolve-worktree`
117
- - **Writes**: MCP `create_checkpoint` (description-only ideas + deadline + optional worktree_id), `update_checkpoint` (branch_name)
118
+ - **Reads**: `.codebyplan/state/checkpoints/*.json` (local-first; `npx codebyplan sync` if stale; MCP `get_checkpoints` break-glass); `.codebyplan/repo.json`, `.codebyplan/git.json`; `npx codebyplan resolve-worktree`
119
+ - **Writes**: `codebyplan checkpoint create` (description-only ideas + deadline + optional worktree_id), `codebyplan checkpoint update --branch-name` (break-glass: MCP `create_checkpoint` / `update_checkpoint`)
118
120
  - **Triggers**: `/cbp-checkpoint-plan` (auto)
@@ -34,7 +34,7 @@ Before any shipment logic, ensure the feat branch is current against main. Shipm
34
34
 
35
35
  ### Step 1: Get Active Checkpoint
36
36
 
37
- Use MCP `get_current_task` with repo_id. Get the active checkpoint.
37
+ Read local state `.codebyplan/state/checkpoints/<id>.json` to get the active checkpoint; on miss run `npx codebyplan sync` once and re-read. Use MCP `get_current_task` as documented break-glass when the state dir is absent and sync fails.
38
38
 
39
39
  If no active checkpoint, show error and stop.
40
40
 
@@ -206,7 +206,7 @@ After the feat branch git delete, run the same conditional Supabase teardown for
206
206
 
207
207
  ### Step 10: Save Shipment Results and Summary
208
208
 
209
- Update checkpoint context via MCP `update_checkpoint`. The `shipment` block contains both branch promotion AND runtime surface results (from `/cbp-ship` Step 7):
209
+ Update checkpoint context via `codebyplan checkpoint update <id> --context '{"shipment": {...}}'` (CLI write-through); use MCP `update_checkpoint` as documented break-glass when the CLI is unavailable. The `shipment` block contains both branch promotion AND runtime surface results (from `/cbp-ship` Step 7):
210
210
 
211
211
  ```
212
212
  context.shipment: {
@@ -281,7 +281,7 @@ Auto-trigger `/cbp-checkpoint-complete`.
281
281
  ## Integration
282
282
 
283
283
  - **Triggered by**: `/cbp-checkpoint-check` (auto, when ready)
284
- - **Reads**: MCP `get_current_task`, `.codebyplan/git.json` (`branch_config`), `.codebyplan/server.json` (`auto_push_enabled`), `.codebyplan/shipment.json` (`shipment`), git branches
285
- - **Writes**: MCP `update_checkpoint` (context.shipment both branch promotion and runtime surface results)
284
+ - **Reads**: Local state `.codebyplan/state/checkpoints/<id>.json`; on miss `npx codebyplan sync` once; MCP `get_current_task` as documented break-glass when the state dir is absent and sync fails. Also reads `.codebyplan/git.json` (`branch_config`), `.codebyplan/server.json` (`auto_push_enabled`), `.codebyplan/shipment.json` (`shipment`), git branches.
285
+ - **Writes**: `codebyplan checkpoint update <id> --context '...'` (CLI write-through) for context.shipment; MCP `update_checkpoint` break-glass. Note: `mcp__supabase__list_branches` / `mcp__supabase__delete_branch` calls in Steps 8–9 are Supabase MCP (not CodeByPlan MCP) and are unchanged.
286
286
  - **Calls**: `/cbp-merge-main` (Step 0, sync); `/cbp-ship-main` (Step 5, branch promotion to main); `/cbp-ship` (Step 7, runtime surface deploy + verification)
287
287
  - **Triggers**: `/cbp-checkpoint-complete` (auto, after successful shipment)
@@ -26,15 +26,15 @@ Source `repo_id` from `.codebyplan/repo.json` — every MCP call below that take
26
26
 
27
27
  | Shape | Resolves to |
28
28
  |-------|-------------|
29
- | `{chk}` (e.g. `138`) | CHK-{chk} via MCP `get_checkpoints` filtered by `number` |
30
- | _(empty)_ | Active/pending checkpoint via MCP `get_current_task`; if none in progress, the most recent `pending` checkpoint that has no `plan.steps` |
29
+ | `{chk}` (e.g. `138`) | CHK-{chk}: scan `.codebyplan/state/checkpoints/*.json` by `number` field (local-first; fallback MCP `get_checkpoints`) |
30
+ | _(empty)_ | Active/pending checkpoint: read `.codebyplan/state/session/current.json` (fallback MCP `get_current_task`); if none in progress, the most recent `pending` checkpoint with no `plan.steps` from local state |
31
31
 
32
32
  Malformed (non-numeric, contains `-`): surface `checkpoint-plan: invalid argument` and stop.
33
33
 
34
34
  ### Step 1: Load Checkpoint + Existing Tasks
35
35
 
36
- 1. Resolve the checkpoint (Step 0). Load `user_context`, `ideas[]`, `context` (decisions / discoveries / dependencies / constraints / qa_answers / alternatives), `research`, `plan`.
37
- 2. MCP `get_tasks(checkpoint_id)` — load existing tasks. This sets the mode:
36
+ 1. Resolve the checkpoint (Step 0). Read `.codebyplan/state/checkpoints/<id>.json` (local-first; if missing/stale run `npx codebyplan sync` once; break-glass: MCP `get_checkpoints`). Load `user_context`, `ideas[]`, `context` (decisions / discoveries / dependencies / constraints / qa_answers / alternatives), `research`, `plan`.
37
+ 2. Read task files under `.codebyplan/state/checkpoints/<id>/tasks/*.json` (fallback: MCP `get_tasks(checkpoint_id)`) — load existing tasks. This sets the mode:
38
38
  - **fresh** — zero tasks: full plan + create all tasks.
39
39
  - **additive re-plan** — tasks exist: gap-analyse against them; only ADD new tasks or refine requirements for gaps. NEVER delete or overwrite an in-flight task.
40
40
  3. Note whether `worktree_id` is set (claimed at create) — drives routing in Step 11.
@@ -45,7 +45,7 @@ Iterate ALL `ideas[]` (not just the first). For each:
45
45
 
46
46
  1. **Discovery level** — 0 (trivial) · 1 (check existing patterns) · 2 (read docs/APIs) · 3 (unfamiliar territory).
47
47
  2. **Codebase analysis** — Glob/Grep/Read the related code: existing patterns to follow, files that will change, integration points.
48
- 3. **Research (level 2+ only)** — spawn a single `cbp-research` subagent for web/library research. Persist findings to `checkpoint.research` via MCP `update_checkpoint` — never to local docs. In additive re-plan mode, read the existing `research` (loaded in Step 1) and append — do not replace the object.
48
+ 3. **Research (level 2+ only)** — spawn a single `cbp-research` subagent for web/library research. Persist findings to `checkpoint.research` via `codebyplan checkpoint update --id <id> --research <json>` (CLI write-through; break-glass: MCP `update_checkpoint`) — never to local docs. In additive re-plan mode, read the existing `research` (loaded in Step 1) and append — do not replace the object.
49
49
  4. **Cross-reference** ideas against each other: overlaps, conflicts, shared dependencies.
50
50
 
51
51
  Write each idea's analysis into `ideas[N].assessment` (Claude-authored; never touch `description`, which is the user's words).
@@ -90,7 +90,7 @@ Resolve every remaining ambiguity. Ask via AskUserQuestion (max 4 per batch). Af
90
90
 
91
91
  ### Step 8: Generate or Extend `plan.steps[]`
92
92
 
93
- Build an ordered `plan.steps[]` where each step is `{ title, description, scope }` (`scope` = which idea/requirement it addresses). Every `ideas[].requirements` item AND every kept gap finding must be covered by ≥1 step. In additive mode, append/refine steps — do not drop steps that map to existing tasks. Save via MCP `update_checkpoint(checkpoint_id, plan: { steps: [...] })` — `plan` is a top-level checkpoint field, so this write does not touch `context` or `research`; the context-replaces rule in Step 10 applies only to the `context` JSONB.
93
+ Build an ordered `plan.steps[]` where each step is `{ title, description, scope }` (`scope` = which idea/requirement it addresses). Every `ideas[].requirements` item AND every kept gap finding must be covered by ≥1 step. In additive mode, append/refine steps — do not drop steps that map to existing tasks. Save via `codebyplan checkpoint update --id <id> --plan <json>` (CLI write-through; break-glass: MCP `update_checkpoint`) — `plan` is a top-level checkpoint field, so this write does not touch `context` or `research`; the context-replaces rule in Step 10 applies only to the `context` JSONB.
94
94
 
95
95
  ### Step 9: Create Tasks as Vertical Slices
96
96
 
@@ -102,11 +102,11 @@ Each task is a complete, independently shippable vertical slice — group by the
102
102
 
103
103
  Sizing: with a 1M-token context, tasks can be large — group by coherent purpose; a single task touching 30+ files is fine if they serve one theme. Only split when themes are genuinely independent.
104
104
 
105
- For each task use MCP `create_task` (`checkpoint_id`, sequential `number` after the current max, `title`, `requirements`, `context` with the relevant decisions/discoveries). **Additive mode:** create only tasks for steps not already covered by an existing task; never delete in-flight tasks. **Coverage check** — a plan step counts as covered only when an existing task's requirements address its full scope; when uncertain, create the task and note in its requirements `may overlap with TASK-N — review before executing`.
105
+ For each task use `codebyplan task create --checkpoint-id <id> --number <n> --title <title> --requirements <json> --context <json>` (CLI write-through; break-glass: MCP `create_task`). **Additive mode:** create only tasks for steps not already covered by an existing task; never delete in-flight tasks. **Coverage check** — a plan step counts as covered only when an existing task's requirements address its full scope; when uncertain, create the task and note in its requirements `may overlap with TASK-N — review before executing`.
106
106
 
107
107
  ### Step 10: Persist Full Context
108
108
 
109
- Final write of the complete `checkpoint.context` JSONB via MCP `update_checkpoint`. Honor the **context-replaces-not-merges** contract: read the current context, merge your additions in memory, write the FULL object (`decisions` + `discoveries` + `dependencies` + `constraints` + `qa_answers` + `alternatives`). A partial write clobbers sibling keys. Phrase any database-verb words as prose in payloads (WAF gate).
109
+ Final write of the complete `checkpoint.context` JSONB via `codebyplan checkpoint update --id <id> --context <json>` (CLI write-through; break-glass: MCP `update_checkpoint`). Honor the **context-replaces-not-merges** contract: read the current context, merge your additions in memory, write the FULL object (`decisions` + `discoveries` + `dependencies` + `constraints` + `qa_answers` + `alternatives`). A partial write clobbers sibling keys. Phrase any database-verb words as prose in payloads (WAF gate).
110
110
 
111
111
  ### Step 11: Show Result + Route
112
112
 
@@ -129,8 +129,8 @@ This skill does **NOT** activate the checkpoint and does **NOT** claim a user/wo
129
129
 
130
130
  ## Integration
131
131
 
132
- - **Reads**: MCP `get_current_task`, `get_checkpoints`, `get_tasks`
133
- - **Writes**: MCP `update_checkpoint` (ideas assessment, context, plan, research), `create_task`
132
+ - **Reads**: `.codebyplan/state/checkpoints/<id>.json`, `checkpoints/<id>/tasks/*.json`, `session/current.json` (local-first; `npx codebyplan sync` if stale; break-glass: MCP `get_current_task`, `get_checkpoints`, `get_tasks`)
133
+ - **Writes**: `codebyplan checkpoint update` (ideas assessment, context, plan, research), `codebyplan task create` (break-glass: MCP `update_checkpoint`, `create_task`)
134
134
  - **Spawns**: `cbp-research` (level 2+ only), config-matched `cbp-e2e-*` specialist (opt-in discovery probe, `whole_checkpoint_mode` — see `context/testing/e2e.md` dispatch contract)
135
135
  - **Triggered by**: `/cbp-checkpoint-create` (auto), or user directly
136
136
  - **Triggers**: `/cbp-checkpoint-start` (auto when claimed at create; directive when left open)
@@ -24,14 +24,14 @@ Source `repo_id` from `.codebyplan/repo.json`. Resolve caller worktree once for
24
24
 
25
25
  | Shape | Resolves to |
26
26
  |-------|-------------|
27
- | `{chk}` (e.g. `138`) | CHK-{chk} via MCP `get_checkpoints` filtered by `number` |
28
- | _(empty)_ | The next `pending` checkpoint that already has tasks (planned but not yet started); if several, the lowest-numbered |
27
+ | `{chk}` (e.g. `138`) | CHK-{chk}: scan `.codebyplan/state/checkpoints/*.json` by `number` field (local-first; fallback MCP `get_checkpoints`) |
28
+ | _(empty)_ | The next `pending` checkpoint with tasks in local state (lowest-numbered); fallback MCP `get_checkpoints` |
29
29
 
30
30
  Malformed (non-numeric, contains `-`): surface `checkpoint-start: invalid argument` and stop.
31
31
 
32
32
  ### Step 1: Load Checkpoint + Tasks
33
33
 
34
- Load the checkpoint (`status`, `worktree_id`, `plan`) and its tasks via MCP `get_tasks(checkpoint_id)`.
34
+ Read `.codebyplan/state/checkpoints/<id>.json` for `status`, `worktree_id`, `plan` (local-first; if missing/stale run `npx codebyplan sync` once; break-glass: MCP `get_checkpoints`). Read task files under `.codebyplan/state/checkpoints/<id>/tasks/*.json` (fallback: MCP `get_tasks(checkpoint_id)`).
35
35
 
36
36
  ### Step 2: Planned-Gate
37
37
 
@@ -57,7 +57,7 @@ This mirrors the CHK-104 hard-lock model — never wrest a checkpoint from a liv
57
57
 
58
58
  If the checkpoint is already `active` AND `worktree_id` already equals `CALLER_WT` (the Step 3 no-op row), skip this step entirely and proceed to Step 5 — nothing to write.
59
59
 
60
- Otherwise set the checkpoint `active` via MCP `update_checkpoint(checkpoint_id, status: "active"`, plus `worktree_id: CALLER_WT` when claiming per Step 3. `caller_worktree_id` (CHK-140 TASK-7) identifies the calling worktree and is auto-injected by the `cbp-mcp-caller-worktree-inject.sh` PreToolUse hook (CHK-198 TASK-2); the server falls back to the repo `main` worktree only when it is absent. If the checkpoint was already `active` but a claim is still needed, skip the status write and only write `worktree_id`.
60
+ Otherwise set the checkpoint `active` via `codebyplan checkpoint update --id <checkpoint-id> --status active` (CLI write-through; break-glass: MCP `update_checkpoint`), plus `--worktree-id CALLER_WT` when claiming per Step 3. For MCP break-glass path: `caller_worktree_id` identifies the calling worktree and is auto-injected by the `cbp-mcp-caller-worktree-inject.sh` PreToolUse hook (CHK-198 TASK-2); the server falls back to the repo `main` worktree only when it is absent. If the checkpoint was already `active` but a claim is still needed, skip the status write and only write `worktree_id`.
61
61
 
62
62
  ### Step 5: Route
63
63
 
@@ -77,8 +77,8 @@ Show a one-line confirmation before routing:
77
77
 
78
78
  ## Integration
79
79
 
80
- - **Reads**: MCP `get_checkpoints`, `get_tasks`; `npx codebyplan resolve-worktree`
81
- - **Writes**: MCP `update_checkpoint` (status + worktree_id; `caller_worktree_id` auto-injected by the cbp-mcp-caller-worktree-inject.sh hook, CHK-198 TASK-2; server falls back to repo `main` only when absent)
80
+ - **Reads**: `.codebyplan/state/checkpoints/<id>.json`, `checkpoints/<id>/tasks/*.json` (local-first; `npx codebyplan sync` if stale; break-glass: MCP `get_checkpoints`, `get_tasks`); `npx codebyplan resolve-worktree`
81
+ - **Writes**: `codebyplan checkpoint update --status active [--worktree-id <id>]` (CLI write-through; break-glass: MCP `update_checkpoint`; `caller_worktree_id` auto-injected by cbp-mcp-caller-worktree-inject.sh hook on the MCP path)
82
82
  - **Triggered by**: `/cbp-checkpoint-plan` (auto when claimed at create), `/cbp-todo` (planned-but-pending gate), or user directly
83
83
  - **Triggers**: `/cbp-task-start` (auto when claimed), or `/cbp-checkpoint-plan` (when the checkpoint is unplanned)
84
84
  - **Never**: plans or creates tasks — that is `/cbp-checkpoint-plan`
@@ -19,7 +19,7 @@ Parse the argument:
19
19
  | Shape | Regex | Resolves to |
20
20
  |-------|-------|-------------|
21
21
  | `{chk}` (e.g. `108`) | `^[0-9]+$` | Target CHK-{chk} |
22
- | _(empty)_ | — | Use MCP `get_current_task` to find the active checkpoint |
22
+ | _(empty)_ | — | Resolve from local state per Step 1.5/2 (MCP `get_current_task` break-glass) the active checkpoint |
23
23
 
24
24
  Anything else is malformed — surface this error and stop:
25
25
 
@@ -42,8 +42,8 @@ Given the parse from Step 0.5:
42
42
 
43
43
  | Parse | Resolution path |
44
44
  |-------|-----------------|
45
- | `{chk}` | MCP `get_checkpoints(repo_id)` filter `number === {chk}` (must exist). |
46
- | _(empty)_ | MCP `get_current_task` with repo_id (and worktree_id resolved via `npx codebyplan resolve-worktree`) to find the active checkpoint. If no active checkpoint, use MCP `get_checkpoints` filtered by `pending` status to find pending ones. |
45
+ | `{chk}` | Scan `.codebyplan/state/checkpoints/*.json` for `number === {chk}` (local-first; if missing/stale run `npx codebyplan sync` once; break-glass: MCP `get_checkpoints`). |
46
+ | _(empty)_ | Read `.codebyplan/state/session/current.json` (with worktree_id from `npx codebyplan resolve-worktree`) to find the active checkpoint (fallback: MCP `get_current_task`). If no active checkpoint, scan local state for `pending` checkpoints (fallback: MCP `get_checkpoints` filtered by `pending`). |
47
47
 
48
48
  ### Step 1.5: Detect Entry Context (from `/cbp-task-complete` expand path)
49
49
 
@@ -76,17 +76,17 @@ When the entry context is "expand from task-complete", `Update context` is the r
76
76
 
77
77
  ### Step 3: Apply Update
78
78
 
79
- Use MCP `update_checkpoint` with the appropriate fields.
79
+ Use `codebyplan checkpoint update --id <checkpoint-id> [--field value ...]` (CLI write-through: updates `.codebyplan/state/checkpoints/<id>.json` + REST; break-glass: MCP `update_checkpoint`).
80
80
 
81
81
  **For activation:**
82
82
  ```
83
- update_checkpoint(checkpoint_id, status: "active")
83
+ codebyplan checkpoint update --id <id> --status active
84
84
  ```
85
85
 
86
86
  **For context updates:**
87
- Read current checkpoint to get existing context, merge new data, then:
87
+ Read current checkpoint from `.codebyplan/state/checkpoints/<id>.json` to get existing context, merge new data, then:
88
88
  ```
89
- update_checkpoint(checkpoint_id, context: merged_context)
89
+ codebyplan checkpoint update --id <id> --context <merged_context_json>
90
90
  ```
91
91
 
92
92
  ### Step 4: Show Result and Route
@@ -110,6 +110,6 @@ Otherwise, no follow-up directive — the user is back in control.
110
110
 
111
111
  ## Integration
112
112
 
113
- - **Reads**: MCP `get_current_task`, `get_checkpoints`
114
- - **Writes**: MCP `update_checkpoint`
113
+ - **Reads**: `.codebyplan/state/session/current.json`, `checkpoints/<id>.json` (local-first; `npx codebyplan sync` if stale; break-glass: MCP `get_current_task`, `get_checkpoints`)
114
+ - **Writes**: `codebyplan checkpoint update --id <id> [--field value ...]` (CLI write-through; break-glass: MCP `update_checkpoint`)
115
115
  - **Triggered by**: User directly, OR `/cbp-task-complete` Step 9c (expand path) — see `task-complete/reference/checkpoint-done-branching.md`
@@ -44,7 +44,7 @@ When a scope flag is used:
44
44
  **`--scope-task` Behavior:**
45
45
 
46
46
  When `--scope-task` is used:
47
- 1. Read `task.files_changed[].path` via MCP `get_current_task`
47
+ 1. Read `task.files_changed[].path` from local state `.codebyplan/state/checkpoints/<id>/tasks/<id>.json` (on miss `npx codebyplan sync` once; MCP `get_current_task` as documented break-glass)
48
48
  2. Read currently-staged files via `git diff --cached --name-only`
49
49
  3. Compute intersection — only those paths are committed
50
50
  4. Foreign-staged files (in staged set but NOT in task) remain staged after the commit; user handles them in a separate commit
@@ -108,11 +108,14 @@ REPO_PATH="$(git rev-parse --show-toplevel)"
108
108
 
109
109
  **If `--files` provided:** Use the manual file list.
110
110
 
111
- **If `--scope-task`:** Resolve via MCP + intersection.
111
+ **If `--scope-task`:** Resolve via local state + intersection.
112
112
 
113
113
  ```bash
114
- # 1. Read task.files_changed[]
115
- task_paths=$(mcp get_current_task | jq -r '.files_changed[].path')
114
+ # 1. Read task.files_changed[] from local state (glob for active task file)
115
+ # On miss: npx codebyplan sync once, then re-read.
116
+ # MCP get_current_task as documented break-glass when state dir absent + sync fails.
117
+ task_paths=$(cat .codebyplan/state/checkpoints/*/tasks/*.json 2>/dev/null \
118
+ | jq -r 'select(.status=="in_progress") | .files_changed[].path' | head -n 200)
116
119
  # 2. Read staged paths
117
120
  staged_paths=$(git diff --cached --name-only)
118
121
  # 3. Compute intersection
@@ -263,6 +266,7 @@ Stage the missing files or use --all.
263
266
 
264
267
  ## Integration
265
268
 
269
+ - **Reads (--scope-task)**: Local state task file `.codebyplan/state/checkpoints/*/tasks/*.json` (in_progress); on miss `npx codebyplan sync` once; MCP `get_current_task` as documented break-glass when the state dir is absent and sync fails.
266
270
  - **Called by**: `/cbp-session-end`, `/cbp-task-complete`, `/cbp-checkpoint-complete`, manual
267
271
  - **Scope usage by commands**:
268
272
  - `/cbp-task-complete` -> `--no-push` (commit all staged)
@@ -135,12 +135,13 @@ After the git branch delete succeeds, run a conditional Supabase preview-branch
135
135
 
136
136
  > Lifecycle contract: see [[supabase-branch-lifecycle]].
137
137
 
138
- - Call `mcp__supabase__list_branches` with `project_id: rrvtrumtkhrsbhcyrwvf`.
138
+ - Resolve the parent project ref: read `.codebyplan/shipment.json` `.shipment.surfaces.supabase.project_ref`; if absent or empty, read the first line of `supabase/.temp/project-ref`. Use that resolved ref as the `project_id`.
139
+ - Call `mcp__supabase__list_branches` with the resolved `project_id`.
139
140
  - Scan the returned list for an entry whose `name` exactly equals `$BRANCH_NAME`.
140
141
  - If found: call `mcp__supabase__delete_branch` with its `branch_id`. Report "Supabase preview branch deleted: `$BRANCH_NAME`".
141
142
  - If not found: no-op silently — the GitHub integration may have already removed it on PR close; not-found is success, NOT an error.
142
143
  - If the `list_branches` call itself fails (network, auth, or a non-success response — distinct from a successful lookup that returns no match): emit a non-blocking warning that the Supabase preview branch for `$BRANCH_NAME` may still exist and should be verified in the dashboard. Do not treat an API failure as a not-found success.
143
- - Never delete the parent project `rrvtrumtkhrsbhcyrwvf` itself or any persistent/production branch.
144
+ - Never delete the branch where `is_default` is true in the `list_branches` response (the production/parent project branch) or any other persistent/long-lived branch.
144
145
 
145
146
  ### Step 10: Show Result
146
147