codebyplan 1.13.45 → 1.13.48

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 (125) hide show
  1. package/dist/cli.js +33 -13
  2. package/package.json +1 -1
  3. package/templates/agents/cbp-cc-executor.md +0 -1
  4. package/templates/agents/cbp-database-agent.md +0 -1
  5. package/templates/agents/cbp-e2e-maestro.md +0 -1
  6. package/templates/agents/cbp-e2e-playwright.md +0 -1
  7. package/templates/agents/cbp-e2e-tauri.md +0 -1
  8. package/templates/agents/cbp-e2e-vscode.md +0 -1
  9. package/templates/agents/cbp-e2e-xcuitest.md +0 -1
  10. package/templates/agents/cbp-improve-claude.md +0 -1
  11. package/templates/agents/cbp-improve-round.md +0 -1
  12. package/templates/agents/cbp-map-architecture.md +0 -1
  13. package/templates/agents/cbp-mechanical-edits.md +0 -1
  14. package/templates/agents/cbp-research.md +0 -1
  15. package/templates/agents/cbp-round-executor.md +0 -1
  16. package/templates/agents/cbp-security-agent.md +0 -1
  17. package/templates/agents/cbp-task-check.md +0 -1
  18. package/templates/agents/cbp-task-planner.md +0 -1
  19. package/templates/agents/cbp-testing-qa-agent.md +0 -1
  20. package/templates/github-workflows/publish.yml +3 -5
  21. package/templates/hooks/cbp-auto-test-hooks.sh +0 -1
  22. package/templates/hooks/cbp-canonical-templates-nudge.sh +0 -1
  23. package/templates/hooks/cbp-context-window-notify.sh +0 -1
  24. package/templates/hooks/cbp-e2e-spec-patterns.sh +0 -1
  25. package/templates/hooks/cbp-lint-format-on-edit.sh +0 -1
  26. package/templates/hooks/cbp-maestro-yaml-validate.sh +0 -1
  27. package/templates/hooks/cbp-mcp-caller-worktree-inject.sh +0 -1
  28. package/templates/hooks/cbp-mcp-migration-guard.sh +0 -1
  29. package/templates/hooks/cbp-mcp-round-sync.sh +0 -1
  30. package/templates/hooks/cbp-plugin-dispatch.sh +0 -1
  31. package/templates/hooks/cbp-pre-commit-quality-gate.sh +0 -1
  32. package/templates/hooks/cbp-session-start-hook.sh +0 -1
  33. package/templates/hooks/cbp-statusline.mjs +0 -1
  34. package/templates/hooks/cbp-statusline.py +0 -1
  35. package/templates/hooks/cbp-statusline.sh +0 -1
  36. package/templates/hooks/cbp-subagent-statusline.mjs +0 -1
  37. package/templates/hooks/cbp-subagent-statusline.py +0 -1
  38. package/templates/hooks/cbp-subagent-statusline.sh +0 -1
  39. package/templates/hooks/cbp-test-coverage-gate.sh +0 -1
  40. package/templates/hooks/cbp-test-hooks.sh +0 -1
  41. package/templates/hooks/validate-context-usage.sh +0 -1
  42. package/templates/hooks/validate-git-commit.sh +57 -9
  43. package/templates/hooks/validate-git-stash-deny.sh +0 -1
  44. package/templates/hooks/validate-structure-lengths.sh +0 -1
  45. package/templates/hooks/validate-structure-lib.sh +17 -1
  46. package/templates/hooks/validate-structure-patterns.sh +0 -1
  47. package/templates/hooks/validate-structure-scope.sh +43 -11
  48. package/templates/hooks/validate-structure-smoke.sh +0 -1
  49. package/templates/hooks/validate-structure-templates.sh +0 -1
  50. package/templates/hooks/validate-structure.sh +0 -1
  51. package/templates/hooks/verify-parity.sh +0 -1
  52. package/templates/rules/agent-claim-verification.md +0 -1
  53. package/templates/rules/architecture-map.md +0 -4
  54. package/templates/rules/cbp-operating-gotchas.md +0 -4
  55. package/templates/rules/context-file-loading.md +0 -1
  56. package/templates/rules/e2e-mandatory.md +0 -4
  57. package/templates/rules/parallel-waves.md +0 -1
  58. package/templates/rules/scope-vocabulary.md +14 -10
  59. package/templates/rules/supabase-branch-lifecycle.md +0 -1
  60. package/templates/rules/todo-backend.md +0 -1
  61. package/templates/skills/cbp-build-cc-agent/SKILL.md +2 -3
  62. package/templates/skills/cbp-build-cc-agent/reference/cbp-quality.md +6 -8
  63. package/templates/skills/cbp-build-cc-agent/scripts/validate-agent.sh +10 -1
  64. package/templates/skills/cbp-build-cc-claude-file/SKILL.md +0 -1
  65. package/templates/skills/cbp-build-cc-claude-file/scripts/validate-claude-file.sh +0 -1
  66. package/templates/skills/cbp-build-cc-mode/SKILL.md +0 -1
  67. package/templates/skills/cbp-build-cc-rule/SKILL.md +18 -8
  68. package/templates/skills/cbp-build-cc-rule/scripts/validate-rule.sh +4 -5
  69. package/templates/skills/cbp-build-cc-settings/SKILL.md +0 -1
  70. package/templates/skills/cbp-build-cc-settings/reference/cbp-conventions.md +0 -4
  71. package/templates/skills/cbp-build-cc-settings/scripts/validate-settings.sh +0 -1
  72. package/templates/skills/cbp-build-cc-skill/SKILL.md +0 -1
  73. package/templates/skills/cbp-build-cc-skill/reference/cbp-quality.md +6 -8
  74. package/templates/skills/cbp-build-cc-skill/scripts/validate-skill.sh +10 -2
  75. package/templates/skills/cbp-checkpoint-check/SKILL.md +0 -1
  76. package/templates/skills/cbp-checkpoint-complete/SKILL.md +0 -1
  77. package/templates/skills/cbp-checkpoint-create/SKILL.md +10 -11
  78. package/templates/skills/cbp-checkpoint-end/SKILL.md +0 -1
  79. package/templates/skills/cbp-checkpoint-plan/SKILL.md +0 -1
  80. package/templates/skills/cbp-checkpoint-plan/reference/alternative-comparison-template.md +0 -4
  81. package/templates/skills/cbp-checkpoint-plan/reference/dep-decision-rubric.md +0 -4
  82. package/templates/skills/cbp-checkpoint-plan/reference/e2e-discovery-probe.md +0 -4
  83. package/templates/skills/cbp-checkpoint-plan/reference/gap-analysis-playbook.md +0 -4
  84. package/templates/skills/cbp-checkpoint-start/SKILL.md +0 -1
  85. package/templates/skills/cbp-checkpoint-update/SKILL.md +0 -1
  86. package/templates/skills/cbp-frontend-a11y/SKILL.md +0 -1
  87. package/templates/skills/cbp-frontend-design/SKILL.md +0 -1
  88. package/templates/skills/cbp-frontend-ui/SKILL.md +0 -1
  89. package/templates/skills/cbp-frontend-ux/SKILL.md +0 -1
  90. package/templates/skills/cbp-git-branch-feat-create/SKILL.md +0 -1
  91. package/templates/skills/cbp-git-commit/SKILL.md +0 -1
  92. package/templates/skills/cbp-git-worktree-create/SKILL.md +0 -1
  93. package/templates/skills/cbp-git-worktree-remove/SKILL.md +0 -1
  94. package/templates/skills/cbp-map-architecture/SKILL.md +0 -1
  95. package/templates/skills/cbp-merge-main/SKILL.md +0 -1
  96. package/templates/skills/cbp-refresh-arch-map/SKILL.md +0 -1
  97. package/templates/skills/cbp-round-check/SKILL.md +0 -1
  98. package/templates/skills/cbp-round-complete/SKILL.md +0 -1
  99. package/templates/skills/cbp-round-end/SKILL.md +0 -1
  100. package/templates/skills/cbp-round-execute/SKILL.md +0 -1
  101. package/templates/skills/cbp-round-execute/reference/inline-fallback.md +0 -4
  102. package/templates/skills/cbp-round-input/SKILL.md +0 -1
  103. package/templates/skills/cbp-round-start/SKILL.md +0 -1
  104. package/templates/skills/cbp-round-update/SKILL.md +0 -1
  105. package/templates/skills/cbp-session-end/SKILL.md +0 -1
  106. package/templates/skills/cbp-session-start/SKILL.md +0 -1
  107. package/templates/skills/cbp-session-start/qa-regression.md +0 -1
  108. package/templates/skills/cbp-setup-e2e/SKILL.md +0 -1
  109. package/templates/skills/cbp-setup-eslint/SKILL.md +0 -1
  110. package/templates/skills/cbp-ship/SKILL.md +0 -1
  111. package/templates/skills/cbp-ship-configure/SKILL.md +0 -1
  112. package/templates/skills/cbp-ship-main/SKILL.md +0 -1
  113. package/templates/skills/cbp-supabase-branch-check/SKILL.md +0 -1
  114. package/templates/skills/cbp-supabase-branch-check/reference/dag-steps.md +0 -4
  115. package/templates/skills/cbp-supabase-migrate/SKILL.md +0 -1
  116. package/templates/skills/cbp-supabase-setup/SKILL.md +0 -1
  117. package/templates/skills/cbp-task-check/SKILL.md +0 -1
  118. package/templates/skills/cbp-task-complete/SKILL.md +0 -1
  119. package/templates/skills/cbp-task-create/SKILL.md +0 -1
  120. package/templates/skills/cbp-task-start/SKILL.md +0 -1
  121. package/templates/skills/cbp-task-testing/SKILL.md +0 -1
  122. package/templates/skills/cbp-todo/SKILL.md +0 -1
  123. package/templates/skills/cbp-todo/qa-regression.md +0 -1
  124. package/templates/skills/supabase/SKILL.md +0 -1
  125. package/templates/skills/supabase-postgres-best-practices/SKILL.md +0 -1
