codebyplan 1.5.1 → 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 (205) hide show
  1. package/dist/cli.js +4462 -748
  2. package/package.json +5 -1
  3. package/templates/.gitkeep +0 -0
  4. package/templates/README.md +20 -0
  5. package/templates/agents/cbp-cc-executor.md +213 -0
  6. package/templates/agents/cbp-database-agent.md +229 -0
  7. package/templates/agents/cbp-improve-claude.md +245 -0
  8. package/templates/agents/cbp-improve-round.md +284 -0
  9. package/templates/agents/cbp-mechanical-edits.md +111 -0
  10. package/templates/agents/cbp-research.md +282 -0
  11. package/templates/agents/cbp-round-executor.md +604 -0
  12. package/templates/agents/cbp-security-agent.md +134 -0
  13. package/templates/agents/cbp-task-check.md +213 -0
  14. package/templates/agents/cbp-task-planner.md +582 -0
  15. package/templates/agents/cbp-test-e2e-agent.md +363 -0
  16. package/templates/agents/cbp-testing-qa-agent.md +400 -0
  17. package/templates/context/mcp-docs.md +139 -0
  18. package/templates/hooks/README.md +236 -0
  19. package/templates/hooks/cbp-auto-test-hooks.sh +44 -0
  20. package/templates/hooks/cbp-lint-format-on-edit.sh +159 -0
  21. package/templates/hooks/cbp-maestro-yaml-validate.sh +100 -0
  22. package/templates/hooks/cbp-mcp-migration-guard.sh +32 -0
  23. package/templates/hooks/cbp-mcp-round-sync.sh +79 -0
  24. package/templates/hooks/cbp-mcp-worktree-inject.sh +76 -0
  25. package/templates/hooks/cbp-notify.sh +68 -0
  26. package/templates/hooks/cbp-plugin-dispatch.sh +29 -0
  27. package/templates/hooks/cbp-pre-commit-quality-gate.sh +204 -0
  28. package/templates/hooks/cbp-statusline.sh +347 -0
  29. package/templates/hooks/cbp-subagent-statusline.sh +182 -0
  30. package/templates/hooks/cbp-test-coverage-gate.sh +144 -0
  31. package/templates/hooks/cbp-test-hooks.sh +320 -0
  32. package/templates/hooks/hooks.json +85 -0
  33. package/templates/hooks/validate-context-usage.sh +59 -0
  34. package/templates/hooks/validate-git-commit.sh +78 -0
  35. package/templates/hooks/validate-git-stash-deny.sh +32 -0
  36. package/templates/hooks/validate-structure-lengths.sh +57 -0
  37. package/templates/hooks/validate-structure-lib.sh +104 -0
  38. package/templates/hooks/validate-structure-patterns.sh +54 -0
  39. package/templates/hooks/validate-structure-scope.sh +33 -0
  40. package/templates/hooks/validate-structure-smoke.sh +95 -0
  41. package/templates/hooks/validate-structure-templates.sh +34 -0
  42. package/templates/hooks/validate-structure.sh +69 -0
  43. package/templates/rules/.gitkeep +0 -0
  44. package/templates/rules/README.md +47 -0
  45. package/templates/rules/context-file-loading.md +52 -0
  46. package/templates/rules/scope-vocabulary.md +64 -0
  47. package/templates/rules/todo-backend.md +109 -0
  48. package/templates/settings.project.base.json +55 -0
  49. package/templates/settings.user.base.json +25 -0
  50. package/templates/skills/cbp-build-cc-agent/SKILL.md +139 -0
  51. package/templates/skills/cbp-build-cc-agent/examples/read-only-reviewer.md +32 -0
  52. package/templates/skills/cbp-build-cc-agent/examples/with-hooks.md +41 -0
  53. package/templates/skills/cbp-build-cc-agent/examples/with-skills-preload.md +25 -0
  54. package/templates/skills/cbp-build-cc-agent/reference/cbp-quality.md +153 -0
  55. package/templates/skills/cbp-build-cc-agent/reference/frontmatter-fields.md +37 -0
  56. package/templates/skills/cbp-build-cc-agent/reference/permission-modes.md +18 -0
  57. package/templates/skills/cbp-build-cc-agent/scripts/validate-agent.sh +67 -0
  58. package/templates/skills/cbp-build-cc-agent/templates/agent.md +66 -0
  59. package/templates/skills/cbp-build-cc-claude-file/SKILL.md +178 -0
  60. package/templates/skills/cbp-build-cc-claude-file/examples/minimal-project.md +33 -0
  61. package/templates/skills/cbp-build-cc-claude-file/examples/monorepo-with-imports.md +39 -0
  62. package/templates/skills/cbp-build-cc-claude-file/reference/imports.md +72 -0
  63. package/templates/skills/cbp-build-cc-claude-file/reference/what-belongs.md +39 -0
  64. package/templates/skills/cbp-build-cc-claude-file/templates/project-claude-md.md +48 -0
  65. package/templates/skills/cbp-build-cc-claude-file/templates/user-claude-md.md +22 -0
  66. package/templates/skills/cbp-build-cc-memory/SKILL.md +201 -0
  67. package/templates/skills/cbp-build-cc-memory/examples/feedback-memory.md +11 -0
  68. package/templates/skills/cbp-build-cc-memory/examples/project-memory.md +11 -0
  69. package/templates/skills/cbp-build-cc-memory/examples/reference-memory.md +13 -0
  70. package/templates/skills/cbp-build-cc-memory/examples/user-memory.md +14 -0
  71. package/templates/skills/cbp-build-cc-memory/reference/memory-types.md +59 -0
  72. package/templates/skills/cbp-build-cc-memory/reference/when-to-save.md +62 -0
  73. package/templates/skills/cbp-build-cc-memory/templates/MEMORY-index.md +4 -0
  74. package/templates/skills/cbp-build-cc-memory/templates/memory-entry.md +15 -0
  75. package/templates/skills/cbp-build-cc-mode/SKILL.md +99 -0
  76. package/templates/skills/cbp-build-cc-rule/SKILL.md +176 -0
  77. package/templates/skills/cbp-build-cc-rule/examples/global-rule.md +19 -0
  78. package/templates/skills/cbp-build-cc-rule/examples/scoped-rule.md +41 -0
  79. package/templates/skills/cbp-build-cc-rule/reference/paths-patterns.md +48 -0
  80. package/templates/skills/cbp-build-cc-rule/templates/rule.md +32 -0
  81. package/templates/skills/cbp-build-cc-settings/SKILL.md +220 -0
  82. package/templates/skills/cbp-build-cc-settings/examples/hooks-config.json +64 -0
  83. package/templates/skills/cbp-build-cc-settings/examples/permissions-config.json +34 -0
  84. package/templates/skills/cbp-build-cc-settings/examples/sandbox-config.json +42 -0
  85. package/templates/skills/cbp-build-cc-settings/reference/cbp-conventions.md +104 -0
  86. package/templates/skills/cbp-build-cc-settings/reference/permission-rules.md +61 -0
  87. package/templates/skills/cbp-build-cc-settings/reference/scope-precedence.md +73 -0
  88. package/templates/skills/cbp-build-cc-settings/reference/settings-fields.md +166 -0
  89. package/templates/skills/cbp-build-cc-settings/templates/settings.json +23 -0
  90. package/templates/skills/cbp-build-cc-settings/templates/settings.local.json +10 -0
  91. package/templates/skills/cbp-build-cc-skill/SKILL.md +154 -0
  92. package/templates/skills/cbp-build-cc-skill/examples/dynamic-context.md +31 -0
  93. package/templates/skills/cbp-build-cc-skill/examples/fork-skill.md +22 -0
  94. package/templates/skills/cbp-build-cc-skill/examples/knowledge-skill.md +25 -0
  95. package/templates/skills/cbp-build-cc-skill/examples/task-skill.md +29 -0
  96. package/templates/skills/cbp-build-cc-skill/reference/cbp-quality.md +157 -0
  97. package/templates/skills/cbp-build-cc-skill/reference/frontmatter-fields.md +35 -0
  98. package/templates/skills/cbp-build-cc-skill/reference/string-substitutions.md +60 -0
  99. package/templates/skills/cbp-build-cc-skill/scripts/validate-skill.sh +90 -0
  100. package/templates/skills/cbp-build-cc-skill/templates/skill.md +51 -0
  101. package/templates/skills/cbp-checkpoint-check/SKILL.md +156 -0
  102. package/templates/skills/cbp-checkpoint-complete/SKILL.md +109 -0
  103. package/templates/skills/cbp-checkpoint-create/SKILL.md +287 -0
  104. package/templates/skills/cbp-checkpoint-end/SKILL.md +241 -0
  105. package/templates/skills/cbp-checkpoint-update/SKILL.md +115 -0
  106. package/templates/skills/cbp-frontend-a11y/SKILL.md +109 -0
  107. package/templates/skills/cbp-frontend-a11y/reference/aria-roles-states.md +130 -0
  108. package/templates/skills/cbp-frontend-a11y/reference/contrast-visual.md +122 -0
  109. package/templates/skills/cbp-frontend-a11y/reference/keyboard-patterns.md +154 -0
  110. package/templates/skills/cbp-frontend-a11y/reference/semantic-html.md +111 -0
  111. package/templates/skills/cbp-frontend-design/SKILL.md +145 -0
  112. package/templates/skills/cbp-frontend-design/reference/nextjs-scss.md +118 -0
  113. package/templates/skills/cbp-frontend-design/reference/rn-expo.md +101 -0
  114. package/templates/skills/cbp-frontend-design/reference/tauri-react.md +82 -0
  115. package/templates/skills/cbp-frontend-ui/SKILL.md +262 -0
  116. package/templates/skills/cbp-frontend-ui/reference/ui-label-maps.md +42 -0
  117. package/templates/skills/cbp-frontend-ui/reference/ui-layout-patterns.md +105 -0
  118. package/templates/skills/cbp-frontend-ui/reference/variant-defaults.md +149 -0
  119. package/templates/skills/cbp-frontend-ux/SKILL.md +181 -0
  120. package/templates/skills/cbp-git-branch-feat-create/SKILL.md +115 -0
  121. package/templates/skills/cbp-git-commit/SKILL.md +278 -0
  122. package/templates/skills/cbp-git-worktree-create/SKILL.md +226 -0
  123. package/templates/skills/cbp-git-worktree-remove/SKILL.md +145 -0
  124. package/templates/skills/cbp-merge-main/SKILL.md +228 -0
  125. package/templates/skills/cbp-round-check/SKILL.md +104 -0
  126. package/templates/skills/cbp-round-end/SKILL.md +183 -0
  127. package/templates/skills/cbp-round-end/reference/findings-presentation.md +44 -0
  128. package/templates/skills/cbp-round-end/reference/inline-fallback.md +35 -0
  129. package/templates/skills/cbp-round-execute/SKILL.md +211 -0
  130. package/templates/skills/cbp-round-execute/reference/inline-fallback.md +59 -0
  131. package/templates/skills/cbp-round-input/SKILL.md +165 -0
  132. package/templates/skills/cbp-round-start/SKILL.md +222 -0
  133. package/templates/skills/cbp-round-update/SKILL.md +163 -0
  134. package/templates/skills/cbp-session-end/SKILL.md +187 -0
  135. package/templates/skills/cbp-session-start/SKILL.md +155 -0
  136. package/templates/skills/cbp-ship/SKILL.md +332 -0
  137. package/templates/skills/cbp-ship/reference/changesets-overview.md +120 -0
  138. package/templates/skills/cbp-ship/reference/eas-cli-overview.md +60 -0
  139. package/templates/skills/cbp-ship/reference/gh-cli-overview.md +135 -0
  140. package/templates/skills/cbp-ship/reference/gh-cli-shipment-commands.md +283 -0
  141. package/templates/skills/cbp-ship/reference/npm-publish-monorepo.md +252 -0
  142. package/templates/skills/cbp-ship/reference/npm-publish-oidc-trusted.md +157 -0
  143. package/templates/skills/cbp-ship/reference/npm-publish-overview.md +171 -0
  144. package/templates/skills/cbp-ship/reference/preflight-checklist.md +88 -0
  145. package/templates/skills/cbp-ship/reference/railway-nestjs-deployment.md +169 -0
  146. package/templates/skills/cbp-ship/reference/railway-overview.md +120 -0
  147. package/templates/skills/cbp-ship/reference/railway-troubleshooting.md +168 -0
  148. package/templates/skills/cbp-ship/reference/release-please-overview.md +99 -0
  149. package/templates/skills/cbp-ship/reference/surface-expo-eas.md +155 -0
  150. package/templates/skills/cbp-ship/reference/surface-npm.md +180 -0
  151. package/templates/skills/cbp-ship/reference/surface-railway.md +152 -0
  152. package/templates/skills/cbp-ship/reference/surface-supabase.md +178 -0
  153. package/templates/skills/cbp-ship/reference/surface-tauri.md +138 -0
  154. package/templates/skills/cbp-ship/reference/surface-vercel.md +124 -0
  155. package/templates/skills/cbp-ship/reference/surface-vscode-ext.md +144 -0
  156. package/templates/skills/cbp-ship/reference/surfaces.md +60 -0
  157. package/templates/skills/cbp-ship/reference/testflight-automation.md +215 -0
  158. package/templates/skills/cbp-ship/reference/testflight-internal-vs-external.md +69 -0
  159. package/templates/skills/cbp-ship/reference/testflight-overview.md +98 -0
  160. package/templates/skills/cbp-ship/reference/versioning.md +116 -0
  161. package/templates/skills/cbp-ship/scripts/detect-surfaces.sh +217 -0
  162. package/templates/skills/cbp-ship/scripts/verify-expo-eas.sh +35 -0
  163. package/templates/skills/cbp-ship/scripts/verify-npm.sh +21 -0
  164. package/templates/skills/cbp-ship/scripts/verify-railway.sh +41 -0
  165. package/templates/skills/cbp-ship/scripts/verify-supabase.sh +19 -0
  166. package/templates/skills/cbp-ship/scripts/verify-tauri.sh +24 -0
  167. package/templates/skills/cbp-ship/scripts/verify-vercel.sh +32 -0
  168. package/templates/skills/cbp-ship/scripts/verify-vscode-ext.sh +25 -0
  169. package/templates/skills/cbp-ship/templates/eas.json +66 -0
  170. package/templates/skills/cbp-ship/templates/railway.toml +15 -0
  171. package/templates/skills/cbp-ship/templates/release-please-config.json +17 -0
  172. package/templates/skills/cbp-ship/templates/vercel.json +19 -0
  173. package/templates/skills/cbp-ship/templates/vscodeignore +21 -0
  174. package/templates/skills/cbp-ship/templates/workflow-changesets.yml +41 -0
  175. package/templates/skills/cbp-ship/templates/workflow-eas-submit.yml +53 -0
  176. package/templates/skills/cbp-ship/templates/workflow-npm-publish.yml +36 -0
  177. package/templates/skills/cbp-ship/templates/workflow-release-please.yml +21 -0
  178. package/templates/skills/cbp-ship/templates/workflow-tauri-release.yml +69 -0
  179. package/templates/skills/cbp-ship/templates/workflow-vsce-publish.yml +31 -0
  180. package/templates/skills/cbp-ship-configure/SKILL.md +296 -0
  181. package/templates/skills/cbp-ship-configure/reference/expo-mobile.md +204 -0
  182. package/templates/skills/cbp-ship-configure/reference/npm-package.md +165 -0
  183. package/templates/skills/cbp-ship-configure/reference/railway-backend.md +199 -0
  184. package/templates/skills/cbp-ship-configure/reference/supabase.md +200 -0
  185. package/templates/skills/cbp-ship-configure/reference/tauri-desktop.md +181 -0
  186. package/templates/skills/cbp-ship-configure/reference/vercel.md +117 -0
  187. package/templates/skills/cbp-ship-configure/reference/vscode-ext.md +155 -0
  188. package/templates/skills/cbp-ship-main/SKILL.md +65 -0
  189. package/templates/skills/cbp-supabase-branch-check/SKILL.md +337 -0
  190. package/templates/skills/cbp-supabase-branch-check/reference/dag-steps.md +29 -0
  191. package/templates/skills/cbp-supabase-migrate/SKILL.md +314 -0
  192. package/templates/skills/cbp-supabase-migrate/reference/advisor-triage.md +70 -0
  193. package/templates/skills/cbp-supabase-migrate/reference/cli-fallback.md +87 -0
  194. package/templates/skills/cbp-supabase-migrate/reference/preflight-dry-run.md +58 -0
  195. package/templates/skills/cbp-supabase-setup/SKILL.md +239 -0
  196. package/templates/skills/cbp-supabase-setup/reference/branching-setup.md +121 -0
  197. package/templates/skills/cbp-supabase-setup/reference/cli-fallback.md +109 -0
  198. package/templates/skills/cbp-task-check/SKILL.md +166 -0
  199. package/templates/skills/cbp-task-complete/SKILL.md +206 -0
  200. package/templates/skills/cbp-task-complete/reference/checkpoint-done-branching.md +48 -0
  201. package/templates/skills/cbp-task-complete/reference/next-step-heuristic.md +56 -0
  202. package/templates/skills/cbp-task-create/SKILL.md +167 -0
  203. package/templates/skills/cbp-task-start/SKILL.md +239 -0
  204. package/templates/skills/cbp-task-testing/SKILL.md +277 -0
  205. package/templates/skills/cbp-todo/SKILL.md +97 -0