@@ -1,31 +1,63 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook Helper: Scope marker validation for validate-structure.sh
4
- # Purpose: Ensure all .claude/ files have a scope marker for structural classification
3
+ # Purpose: Enforce scope markers on USER-CREATED .claude/ files only. Files the
4
+ # codebyplan package distributes (a template twin exists) are MANAGED:
5
+ # org-shared is the implicit default, so no marker is required and an
6
+ # explicit 'org-shared' marker is redundant (warned, non-blocking).
7
+ # A file with no template twin is user-created and must declare a marker.
5
8
  # Sourced by validate-structure.sh - not run directly
6
9
  #
7
- # Expects: $REL_PATH, $FILE_PATH, $EXT, warn(), match_path(),
8
- # has_yaml_frontmatter(), has_yaml_field(), has_scope_comment() (from validate-structure-lib.sh)
10
+ # Expects: $REL_PATH, $FILE_PATH, $EXT, $REPO_ROOT, warn(), match_path(),
11
+ # has_yaml_frontmatter(), has_yaml_field(), has_scope_comment(),
12
+ # has_template_twin() (from validate-structure-lib.sh)
9
13
 
10
14
  # Only check .claude/ files
11
15
  if ! match_path '^/\.claude/'; then
12
16
  return 0 2>/dev/null || true
13
17
  fi
14
18
 
19
+ # Path beneath .claude/ — used for template-twin (managed) detection.
20
+ _scope_rel="${REL_PATH#/.claude/}"
21
+
22
+ # Managed = the codebyplan package ships a template twin for this file. When no
23
+ # twin is found (or no templates dir is resolvable) the file is user-created and
24
+ # a marker is required — the conservative fallback that preserves legacy behavior.
25
+ if has_template_twin "$_scope_rel"; then
26
+ _scope_managed=1
27
+ else
28
+ _scope_managed=0
29
+ fi
30
+
31
+ _valid_scope_re='^(org-shared|project-shared|repo-only:[a-z0-9]([a-z0-9-]*[a-z0-9])?)$'
32
+
15
33
  case "$EXT" in
16
34
  md)
17
- if has_yaml_frontmatter "$FILE_PATH"; then
18
- if ! has_yaml_field "$FILE_PATH" scope; then
19
- warn "Missing scope: in frontmatter. Add 'scope: org-shared' / 'scope: project-shared' / 'scope: repo-only:<name>' for structural classification. See rules/scope-vocabulary.md."
35
+ if has_yaml_frontmatter "$FILE_PATH" && has_yaml_field "$FILE_PATH" scope 50; then
36
+ _scope_val=$(head -50 "$FILE_PATH" 2>/dev/null | grep -E '^scope:' | head -1 \
37
+ | sed -E 's/^scope:[[:space:]]*//; s/[[:space:]]*#.*$//; s/[[:space:]]*$//')
38
+ if [ "$_scope_managed" = "1" ] && [ "$_scope_val" = "org-shared" ]; then
39
+ warn "Redundant 'scope: org-shared' on a package-managed file — org-shared is the implicit default; remove the key. See rules/scope-vocabulary.md."
40
+ elif ! [[ "$_scope_val" =~ $_valid_scope_re ]]; then
41
+ warn "Invalid scope value '$_scope_val'. Use org-shared / project-shared / repo-only:<name>. See rules/scope-vocabulary.md."
20
42
  fi
21
- else
22
- warn "Missing frontmatter with scope:. Add YAML frontmatter with 'scope: org-shared' / 'scope: project-shared' / 'scope: repo-only:<name>'. See rules/scope-vocabulary.md."
43
+ elif [ "$_scope_managed" = "0" ]; then
44
+ warn "Missing scope: in frontmatter. A user-created .claude/ file must declare 'scope: project-shared' or 'scope: repo-only:<name>' (package-managed files default to org-shared). See rules/scope-vocabulary.md."
23
45
  fi
46
+ # managed + no marker → org-shared implied, no warning.
24
47
  ;;
25
48
  sh)
26
- if ! has_scope_comment "$FILE_PATH"; then
27
- warn "Missing # @scope: comment. Add '# @scope: org-shared' / '# @scope: project-shared' / '# @scope: repo-only:<name>' after shebang. See rules/scope-vocabulary.md."
49
+ if has_scope_comment "$FILE_PATH"; then
50
+ _scope_val=$(head -5 "$FILE_PATH" 2>/dev/null | grep -E '^# @scope:' | head -1 \
51
+ | sed -E 's/^# @scope:[[:space:]]*//; s/[[:space:]]*#.*$//; s/[[:space:]]*$//')
52
+ if [ "$_scope_managed" = "1" ] && [ "$_scope_val" = "org-shared" ]; then
53
+ warn "Redundant '# @scope: org-shared' on a package-managed hook — org-shared is the implicit default; remove the comment. See rules/scope-vocabulary.md."
54
+ elif ! [[ "$_scope_val" =~ $_valid_scope_re ]]; then
55
+ warn "Invalid @scope value '$_scope_val'. Use org-shared / project-shared / repo-only:<name>. See rules/scope-vocabulary.md."
56
+ fi
57
+ elif [ "$_scope_managed" = "0" ]; then
58
+ warn "Missing # @scope: comment. A user-created .claude/ hook must declare '# @scope: project-shared' or '# @scope: repo-only:<name>' (package-managed hooks default to org-shared). See rules/scope-vocabulary.md."
28
59
  fi
60
+ # managed + no marker → org-shared implied, no warning.
29
61
  ;;
30
62
  json)
31
63
  # JSON can't have frontmatter — skip
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Smoke runner for validate-structure-*.sh + validate-structure-lib.sh
4
3
  # Iterates fixtures under __test-fixtures__/validate-structure/{good,bad}/
5
4
  # Each test case maps a fixture file → simulated rel path inside .claude/
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook Helper: Template/context suggestion for validate-structure.sh
4
3
  # Purpose: Map file locations to applicable templates or context files
5
4
  # Sourced by validate-structure.sh - not run directly
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # @hook: PreToolUse Edit|Write
4
3
  # Hook: PreToolUse for Edit|Write
5
4
  # Purpose: Validate file paths against structure patterns
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env bash
2
- # @scope: org-shared
3
2
  # @event: SessionStart
4
3
  # Scope + sibling-parity sweep at session start. Calls `codebyplan claude verify-parity --warn-only`.
5
4
  # Fires ONLY in the templates source monorepo (self-guards on templates/ presence); no-op for consumers.
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: agent-claim-verification
4
3
  description: Subagents must cite the source file (path:line) or vendor docs before asserting that any JSON key, schema field, env-var name, or external API shape exists.
5
4
  paths:
@@ -1,7 +1,3 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # Architecture Map
6
2
 
7
3
  When `.claude/architecture/` exists in this repo, per-module map files may be present.
@@ -1,7 +1,3 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # CBP Operating Gotchas
6
2
 
7
3
  Cross-repo traps in the CodeByPlan tooling surface (CLI, MCP, git, host platform) that
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  paths:
4
3
  - ".claude/context/**/*"