@@ -0,0 +1,109 @@
1
+ ---
2
+ scope: org-shared
3
+ paths:
4
+ - "apps/todo-worker/**"
5
+ - "apps/web/src/lib/mcp/**"
6
+ - "supabase/migrations/*todos*"
7
+ - "supabase/migrations/*worktrees*"
8
+ ---
9
+
10
+ # Todo backend — queue contract, invariants, and writer obligations
11
+
12
+ The todos queue is materialised by `apps/todo-worker` (CHK-122) and consumed by `/cbp-todo` + `mcp__codebyplan__get_next_action`. This rule documents what every contributor to the MCP write tools, the worker, or the SQL schema must respect.
13
+
14
+ ## 1. Six workflow invariants — DB-layer guards, never bypassable
15
+
16
+ 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.
17
+
18
+ | # | Trigger | What it enforces |
19
+ |---|---------|------------------|
20
+ | 1 | `trg_enforce_checkpoint_activation_worktree` | A checkpoint cannot be activated without `worktree_id` set |
21
+ | 2 | `enforce_standalone_task_worktree` (via task workflow) | A standalone task cannot be moved to `in_progress` without `assigned_worktree_id` |
22
+ | 3 | `trg_enforce_task_workflow_invariants` | ≤ 1 `in_progress` task per checkpoint |
23
+ | 4 | `trg_enforce_single_in_progress_round_per_task` | ≤ 1 `in_progress` round per task |
24
+ | 5 | `trg_enforce_single_active_scope_per_worktree` | ≤ 1 active (checkpoint OR standalone task) per worktree |
25
+ | 6 | `trg_enforce_standalone_task_scope_per_worktree` | ≤ 1 `in_progress` standalone task per worktree |
26
+
27
+ The worker is a passive cross-checker (`apps/todo-worker/src/invariants/check.ts`) — if its check disagrees with the DB, the DB wins.
28
+
29
+ ## 2. Queue contract — todos_jobs lifecycle
30
+
31
+ `todos_jobs` is the work queue drained by the worker.
32
+
33
+ ```
34
+ MCP write → enqueueTodoJob → todos_jobs (status='pending')
35
+
36
+ worker claim_todos_job (SELECT … FOR UPDATE SKIP LOCKED)
37
+
38
+ computeTodos(repo, worktree, user) → desired rows
39
+
40
+ apply_todos RPC → todos table (status='current' / 'pending')
41
+
42
+ todos_jobs.status='completed'
43
+ ```
44
+
45
+ `status` enum: `pending → in_progress → completed | failed`. `failed` rows retry up to 3 attempts via the heartbeat cron.
46
+
47
+ ## 3. Priority sort_order bands
48
+
49
+ The worker emits todos with these `sort_order` ranges. Lower = surfaces first in `get_next_action`.
50
+
51
+ | Band | sort_order | State |
52
+ |------|-----------|-------|
53
+ | Active round | 10–19 | Checkpoint active, task in_progress, round in_progress |
54
+ | Active task pending round | 20–29 | Checkpoint active, task in_progress, no round yet |
55
+ | Pending task in active checkpoint | 30–39 | Checkpoint active, lowest-numbered pending task |
56
+ | Pending checkpoint | 40–49 | No active checkpoint, lowest-numbered pending |
57
+ | Standalone task | 60–69 | No checkpoint context, in_progress / pending standalone |
58
+ | Repo-sync prompt | 90–99 | `repos.needs_refresh = true` |
59
+
60
+ ## 4. Command + args mapping
61
+
62
+ `get_next_action` returns one row mapping to one of these slash commands. The worker stamps `command` + `metadata.context` based on workflow state:
63
+
64
+ | State | Command | Required context |
65
+ |-------|---------|------------------|
66
+ | Round in progress | `/cbp-round-update` | `{checkpoint_id, task_id, round_id}` |
67
+ | Round pending start | `/cbp-round-start` | `{checkpoint_id, task_id}` |
68
+ | Task pending start | `/cbp-task-start` | `{checkpoint_id, task_id}` or `{task_id}` for standalone |
69
+ | Checkpoint pending activation | `/cbp-checkpoint-update` | `{checkpoint_id}` |
70
+ | Checkpoint done | `/cbp-checkpoint-check` | `{checkpoint_id}` |
71
+ | Repo needs sync | `npx codebyplan tech-stack` | `{repo_id}` |
72
+
73
+ ## 5. Heartbeat policy
74
+
75
+ 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 `enqueueTodoJob` calls in MCP writers.
76
+
77
+ 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.
78
+
79
+ ## 6. Writer obligations — every MCP write enqueues
80
+
81
+ `apps/web/src/lib/mcp/enqueueTodoJob.ts` exposes:
82
+
83
+ ```ts
84
+ enqueueTodoJob(client, { repoId, worktreeId, userId, reason }): Promise<void>
85
+ ```
86
+
87
+ Every workflow mutator in `apps/web/src/lib/mcp/tools/write.ts` MUST call this after the mutation succeeds. The 11 writers as of CHK-122:
88
+
89
+ `create_checkpoint, update_checkpoint, complete_checkpoint, create_task, update_task, complete_task, add_round, update_round, complete_round, create_session_log, update_session_log`
90
+
91
+ Plus the 2 dedicated enqueue tools: `enqueue_todo_job`, `bind_worktree_user`.
92
+
93
+ **Contract**: best-effort. The helper logs and swallows failures — the heartbeat catches anything that slips through. Atomic in-txn enqueue is NOT supported (supabase-js limitation); the worker's bounded staleness (next heartbeat ≤ 24h) is the safety net.
94
+
95
+ ## 7. Cutover history
96
+
97
+ 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.
98
+
99
+ ## 8. Deployment — Railway
100
+
101
+ `apps/todo-worker` runs as a Railway service alongside `apps/backend`. Setup:
102
+
103
+ 1. Dashboard → New service → Connect GitHub → pick this repo.
104
+ 2. Build command: `pnpm install && pnpm --filter @codebyplan/todo-worker build`
105
+ 3. Start command: `node apps/todo-worker/dist/main.js`
106
+ 4. Env vars (from `apps/todo-worker/.env.example`): `SUPABASE_URL`, `SUPABASE_SECRET_KEY` (an `sb_secret_...` key), `LOG_LEVEL`, `WORKER_POLL_MS`.
107
+ 5. Save the resulting `project_ref` to `.codebyplan.json` `shipment.surfaces.railway-todo-worker.project_ref`.
108
+
109
+ Smoke after deploy: run `/cbp-task-complete` in any worktree → tail Railway logs → expect a `claim → apply` cycle within `WORKER_POLL_MS`.
@@ -0,0 +1,55 @@
1
+ {
2
+ "alwaysThinkingEnabled": true,
3
+ "autoUpdatesChannel": "latest",
4
+ "awaySummaryEnabled": true,
5
+ "disableAgentView": false,
6
+ "disableRemoteControl": false,
7
+ "editorMode": "normal",
8
+ "outputStyle": "default",
9
+ "preferredNotifChannel": "notifications_disabled",
10
+ "prefersReducedMotion": false,
11
+ "respectGitignore": true,
12
+ "showTurnDuration": true,
13
+ "spinnerTipsEnabled": true,
14
+ "terminalProgressBarEnabled": true,
15
+ "viewMode": "default",
16
+ "worktree": { "baseRef": "fresh" },
17
+ "autoScrollEnabled": true,
18
+ "cleanupPeriodDays": 30,
19
+ "includeGitInstructions": true,
20
+ "showThinkingSummaries": true,
21
+ "disableSkillShellExecution": false,
22
+ "skipWebFetchPreflight": false,
23
+ "fastModePerSessionOptIn": false,
24
+ "effortLevel": "xhigh",
25
+ "statusLine": {
26
+ "type": "command",
27
+ "command": "bash ./.claude/hooks/cbp-statusline.sh"
28
+ },
29
+ "subagentStatusLine": {
30
+ "type": "command",
31
+ "command": "bash ./.claude/hooks/cbp-subagent-statusline.sh"
32
+ },
33
+ "permissions": {
34
+ "defaultMode": "bypassPermissions",
35
+ "deny": ["Bash(rm -rf /:*)", "Bash(rm -rf ~:*)", "Bash(rm -rf /*:*)"],
36
+ "ask": [
37
+ "Bash(git reset:*)",
38
+ "Bash(git clean:*)",
39
+ "Bash(git push --force:*)",
40
+ "Bash(git push -f:*)",
41
+ "Bash(git checkout -- :*)",
42
+ "Bash(git add .:*)",
43
+ "Bash(git add -A:*)",
44
+ "Bash(rm -rf:*)",
45
+ "Bash(pnpm add:*)",
46
+ "Bash(pnpm install:*)",
47
+ "Bash(npm install:*)",
48
+ "Bash(npm i:*)",
49
+ "Bash(npx add:*)"
50
+ ]
51
+ },
52
+ "attribution": { "commit": "", "pr": "" },
53
+ "showClearContextOnPlanAccept": false,
54
+ "syntaxHighlightingDisabled": false
55
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "alwaysThinkingEnabled": true,
3
+ "autoUpdatesChannel": "latest",
4
+ "awaySummaryEnabled": true,
5
+ "disableAgentView": false,
6
+ "disableRemoteControl": false,
7
+ "editorMode": "normal",
8
+ "outputStyle": "default",
9
+ "preferredNotifChannel": "notifications_disabled",
10
+ "prefersReducedMotion": false,
11
+ "respectGitignore": true,
12
+ "showTurnDuration": true,
13
+ "spinnerTipsEnabled": true,
14
+ "terminalProgressBarEnabled": true,
15
+ "viewMode": "default",
16
+ "worktree": { "baseRef": "fresh" },
17
+ "autoScrollEnabled": true,
18
+ "cleanupPeriodDays": 30,
19
+ "includeGitInstructions": true,
20
+ "showThinkingSummaries": true,
21
+ "disableSkillShellExecution": false,
22
+ "skipWebFetchPreflight": false,
23
+ "fastModePerSessionOptIn": false,
24
+ "permissions": { "skipDangerousModePermissionPrompt": true }
25
+ }
@@ -0,0 +1,139 @@
1
+ ---
2
+ scope: org-shared
3
+ name: cbp-build-cc-agent
4
+ description: Build a Claude Code subagent at .claude/agents/{name}/AGENT.md (CBP folder form) following the official sub-agents spec (frontmatter, tools, model, memory, hooks, skills preload, permission modes, isolation).
5
+ argument-hint: "[agent-name] [--scope=project|user] [--memory=project|user|local] [--isolation=worktree]"
6
+ allowed-tools: Read, Write, Edit, Glob, Grep, Bash(mkdir *), Bash(chmod *)
7
+ effort: xhigh
8
+ ---
9
+
10
+ # Build Claude Code Subagent
11
+
12
+ Create a Claude Code subagent following the official Claude Code sub-agents spec. Supports every frontmatter field the runtime recognises.
13
+
14
+ **CBP authoring quality** (Work-Executor vs Utility split, I/O contracts, signal density, anti-patterns, failure modes): read [reference/cbp-quality.md](reference/cbp-quality.md) before writing.
15
+
16
+ ## Arguments
17
+
18
+ `$ARGUMENTS` — agent name (kebab-case, required). Flags: `--scope=project|user` (default `project`), `--memory=project|user|local`, `--isolation=worktree`.
19
+
20
+ ## When to Use
21
+
22
+ - Recurring task that matches an existing worker pattern
23
+ - Work produces verbose output you want kept out of the main conversation
24
+ - Task has a tight tool-access or permission boundary
25
+ - Seen the same side-task pattern 3+ times
26
+
27
+ Do **not** create a subagent for one-off work — spawn `general-purpose` inline instead.
28
+
29
+ ## Instructions
30
+
31
+ ### Step 1 — Validate inputs
32
+
33
+ - Name must be lowercase kebab-case (a–z, 0–9, hyphens only)
34
+ - Reject collisions with built-in agents: `Explore`, `Plan`, `general-purpose`, `statusline-setup`, `Claude Code Guide`
35
+ - Reject if `.claude/agents/{name}/AGENT.md` already exists unless the user asked to update
36
+
37
+ ### Step 2 — Pick scope
38
+
39
+ CBP uses the **folder form** so an agent can bundle supporting docs/scripts next to `AGENT.md`.
40
+
41
+ | Scope | Path | Use when |
42
+ | ------- | ---------------------------------- | --------------------------------------- |
43
+ | project | `.claude/agents/{name}/AGENT.md` | Repo-specific, shared with team via git |
44
+ | user | `~/.claude/agents/{name}/AGENT.md` | Personal, reused across all projects |
45
+
46
+ Default: `project`. Pass `--scope=user` to override. Flat form (`.claude/agents/{name}.md`) is the Claude Code native layout but CBP's structure hook expects the folder form — always use that in this repo.
47
+
48
+ ### Step 3 — Read the template and CBP context
49
+
50
+ Read `${CLAUDE_SKILL_DIR}/templates/agent.md` for the canonical frontmatter set. Fill only fields that matter for the agent; leave the rest out (every field except `name` and `description` is optional).
51
+
52
+ CBP adds a required `scope:` frontmatter marker (structural classification; not read by Claude Code). Values: `org-shared` | `project-shared` | `repo-only:<repo-name>`. Length hook warns at 400 lines, blocks at 800. Quality details in [reference/cbp-quality.md](reference/cbp-quality.md).
53
+
54
+ ### Step 4 — Gather required fields
55
+
56
+ Ask the user only for what cannot be inferred from context:
57
+
58
+ | Field | Source |
59
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
60
+ | `name` | Argument |
61
+ | `description` | User — must describe _when_ Claude should delegate, not what the agent is |
62
+ | `tools` / `disallowedTools` | Derive from the workflow. Prefer narrow allowlists for read-only agents |
63
+ | `model` | Pinned ID (e.g. `sonnet`) for version-locked reasoning, or alias (`sonnet` / `opus` / `haiku`) for explicit lowering exceptions. `inherit` is NOT permitted in plugin authoring — every agent states its model explicitly. Default for plugin agents is `sonnet`; see [/cbp-build-cc-mode](../build-cc-mode/SKILL.md) for the matrix |
64
+ | `effort` | `xhigh` by default for plugin agents; lower (`high` / `medium` / `low`) only as a documented exception in the build-cc-mode matrix. Always set explicitly — no commented-out placeholders |
65
+ | `permissionMode` | `default` unless the agent must run autonomously |
66
+
67
+ ### Step 5 — Consider optional capabilities
68
+
69
+ Check each against the task and include only when they add value:
70
+
71
+ | Capability | Field | When to include |
72
+ | -------------------- | --------------------------------------------------------------- | ------------------------------------------------------ |
73
+ | Persistent memory | `memory: project\|user\|local` | Agent should accumulate learnings across conversations |
74
+ | Preloaded skills | `skills: [skill-a, skill-b]` | Domain knowledge the agent needs every run |
75
+ | Scoped MCP servers | `mcpServers: [...]` | Tools the parent session shouldn't have in context |
76
+ | Lifecycle hooks | `hooks: { PreToolUse: [...], PostToolUse: [...], Stop: [...] }` | Need to validate tool calls or trigger side-effects |
77
+ | Worktree isolation | `isolation: worktree` | Agent should mutate an isolated copy of the repo |
78
+ | Background execution | `background: true` | Agent should always run concurrently |
79
+ | Bounded turns | `maxTurns: N` | Cap runaway loops |
80
+ | Subagent spawning | `tools: Agent(worker, researcher)` | Only if run as main thread via `--agent` |
81
+
82
+ Cross-references for complex cases:
83
+
84
+ - Frontmatter table: [reference/frontmatter-fields.md](reference/frontmatter-fields.md)
85
+ - Permission modes: [reference/permission-modes.md](reference/permission-modes.md)
86
+ - Hook patterns: [examples/with-hooks.md](examples/with-hooks.md)
87
+ - Preloaded skills pattern: [examples/with-skills-preload.md](examples/with-skills-preload.md)
88
+ - Read-only agent pattern: [examples/read-only-reviewer.md](examples/read-only-reviewer.md)
89
+
90
+ ### Step 6 — Write the agent file
91
+
92
+ 1. Create directory: `mkdir -p {scope-path}/{name}`
93
+ 2. Write `{scope-path}/{name}/AGENT.md`
94
+ 3. Copy the template, fill frontmatter, then write the system prompt as the markdown body. The body becomes the agent's entire system prompt — no CLAUDE.md prefix, no Claude Code defaults.
95
+
96
+ System prompt guidance:
97
+
98
+ - Open with a one-line role ("You are a ...")
99
+ - Numbered workflow the agent follows when invoked
100
+ - Output format it must return
101
+ - Failure modes (when to return `blocked`, `failed`, `no_findings`)
102
+
103
+ Supporting files (optional) live next to `AGENT.md` in the same folder: `{name}/context.md`, `{name}/examples/`, etc.
104
+
105
+ ### Step 7 — Validate
106
+
107
+ Run the validator:
108
+
109
+ ```bash
110
+ bash "${CLAUDE_SKILL_DIR}/scripts/validate-agent.sh" "{scope-path}/{name}/AGENT.md"
111
+ ```
112
+
113
+ It checks: name format, frontmatter parses, required fields present (`name`, `description`, `scope`), tool names are valid, model alias is recognised.
114
+
115
+ ### Step 8 — Surface to the user
116
+
117
+ Report:
118
+
119
+ - Path written
120
+ - Frontmatter fields used (and which optional ones were skipped and why)
121
+ - How to invoke: `@agent-{name}`, natural language, or `claude --agent {name}`
122
+ - Note that manual edits require `/agents` reload or a session restart (per spec)
123
+ - Commit the new agent file to git so it propagates to other team members
124
+
125
+ ## Integration
126
+
127
+ - **Triggered by**: user invocation
128
+ - **Reads**: `${CLAUDE_SKILL_DIR}/templates/agent.md`, `${CLAUDE_SKILL_DIR}/reference/*.md` (including `cbp-quality.md`)
129
+ - **Writes**: `.claude/agents/{name}/AGENT.md` or `~/.claude/agents/{name}/AGENT.md`
130
+ - **Related skills**: `/cbp-build-cc-skill` (skill-level workflows), `/cbp-build-cc-settings` (session-level `SubagentStart`/`SubagentStop` hooks), `/cbp-build-cc-mode` (canonical model/effort matrix — audit or apply)
131
+
132
+ ## Key Rules
133
+
134
+ - `description` is what Claude reads to decide whether to delegate. Write it for matching, not for humans
135
+ - Subagents cannot spawn other subagents — the `Agent` tool only applies when the agent runs as the main thread
136
+ - `bypassPermissions` and `acceptEdits` inherited from the parent cannot be weakened by the child
137
+ - Preloaded skills inject _full content_ at startup — don't preload `disable-model-invocation: true` skills
138
+ - Restart the session or use `/agents` to load a newly written agent file
139
+ - CBP folder form is required — the structure hook blocks flat agent files in this repo
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: code-reviewer
3
+ description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.
4
+ tools: Read, Grep, Glob, Bash
5
+ model: sonnet
6
+ effort: xhigh
7
+ color: blue
8
+ ---
9
+
10
+ You are a senior code reviewer ensuring high standards of code quality and security.
11
+
12
+ When invoked:
13
+ 1. Run `git diff` to see recent changes
14
+ 2. Focus on modified files
15
+ 3. Begin review immediately
16
+
17
+ Review checklist:
18
+ - Code is clear and readable
19
+ - Functions and variables are well-named
20
+ - No duplicated code
21
+ - Proper error handling
22
+ - No exposed secrets or API keys
23
+ - Input validation implemented
24
+ - Good test coverage
25
+ - Performance considerations addressed
26
+
27
+ Provide feedback organized by priority:
28
+ - Critical issues (must fix)
29
+ - Warnings (should fix)
30
+ - Suggestions (consider improving)
31
+
32
+ Include specific examples of how to fix issues.
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: db-reader
3
+ description: Execute read-only database queries. Use when analyzing data or generating reports.
4
+ tools: Bash
5
+ model: sonnet
6
+ effort: xhigh
7
+ hooks:
8
+ PreToolUse:
9
+ - matcher: "Bash"
10
+ hooks:
11
+ - type: command
12
+ command: "./scripts/validate-readonly-query.sh"
13
+ ---
14
+
15
+ You are a database analyst with read-only access. Execute SELECT queries to answer questions about the data.
16
+
17
+ When asked to analyze data:
18
+ 1. Identify which tables contain the relevant data
19
+ 2. Write efficient SELECT queries with appropriate filters
20
+ 3. Present results clearly with context
21
+
22
+ You cannot modify data. If asked to INSERT, UPDATE, DELETE, or modify schema, explain that you only have read access.
23
+
24
+ ---
25
+
26
+ **Companion script — `./scripts/validate-readonly-query.sh`:**
27
+
28
+ ```bash
29
+ #!/bin/bash
30
+ # Exit 2 blocks the tool call and feeds stderr back to Claude.
31
+ INPUT=$(cat)
32
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
33
+ [ -z "$COMMAND" ] && exit 0
34
+ if echo "$COMMAND" | grep -iE '\b(INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|TRUNCATE|REPLACE|MERGE)\b' > /dev/null; then
35
+ echo "Blocked: Write operations not allowed. Use SELECT queries only." >&2
36
+ exit 2
37
+ fi
38
+ exit 0
39
+ ```
40
+
41
+ Make it executable: `chmod +x ./scripts/validate-readonly-query.sh`
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: api-developer
3
+ description: Implement API endpoints following team conventions. Use when adding, modifying, or reviewing HTTP handlers.
4
+ tools: Read, Write, Edit, Grep, Glob, Bash
5
+ model: sonnet
6
+ effort: xhigh
7
+ memory: project
8
+ skills:
9
+ - api-conventions
10
+ - error-handling-patterns
11
+ ---
12
+
13
+ You are an API developer. Follow the conventions and patterns preloaded via the `skills` field — they define the project's RESTful naming, error format, and validation rules.
14
+
15
+ When invoked:
16
+ 1. Read `MEMORY.md` to recall past learnings on this codebase
17
+ 2. Locate the handler directory (`src/api/handlers/`)
18
+ 3. Implement the endpoint per the preloaded conventions
19
+ 4. Write or update tests in the matching `*.test.ts` file
20
+ 5. Append one-line learnings to `MEMORY.md` when you discover a pattern worth remembering
21
+
22
+ Return:
23
+ - Files created/modified
24
+ - Test coverage summary
25
+ - Any deviation from conventions and why
@@ -0,0 +1,153 @@
1
+ ---
2
+ scope: org-shared
3
+ ---
4
+
5
+ # Agent Authoring Quality
6
+
7
+ Quality expectations and structure for `/.claude/agents/{name}/AGENT.md` files. This file adds CBP-specific constraints on top of the official Claude Code sub-agents spec.
8
+
9
+ ## CBP Folder Form
10
+
11
+ CBP uses the folder form `.claude/agents/{name}/AGENT.md`, not Claude Code's native flat `.claude/agents/{name}.md`. The structure hook enforces this. Folder form lets an agent bundle supporting files (context, examples, scripts) next to `AGENT.md`.
12
+
13
+ ## Required CBP Frontmatter
14
+
15
+ Every agent MUST have `scope:` in addition to the Claude Code native fields:
16
+
17
+ ```yaml
18
+ ---
19
+ scope: org-shared # structural marker: org-shared | project-shared | repo-only:<repo-name>
20
+ name: agent-name
21
+ description: One sentence — used for matching. Be specific.
22
+ tools: Read, Write, Edit, Glob, Grep, Bash
23
+ effort: high
24
+ ---
25
+ ```
26
+
27
+ `scope:` is a CBP structural marker — not read by Claude Code itself. Missing `scope:` fails validation (`validate-agent.sh` / `validate-structure-scope.sh`).
28
+
29
+ ## Agent Types
30
+
31
+ | Type | Phases | Thinking Sections | Self-Improvement | Max Lines |
32
+ | ----------------- | ----------------------- | ----------------------- | ---------------------- | --------- |
33
+ | **Work Executor** | Freeform work | Yes (mandatory) | Yes (mandatory) | 400 |
34
+ | **Utility** | Defined phases/workflow | No (embedded in phases) | No (returns to caller) | 400 |
35
+
36
+ Work Executors do arbitrary work — they need structured thinking to avoid errors.
37
+ Utility agents have defined phases — thinking is embedded in their workflow.
38
+
39
+ ## Required Sections
40
+
41
+ Every agent MUST have these sections:
42
+
43
+ | Section | Purpose | Skip When |
44
+ | ------------------------ | ------------------------------------------- | -------------- |
45
+ | **Frontmatter** | name, description, tools, effort | Never |
46
+ | **Purpose** | Why this agent exists, what it replaces | Never |
47
+ | **Input Contract** | YAML schema of what the agent receives | Never |
48
+ | **Output Contract** | YAML schema of what the agent returns | Never |
49
+ | **Workflow** | Numbered phases with clear steps | Never |
50
+ | **Completion Criteria** | When the agent is done | Never |
51
+ | **Failure Modes** | What to do when blocked/failed | Never |
52
+ | **Integration** | Spawned by, returns to, input from | Never |
53
+ | Thinking Requirements | Problem understanding, source check, design | Utility agents |
54
+ | Self-Improvement Capture | Rules/architecture/command gaps found | Utility agents |
55
+
56
+ ## Frontmatter
57
+
58
+ ```yaml
59
+ ---
60
+ name: agent-name
61
+ description: One sentence — used for agent matching. Be specific.
62
+ tools: Read, Write, Edit, Glob, Grep, Bash
63
+ effort: high
64
+ ---
65
+ ```
66
+
67
+ - `tools:` — only list tools the agent actually needs. Don't give Write/Edit to read-only agents.
68
+ - `effort:` — `high` for agents that do complex multi-step work
69
+
70
+ ## Quality Expectations
71
+
72
+ ### Signal Density
73
+
74
+ Every line must drive behavior. Test each line: "If I remove this, will the agent make a mistake?" If no, cut it.
75
+
76
+ | Bad | Good |
77
+ | ----------------------------------- | -------------------------------------- |
78
+ | "Make sure to carefully analyze..." | (just write the analysis steps) |
79
+ | "IMPORTANT: Always check..." | (put it in the workflow as a step) |
80
+ | "Note: This is critical..." | (make it a phase gate or failure mode) |
81
+
82
+ ### Concrete Steps Over Vague Guidance
83
+
84
+ | Bad | Good |
85
+ | ---------------------------------- | ------------------------------------------------------------------------- |
86
+ | "Analyze the codebase thoroughly" | "Glob `src/**/*.ts`, read files matching the pattern" |
87
+ | "Fix any issues found" | "For each lint error: read the file, apply the fix, add to fixes_applied" |
88
+ | "When uncertain, apply fix anyway" | "When uncertain about create vs update, update the existing file" |
89
+
90
+ ### Input/Output Contracts Must Be Precise
91
+
92
+ Contracts define how agents communicate. Vague contracts produce vague work.
93
+
94
+ ```yaml
95
+ # Bad — what does "context" mean?
96
+ input:
97
+ context: object
98
+
99
+ # Good — every field named and typed
100
+ input:
101
+ checkpoint_goal: string
102
+ round_requirements: string
103
+ has_ui_work: boolean
104
+ ```
105
+
106
+ ### Merge-First for Infrastructure Changes
107
+
108
+ Agents that modify `.claude/` files MUST:
109
+
110
+ 1. Inventory existing files in the target category before creating new ones
111
+ 2. Update existing files when topic overlap > 50%
112
+ 3. Document `checked_existing` in output when creating new files
113
+
114
+ ## Anti-Patterns
115
+
116
+ | Pattern | Problem | Fix |
117
+ | ----------------------------------------------------- | ------------------------------------- | ---------------------------------------------------- |
118
+ | Emphasis markers as fixes ("IMPORTANT:", "REQUIRED:") | Structural problem masked by shouting | Inline the content or split the agent |
119
+ | "Full autonomy to create anything" | Creates file sprawl | Constrain to update-first, create-with-justification |
120
+ | Recursive self-spawning > 3 levels | Infinite loops, context exhaustion | Hard cap with fallback to caller |
121
+ | Agent has 10+ phases | Too many responsibilities | Split into orchestrator + specialists |
122
+ | Duplicate logic across agents | Drift, inconsistency | Extract to context file, both agents read it |
123
+
124
+ ## When to Create vs Update an Agent
125
+
126
+ | Situation | Action |
127
+ | ---------------------------------------- | ----------------------------------------------- |
128
+ | Existing agent covers the domain | Update its AGENT.md |
129
+ | New domain, no existing agent covers it | Create new agent |
130
+ | Existing agent is too large (>400 lines) | Split into orchestrator + specialist |
131
+ | One-off task, not recurring | Don't create an agent — use inline instructions |
132
+
133
+ ## Integration Section Format
134
+
135
+ ```markdown
136
+ ## Integration
137
+
138
+ - **Spawned by**: [skill or command that spawns this agent]
139
+ - **Returns to**: [what processes the output]
140
+ - **Input from**: [where data comes from]
141
+ - **Saves to**: [where results are stored]
142
+ ```
143
+
144
+ ## Failure Mode Defaults
145
+
146
+ Every agent should handle at minimum:
147
+
148
+ | Condition | Action |
149
+ | -------------------- | ----------------------------------------- |
150
+ | Requirements unclear | Return `blocked`, describe what's missing |
151
+ | Dependency missing | Return `blocked`, note what's needed |
152
+ | Unrecoverable error | Return `failed`, describe error |
153
+ | No actionable work | Return `skipped` or `no_findings` |
@@ -0,0 +1,37 @@
1
+ # Subagent Frontmatter Reference
2
+
3
+ Source: official Claude Code sub-agents spec. Only `name` and `description` are required.
4
+
5
+ | Field | Type | Purpose |
6
+ |-------|------|---------|
7
+ | `name` | string | Unique identifier, kebab-case |
8
+ | `description` | string | When to delegate. Claude matches against this |
9
+ | `tools` | list | Allowlist of tools (inherits all if omitted) |
10
+ | `disallowedTools` | list | Denylist, applied first, then `tools` filters the remainder |
11
+ | `model` | string | `sonnet` \| `opus` \| `haiku` \| full ID (e.g. `sonnet`) \| `inherit`. **Plugin agents authored in CBP MUST set this explicitly** — `inherit` is not permitted; see [/cbp-build-cc-mode](../../build-cc-mode/SKILL.md) for the canonical model/effort matrix |
12
+ | `permissionMode` | string | `default` \| `acceptEdits` \| `auto` \| `dontAsk` \| `bypassPermissions` \| `plan` |
13
+ | `maxTurns` | number | Cap on agentic turns before the agent must stop |
14
+ | `skills` | list | Skills to preload — full content injected at startup |
15
+ | `mcpServers` | list | String references (shared) or inline defs (scoped to this agent) |
16
+ | `hooks` | object | Lifecycle hooks — `PreToolUse`, `PostToolUse`, `Stop` (→ `SubagentStop`) |
17
+ | `memory` | string | `user` \| `project` \| `local` — persistent MEMORY.md directory |
18
+ | `background` | boolean | Always run concurrent to the main thread |
19
+ | `effort` | string | `low` \| `medium` \| `high` \| `xhigh` \| `max`. **Plugin agents authored in CBP MUST set this explicitly** (no commented-out placeholder); see [/cbp-build-cc-mode](../../build-cc-mode/SKILL.md) for the matrix |
20
+ | `isolation` | string | `worktree` — gives the agent a temporary git worktree |
21
+ | `color` | string | `red` \| `blue` \| `green` \| `yellow` \| `purple` \| `orange` \| `pink` \| `cyan` |
22
+ | `initialPrompt` | string | Auto-submitted first user turn when the agent is the main session agent |
23
+
24
+ ## Tool-allowlist special forms
25
+
26
+ | Form | Effect |
27
+ |------|--------|
28
+ | `Agent` | Agent may spawn any subagent (main-thread only) |
29
+ | `Agent(worker, researcher)` | Only these subagent types may be spawned |
30
+ | (omit `Agent`) | Cannot spawn subagents |
31
+
32
+ ## Resolution order for `model`
33
+
34
+ 1. `CLAUDE_CODE_SUBAGENT_MODEL` env var
35
+ 2. Per-invocation `model` parameter passed by Claude
36
+ 3. The `model` field in this file
37
+ 4. Main conversation's model
@@ -0,0 +1,18 @@
1
+ # Permission Modes Reference
2
+
3
+ Source: official Claude Code sub-agents and permission-modes specs.
4
+
5
+ | Mode | Behaviour |
6
+ |------|-----------|
7
+ | `default` | Standard permission prompts |
8
+ | `acceptEdits` | Auto-accept edits and common filesystem commands in working dir |
9
+ | `auto` | Background classifier reviews commands and protected-dir writes |
10
+ | `dontAsk` | Auto-deny prompts; only explicit allows pass |
11
+ | `bypassPermissions` | Skip prompts entirely (writes to `.git`, `.claude`, etc. still prompt) |
12
+ | `plan` | Read-only exploration mode |
13
+
14
+ ## Inheritance rules
15
+
16
+ - If parent is `bypassPermissions` or `acceptEdits`, child cannot weaken it
17
+ - If parent is `auto`, child inherits `auto` and its `permissionMode` is ignored
18
+ - Otherwise the child's `permissionMode` takes effect as declared