5
4
  - ".claude/agents/**/*"
@@ -1,7 +1,3 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # E2E Mandatory Run Contract
6
2
 
7
3
  E2E is **opt-out, not opt-in**. Whenever a framework configured in `.codebyplan/e2e.json`
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: parallel-waves
4
3
  description: Wave schema, invariants, and proximity-split algorithm for cbp-task-planner Phase 5.6 wave decomposition.
5
4
  paths:
@@ -1,10 +1,15 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # Scope Vocabulary
6
2
 
7
- Canonical scope-marker enum for `.claude/` files. Every CBP-managed agent, skill, rule, and hook script must declare exactly one `scope:` value from the enum below. The marker is enforced by four validators (cross-linked at the bottom of this file).
3
+ Canonical scope-marker enum for `.claude/` files. The marker classifies a structural file's distribution scope but it is **required only on user-created files**, not on the assets the `codebyplan` package distributes.
4
+
5
+ ## When is a `scope:` marker required?
6
+
7
+ A `.claude/` structural file (a rule, an agent, a `SKILL.md`, or a `hooks/*.sh`) is one of two kinds:
8
+
9
+ - **Package-managed** — the `codebyplan` package ships a **template twin** for it (`packages/codebyplan-package/templates/<rel>` in the monorepo, or `node_modules/codebyplan/templates/<rel>` in a consumer repo). Managed files are **`org-shared` by definition** — `org-shared` is the implicit, **markerless** default. A managed file needs **no** `scope:` marker; an explicit `scope: org-shared` on it is **redundant** and validators emit a non-blocking warning to remove it.
10
+ - **User-created** — no template twin exists. These are repo- or project-local additions the package never distributes, so they **must** declare a `scope:` marker (`project-shared` or `repo-only:<name>`; `org-shared` is also accepted but unusual for a non-distributed file).
11
+
12
+ **Conservative fallback**: when no templates directory is resolvable at all (e.g. `codebyplan` is not installed), twin detection is inactive and every structural file is treated as user-created — a marker is required. Enforcement is never silently dropped.
8
13
 
9
14
  ## Enum values
10
15
 
@@ -57,9 +62,8 @@ Used by `.sh` hook scripts and `.sh` tooling under `.claude/`. Place the marker
57
62
 
58
63
  ## Enforcement
59
64
 
60
- Four validators enforce this enum. A file missing the marker (or carrying a non-enum value) fails validation:
65
+ `codebyplan claude verify-parity` is the **central enforcer** of the rule above; the other validators are twin-aware helpers. A marker is required only on user-created (no-twin) files; a redundant `org-shared` marker on a managed (twin) file is a non-blocking warning; a present-but-non-enum value always fails:
61
66
 
62
- - `.claude/hooks/validate-structure-scope.sh` — warns when a `.claude/` file being edited (PreToolUse `Edit|Write`) lacks a scope marker; sourced by `validate-structure.sh`; it is NOT a session-start sweep.
63
- - `codebyplan claude verify-parity` — sweeps all `.claude/{rules,skills,agents,hooks}` for missing/non-enum scope markers AND runs the sibling-parity check against `templates/`; invoked automatically at session start via `.claude/hooks/verify-parity.sh` (monorepo only); run manually with `--json` for CI.
64
- - `.claude/skills/cbp-build-cc-agent/scripts/validate-agent.sh` — blocks agent authoring when `scope:` is absent.
65
- - `.claude/skills/cbp-build-cc-skill/scripts/validate-skill.sh` — blocks skill authoring when `scope:` is absent.
67
+ - `codebyplan claude verify-parity` — sweeps `.claude/{rules,skills,agents,hooks}`. For each structural file it checks the template twin: a no-twin file missing a marker is a **`missing-scope`** error; a managed file carrying `org-shared` is a **`redundant-scope`** warning (surfaced in `warnings`, never raises the exit code); any present non-enum value is an **`invalid-scope`** error. It also runs the sibling-parity check against `templates/`. Invoked automatically at session start via `.claude/hooks/verify-parity.sh` (monorepo only); run manually with `--json` (emits `{ violations, warnings }`) for CI.
68
+ - `.claude/hooks/validate-structure-scope.sh` — PreToolUse `Edit|Write` helper (sourced by `validate-structure.sh`, NOT a session-start sweep). Warns when a **user-created** `.claude/` file being edited lacks a marker, and warns on a redundant `org-shared` marker when the file is package-managed. Uses `has_template_twin` (in `validate-structure-lib.sh`) for managed detection.
69
+ - `.claude/skills/cbp-build-cc-agent/scripts/validate-agent.sh`, `.../cbp-build-cc-skill/scripts/validate-skill.sh`, `.../cbp-build-cc-rule/scripts/validate-rule.sh` — authoring validators. `scope:` is **optional** at authoring time; these scripts only reject a present-but-non-enum value. The user-created requirement is enforced centrally by `verify-parity`.
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  description: Supabase preview-branch lifecycle mirrors the git feat-branch lifecycle
4
3
  paths:
5
4
  - "supabase/migrations/**"
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  paths:
4
3
  - "apps/todo-worker/**"
5
4
  - "packages/mcp-tools/src/**"
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-build-cc-agent
4
3
  description: Build a Claude Code subagent at .claude/agents/{name}.md (flat form, per the official sub-agents spec) following the official sub-agents spec (frontmatter, tools, model, hooks, skills preload, permission modes, isolation).
5
4
  argument-hint: "[agent-name] [--scope=project|user] [--isolation=worktree]"
@@ -49,7 +48,7 @@ Default: `project`. Pass `--scope=user` to override. Use folder form `{scope-pat
49
48
 
50
49
  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
50
 
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).
51
+ CBP adds a `scope:` frontmatter marker (structural classification; not read by Claude Code). Values: `org-shared` | `project-shared` | `repo-only:<repo-name>`. It is **required only on user-created agents** — a package-managed agent (template twin under `templates/agents/`) is `org-shared` by default and needs no marker. Length hook warns at 400 lines, blocks at 800. Quality details in [reference/cbp-quality.md](reference/cbp-quality.md).
53
52
 
54
53
  ### Step 4 — Gather required fields
55
54
 
@@ -111,7 +110,7 @@ bash "${CLAUDE_SKILL_DIR}/scripts/validate-agent.sh" "{scope-path}/{name}.md"
111
110
 
112
111
  (Pass `{scope-path}/{name}/AGENT.md` instead if folder form was chosen.)
113
112
 
114
- It checks: name format, frontmatter parses, required fields present (`name`, `description`, `scope`), tool names are valid, model alias is recognised.
113
+ It checks: name format, frontmatter parses, required fields present (`name`, `description`), the `scope:` value is a valid enum when present (the key itself is optional — required only on user-created agents, enforced centrally by `codebyplan claude verify-parity`), tool names are valid, model alias is recognised.
115
114
 
116
115
  ### Step 8 — Surface to the user
117
116
 
@@ -1,7 +1,3 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # Agent Authoring Quality
6
2
 
7
3
  Quality expectations and structure for `/.claude/agents/{name}.md` files. This file adds CBP-specific constraints on top of the official Claude Code sub-agents spec.
@@ -10,13 +6,15 @@ Quality expectations and structure for `/.claude/agents/{name}.md` files. This f
10
6
 
11
7
  CBP uses the flat form `.claude/agents/{name}.md` — the default per the official Claude Code sub-agents spec. All 12 existing CBP agents use this layout. Folder form `.claude/agents/{name}/AGENT.md` is optional and only appropriate when the agent bundles supporting files (context, examples, scripts) next to the definition.
12
8
 
13
- ## Required CBP Frontmatter
9
+ ## CBP Frontmatter — the `scope:` marker
10
+
11
+ `scope:` is a CBP structural marker (not read by Claude Code itself). It is **required only on user-created agents** — ones the `codebyplan` package does NOT distribute. A package-managed agent (one that has a template twin under `templates/agents/`) is `org-shared` by default and needs **no** marker; an explicit `scope: org-shared` on it is redundant. See `rules/scope-vocabulary.md`.
14
12
 
15
- Every agent MUST have `scope:` in addition to the Claude Code native fields:
13
+ For a user-created agent, add a marker alongside the Claude Code native fields:
16
14
 
17
15
  ```yaml
18
16
  ---
19
- scope: org-shared # structural marker: org-shared | project-shared | repo-only:<repo-name>
17
+ scope: project-shared # or: repo-only:<repo-name> (user-created agents only)
20
18
  name: agent-name
21
19
  description: One sentence — used for matching. Be specific.
22
20
  tools: Read, Write, Edit, Glob, Grep, Bash
@@ -24,7 +22,7 @@ effort: high
24
22
  ---
25
23
  ```
26
24
 
27
- `scope:` is a CBP structural marker not read by Claude Code itself. Missing `scope:` fails validation (`validate-agent.sh` / `validate-structure-scope.sh`).
25
+ `validate-agent.sh` validates the value when present but does not require the key; `codebyplan claude verify-parity` is the central enforcer of the user-created requirement (and warns on a redundant `org-shared` marker on a managed agent).
28
26
 
29
27
  ## Agent Types
30
28
 
@@ -34,7 +34,16 @@ fm=$(awk '/^---[[:space:]]*$/{n++; next} n==1{print} n==2{exit}' "$FILE")
34
34
  # Required fields
35
35
  grep -qE '^name:[[:space:]]*' <<< "$fm" || err "missing required field: name"
36
36
  grep -qE '^description:[[:space:]]*' <<< "$fm" || err "missing required field: description"
37
- grep -qE '^scope:[[:space:]]*' <<< "$fm" || err "missing CBP required field: scope (org-shared|project-shared|repo-only:<repo-name>)"
37
+
38
+ # CBP scope: OPTIONAL. Required only on user-created assets (no template twin) —
39
+ # enforced centrally by `codebyplan claude verify-parity`. Package-managed agents
40
+ # default to org-shared (markerless). Validate the VALUE only when present.
41
+ if grep -qE '^scope:[[:space:]]*' <<< "$fm"; then
42
+ scope_val=$(grep -E '^scope:' <<< "$fm" | head -1 | sed -E 's/^scope:[[:space:]]*//; s/[[:space:]]*$//')
43
+ if ! [[ "$scope_val" =~ ^(org-shared|project-shared|repo-only:[a-z0-9]([a-z0-9-]*[a-z0-9])?)$ ]]; then
44
+ err "scope value '$scope_val' is not a valid enum value (org-shared|project-shared|repo-only:<slug>)"
45
+ fi
46
+ fi
38
47
 
39
48
  # Name format: kebab-case
40
49
  name=$(grep -E '^name:' <<< "$fm" | head -1 | sed -E 's/^name:[[:space:]]*//; s/[[:space:]]*$//; s/^"(.*)"$/\1/' || true)
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-build-cc-claude-file
4
3
  description: Create or update a CLAUDE.md file at any scope (managed, project, user, local) following the official memory spec — imports (@path), nested discovery, AGENTS.md bridge, comment stripping, and claudeMdExcludes.
5
4
  argument-hint: "[action] [--scope=managed|project|user|local]"
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Validate a CLAUDE.md or CLAUDE.local.md file.
4
3
  # Usage: validate-claude-file.sh <path-to-claude-file>
5
4
  # Exit 0 = valid, exit 1 = invalid (errors printed to stderr).
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-build-cc-mode
4
3
  description: Audit + apply the CHK-109 model/effort convention across every authoring skill and agent under `packages/codebyplan-package/templates/`. Skills set `effort:` only and inherit the session model; agents pin `model:` + `effort:`. Bare invocation audits and reports frontmatter gaps; with a path argument, edits the target file's frontmatter to the convention-decided values.
5
4
  argument-hint: "[path-to-agent-or-skill]"
@@ -1,7 +1,6 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-build-cc-rule
4
- description: Build a path-scoped rule file at .claude/rules/{name}.md following the official memory/rules spec (paths globs, always-loaded vs on-demand, symlinks) plus CBP conventions (required scope field for structural classification (validate-structure-scope.sh), narrow-paths discipline; hook warns at 100 lines, blocks at 200).
3
+ description: Build a path-scoped rule file at .claude/rules/{name}.md following the official memory/rules spec (paths globs, always-loaded vs on-demand, symlinks) plus CBP conventions (scope field for structural classification — required only on user-created rules (validate-structure-scope.sh), narrow-paths discipline; hook warns at 100 lines, blocks at 200).
5
4
  argument-hint: '[name] [--scope=project|user] [--paths="glob,glob"]'
6
5
  allowed-tools: Read, Write, Edit, Glob, Grep
7
6
  effort: xhigh
@@ -76,13 +75,24 @@ paths:
76
75
 
77
76
  Unscoped rules (no `paths:`) belong only on truly universal constraints: git attribution, company secrets policy, file-naming conventions.
78
77
 
79
- ### Step 4 — Required CBP Frontmatter
78
+ ### Step 4 — CBP Frontmatter
80
79
 
81
- Every rule MUST have **both** fields:
80
+ `scope:` is required **only for user-created rules** (no template twin); package-managed rules are `org-shared` by default — omit the marker. `paths:` is recommended for every rule.
81
+
82
+ **User-created rule** (must declare scope):
83
+
84
+ ```yaml
85
+ ---
86
+ scope: project-shared # or: repo-only:<repo-name>
87
+ paths:
88
+ - "apps/*/src/app/api/**/*.ts"
89
+ ---
90
+ ```
91
+
92
+ **Package-managed rule** (template twin exists → org-shared implicit, no marker):
82
93
 
83
94
  ```yaml
84
95
  ---
85
- scope: org-shared # or: project-shared | repo-only:<repo-name>
86
96
  paths:
87
97
  - "apps/*/src/app/api/**/*.ts"
88
98
  ---
@@ -90,7 +100,7 @@ paths:
90
100
 
91
101
  | Field | Purpose |
92
102
  | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
93
- | `scope:` | CBP structural marker — required by validators (`validate-structure-scope.sh`). NOT read by Claude Code. Values: `org-shared` \| `project-shared` \| `repo-only:<name>` |
103
+ | `scope:` | CBP structural marker — NOT read by Claude Code. Required only on **user-created** rules (no template twin); package-managed rules are `org-shared` by default and need no marker. Values: `org-shared` \| `project-shared` \| `repo-only:<name>`. See `rules/scope-vocabulary.md`. |
94
104
  | `paths:` | File globs that trigger rule loading (Claude Code native) |
95
105
 
96
106
  When propagating rules between repos, copy only rules where `scope: org-shared` OR `scope: repo-only:<target>`.
@@ -161,7 +171,7 @@ Run the validator:
161
171
  bash "${CLAUDE_SKILL_DIR}/scripts/validate-rule.sh" "{scope-path}/{name}.md"
162
172
  ```
163
173
 
164
- It checks: YAML frontmatter present, `scope:` field present and valid enum value, H1 heading present and its kebab-case form matches the filename, `paths:` field (warns if absent — unconditional rules burn context on every session), line count (warns at 100, errors at 200).
174
+ It checks: YAML frontmatter present, the `scope:` value is a valid enum when present (the key itself is optional — required only on user-created rules, enforced centrally by `codebyplan claude verify-parity`), H1 heading present and its kebab-case form matches the filename, `paths:` field (warns if absent — unconditional rules burn context on every session), line count (warns at 100, errors at 200).
165
175
 
166
176
  ### Step 9 — Verify loading
167
177
 
@@ -180,7 +190,7 @@ Use the `InstructionsLoaded` hook if you need to debug exactly when and why a ru
180
190
 
181
191
  - Every rule needs an intent — if removing it wouldn't change Claude's behaviour, delete it
182
192
  - Prefer path-scoped over unconditional — context is a finite budget
183
- - Missing `scope:` fails validation (validate-structure-scope.sh warns; validate-agent.sh / validate-skill.sh block); missing `paths:` loads the rule on every file read
193
+ - `scope:` is required only on user-created rules (no template twin); a managed rule is `org-shared` by default — enforced centrally by `codebyplan claude verify-parity` (missing marker = error for user-created files; redundant `org-shared` on a managed file = non-blocking warning); `validate-structure-scope.sh` also warns at edit time; missing `paths:` loads the rule on every file read
184
194
  - Rules are stored in the CBP database; the authoritative copy is in the DB — commit changes you want to keep
185
195
  - Conflicting rules load in both — Claude picks arbitrarily. Remove or merge duplicates
186
196
  - Rules that restate the Claude Code spec add no value — point to the official spec instead
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Validate a Claude Code rule file at .claude/rules/{name}.md.
4
3
  # Usage: validate-rule.sh <path-to-rule-file>
5
4
  # Exit 0 = valid, exit 1 = invalid (errors printed to stderr).
@@ -24,10 +23,10 @@ fi
24
23
  # Extract frontmatter block
25
24
  fm=$(awk '/^---[[:space:]]*$/{n++; next} n==1{print} n==2{exit}' "$FILE")
26
25
 
27
- # scope: field required + must match enum
28
- if ! grep -qE '^scope:[[:space:]]*' <<< "$fm"; then
29
- err "missing CBP required field: scope (org-shared|project-shared|repo-only:<repo-name>)"
30
- else
26
+ # scope: OPTIONAL. Required only on user-created assets (no template twin) —
27
+ # enforced centrally by `codebyplan claude verify-parity`. Package-managed rules
28
+ # default to org-shared (markerless). Validate the VALUE only when present.
29
+ if grep -qE '^scope:[[:space:]]*' <<< "$fm"; then
31
30
  scope_val=$(grep -E '^scope:' <<< "$fm" | head -1 | sed -E 's/^scope:[[:space:]]*//; s/[[:space:]]*$//')
32
31
  if ! [[ "$scope_val" =~ ^(org-shared|project-shared|repo-only:[a-z0-9]([a-z0-9-]*[a-z0-9])?)$ ]]; then
33
32
  err "scope value '$scope_val' is not a valid enum value (org-shared|project-shared|repo-only:<slug>)"
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-build-cc-settings
4
3
  description: Create or update Claude Code settings.json / settings.local.json / managed-settings.json following the official settings spec — scopes, permissions, hooks, sandbox, attribution, plugins, env vars, JSON schema validation.
5
4
  argument-hint: "[action] [--scope=user|project|local|managed]"
@@ -1,7 +1,3 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # Settings Authoring Conventions
6
2
 
7
3
  Read this before creating or updating `.claude/settings.json` or `.claude/settings.local.json`. This file adds CBP-specific constraints on top of the official Claude Code settings spec.
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Validate a Claude Code settings*.json file.
4
3
  # Usage: validate-settings.sh <path-to-settings-file>
5
4
  # Exit 0 = valid, exit 1 = invalid (errors printed to stderr).
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-build-cc-skill
4
3
  description: Build a Claude Code skill at .claude/skills/{name}/SKILL.md following the official skills spec — frontmatter, supporting files (templates, examples, reference, scripts), invocation control, argument substitution, dynamic context, fork-to-subagent, allowed-tools.
5
4
  argument-hint: "[skill-name] [--scope=project|user] [--fork] [--disable-model-invocation]"
@@ -1,24 +1,22 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # Skill Authoring Quality
6
2
 
7
3
  Quality expectations and structure for `/.claude/skills/{name}/SKILL.md` files. This file adds CBP-specific constraints on top of the official Claude Code skills spec.
8
4
 
9
- ## Required CBP Frontmatter
5
+ ## CBP Frontmatter — the `scope:` marker
6
+
7
+ `scope:` is a CBP structural marker (not read by Claude Code itself). It is **required only on user-created skills** — ones the `codebyplan` package does NOT distribute. A package-managed skill (one with a template twin under `templates/skills/`) is `org-shared` by default and needs **no** marker; an explicit `scope: org-shared` on it is redundant. See `rules/scope-vocabulary.md`.
10
8
 
11
- Every skill MUST have `scope:` in addition to the Claude Code native fields:
9
+ For a user-created skill, add a marker alongside the Claude Code native fields:
12
10
 
13
11
  ```yaml
14
12
  ---
15
- scope: org-shared # structural marker: org-shared | project-shared | repo-only:<repo-name>
13
+ scope: project-shared # or: repo-only:<repo-name> (user-created skills only)
16
14
  name: cbp-skill-name
17
15
  description: One sentence — shown in skill list and used for auto-matching
18
16
  ---
19
17
  ```
20
18
 
21
- `scope:` is a CBP structural marker not read by Claude Code itself. Missing `scope:` fails validation (`validate-skill.sh` / `validate-structure-scope.sh`).
19
+ `validate-skill.sh` validates the value when present but does not require the key; `codebyplan claude verify-parity` is the central enforcer of the user-created requirement (and warns on a redundant `org-shared` marker on a managed skill).
22
20
 
23
21
  ## What Skills Are
24
22
 
@@ -46,8 +46,16 @@ fi
46
46
  # Description recommended
47
47
  grep -qE '^description:\s*' <<< "$fm" || echo " WARN: no description — Claude will use first paragraph" >&2
48
48
 
49
- # CBP scope required
50
- grep -qE '^scope:\s*' <<< "$fm" || err "missing CBP required field: scope (org-shared|project-shared|repo-only:<repo-name>)"
49
+ # CBP scope: OPTIONAL. Required only on user-created assets (no template twin) —
50
+ # that requirement is enforced centrally by `codebyplan claude verify-parity`.
51
+ # Package-managed skills default to org-shared (markerless). Here we only validate
52
+ # the VALUE when a marker is present.
53
+ if grep -qE '^scope:\s*' <<< "$fm"; then
54
+ scope_val=$(grep -E '^scope:' <<< "$fm" | head -1 | sed -E 's/^scope:[[:space:]]*//; s/[[:space:]]*$//')
55
+ if ! [[ "$scope_val" =~ ^(org-shared|project-shared|repo-only:[a-z0-9]([a-z0-9-]*[a-z0-9])?)$ ]]; then
56
+ err "scope value '$scope_val' is not a valid enum value (org-shared|project-shared|repo-only:<slug>)"
57
+ fi
58
+ fi
51
59
 
52
60
  # Model — skills MUST NOT pin a model. A skill's inline turn runs in the user's
53
61
  # active session, so it inherits the session model. Pinning one forces a model the
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-checkpoint-check
4
3
  description: Full re-evaluation of a checkpoint with before/after comparison
5
4
  argument-hint: [CHK-NNN]
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-checkpoint-complete
4
3
  description: Complete a checkpoint after all tasks are done
5
4
  argument-hint: [checkpoint-number]
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-checkpoint-create
4
3
  description: Mechanical checkpoint creation — capture the user's description, infer title + goal, dedup against existing modules, create the checkpoint row + feat branch, then hand off to /cbp-checkpoint-plan for deep planning. Creates ZERO tasks.
5
4
  argument-hint: [checkpoint description]
@@ -67,24 +66,24 @@ Ask the user via AskUserQuestion whether to claim this checkpoint now:
67
66
  - **Claim for me + this worktree** (default) — resolve `npx codebyplan resolve-worktree 2>/dev/null` and set it as the checkpoint `worktree_id` at create. The creator carries momentum straight through plan → start.
68
67
  - **Leave it open** — create with `worktree_id` null so anyone free can claim it later via `/cbp-checkpoint-start`.
69
68
 
70
- Record the choice; it drives both the create call (Step 8) and the plan→start routing in `/cbp-checkpoint-plan`.
69
+ Record the choice; it drives both the create call (Step 7) and the plan→start routing in `/cbp-checkpoint-plan`.
71
70
 
72
- ### Step 7: Determine Next Checkpoint Number
73
-
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
-
76
- ### Step 8: Create Checkpoint Row
71
+ ### Step 7: Create Checkpoint Row
77
72
 
78
73
  `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`
74
+ - `--repo-id` (from `.codebyplan/repo.json`), `--title`, `--goal`, `--deadline`, `--status pending`
80
75
  - `--ideas` JSON `[{ description: <raw user text> }]`
81
76
  - `--worktree-id` the resolved worktree **only if the user chose "claim"**; omit when "leave open"
82
77
 
83
- Break-glass fallback: MCP `create_checkpoint` when the CLI is unavailable.
78
+ Do **not** pass `--number` — the database auto-assigns the next per-repo checkpoint number via a `BEFORE INSERT` trigger (advisory-locked `MAX(number)+1` scoped to `repo_id`). The DB-assigned number comes back on the created row (and is written into `.codebyplan/state/checkpoints/<id>.json`); read it for the branch slug (Step 8) and the result display (Step 9).
79
+
80
+ Break-glass fallback: MCP `create_checkpoint` (also omit `number`) when the CLI is unavailable.
84
81
 
85
82
  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.
86
83
 
87
- ### Step 9: Create + Switch to Feat Branch
84
+ ### Step 8: Create + Switch to Feat Branch
85
+
86
+ `{NNN}` below is the DB-assigned checkpoint number read back from the Step 7 `codebyplan checkpoint create` response.
88
87
 
89
88
  Read `.codebyplan/git.json` `branch_config.production` (default `"main"`) as `BASE`. codebyplan repos are main-only — never create or branch from a `development`/integration branch.
90
89
 
@@ -107,7 +106,7 @@ Persist the branch via `codebyplan checkpoint update --id <checkpoint-id> --bran
107
106
 
108
107
  **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.
109
108
 
110
- ### Step 10: Show Result + Auto-Trigger Plan
109
+ ### Step 9: Show Result + Auto-Trigger Plan
111
110
 
112
111
  ```
113
112
  ## Checkpoint Created
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-checkpoint-end
4
3
  description: Single point for all shipment — branch promotion to main via /cbp-ship-main, runtime deploy via /cbp-ship, branch cleanup, summary. Standalone tasks bypass shipment entirely.
5
4
  effort: xhigh
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-checkpoint-plan
4
3
  description: Deep inline planning for a checkpoint — assess, gap-analyse, decide dependencies, compare alternatives, optionally e2e-probe a suspected-broken area, then create tasks as vertical slices. Runs after /cbp-checkpoint-create (mechanical) and before /cbp-checkpoint-start (activate + claim). Does NOT activate or claim.
5
4
  argument-hint: [checkpoint-number]
@@ -1,7 +1,3 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # Alternative Comparison Template
6
2
 
7
3
  Loaded by `/cbp-checkpoint-plan` Step 6. Use when a meaningful design fork has more than one viable answer. Surfacing the alternatives — instead of silently picking one — is what lets the user redirect before tasks are created.
@@ -1,7 +1,3 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # Dependency Decision Rubric
6
2
 
7
3
  Loaded by `/cbp-checkpoint-plan` Step 5. Use when an idea could be built by extending something already installed OR by pulling in a new dependency. The goal is a deliberate, recorded choice — never a silent `pnpm add`.
@@ -1,7 +1,3 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # E2E Discovery Probe
6
2
 
7
3
  Loaded by `/cbp-checkpoint-plan` Step 4. The probe answers one question before you plan a fix: **is this area actually broken, and how?** It reuses the config-matched `cbp-e2e-*` specialist (the framework owners of e2e execution) in `whole_checkpoint_mode` rather than introducing a second smoke-test path. See `context/testing/e2e.md` for the dispatch contract that selects which specialist to spawn.
@@ -1,7 +1,3 @@
1
- ---
2
- scope: org-shared
3
- ---
4
-
5
1
  # Gap Analysis Playbook
6
2
 
7
3
  Loaded by `/cbp-checkpoint-plan` Step 3. The job: find what the raw request misses, before any task is created. Most "half-ass" outcomes come from planning only what was literally asked and ignoring the foundations it depends on or the adjacent breakage it sits next to.
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-checkpoint-start
4
3
  description: Activate a planned checkpoint and claim it for the current user/worktree, then route into task work. Runs after /cbp-checkpoint-plan (which produces tasks but never activates). Refuses to start an unplanned checkpoint.
5
4
  argument-hint: [checkpoint-number]
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-checkpoint-update
4
3
  description: Update checkpoint state (activate, update context, etc.)
5
4
  argument-hint: [checkpoint-number]