codebyplan 1.13.29 → 1.13.30

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 (26) hide show
  1. package/dist/cli.js +728 -18
  2. package/package.json +1 -1
  3. package/templates/README.md +16 -13
  4. package/templates/agents/cbp-cc-executor.md +6 -9
  5. package/templates/agents/cbp-round-executor.md +1 -2
  6. package/templates/rules/README.md +13 -8
  7. package/templates/rules/cbp-operating-gotchas.md +64 -0
  8. package/templates/settings.project.base.json +0 -1
  9. package/templates/skills/cbp-build-cc-agent/SKILL.md +3 -4
  10. package/templates/skills/cbp-build-cc-agent/examples/with-skills-preload.md +2 -3
  11. package/templates/skills/cbp-build-cc-agent/reference/frontmatter-fields.md +0 -1
  12. package/templates/skills/cbp-build-cc-agent/scripts/validate-agent.sh +0 -6
  13. package/templates/skills/cbp-build-cc-agent/templates/agent.md +1 -2
  14. package/templates/skills/cbp-build-cc-claude-file/SKILL.md +16 -2
  15. package/templates/skills/cbp-build-cc-claude-file/reference/what-belongs.md +1 -1
  16. package/templates/skills/cbp-build-cc-mode/SKILL.md +1 -1
  17. package/templates/skills/cbp-build-cc-rule/SKILL.md +2 -2
  18. package/templates/skills/cbp-build-cc-memory/SKILL.md +0 -201
  19. package/templates/skills/cbp-build-cc-memory/examples/feedback-memory.md +0 -11
  20. package/templates/skills/cbp-build-cc-memory/examples/project-memory.md +0 -11
  21. package/templates/skills/cbp-build-cc-memory/examples/reference-memory.md +0 -13
  22. package/templates/skills/cbp-build-cc-memory/examples/user-memory.md +0 -14
  23. package/templates/skills/cbp-build-cc-memory/reference/memory-types.md +0 -59
  24. package/templates/skills/cbp-build-cc-memory/reference/when-to-save.md +0 -62
  25. package/templates/skills/cbp-build-cc-memory/templates/MEMORY-index.md +0 -4
  26. package/templates/skills/cbp-build-cc-memory/templates/memory-entry.md +0 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebyplan",
3
- "version": "1.13.29",
3
+ "version": "1.13.30",
4
4
  "description": "CLI for CodeByPlan — AI-powered development planning and tracking",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,20 +1,23 @@
1
- # Templates
1
+ # .claude/
2
2
 
3
- This directory holds the installed content that the `codebyplan claude install` subcommand places into a consuming project's `./.claude/` directory. Skills, agents, and hooks live here.
3
+ This directory is **managed by the `codebyplan` package** and refreshed by:
4
4
 
5
- ## Authoring source
5
+ ```sh
6
+ npx codebyplan claude update
7
+ ```
6
8
 
7
- `packages/codebyplan-package/templates/` is the single source of truth for all `.claude/` content. The sibling-identity gate (CHK-134) requires that every edit to `templates/` is mirrored to `.claude/` in the same commit — there is no special "canonical worktree". Every worktree running this repo consumes updates via `npx codebyplan claude install|update`; release-please publishes the `codebyplan` npm package on merge to main, which propagates changes to consuming repos.
9
+ ## Do not hand-edit managed files
8
10
 
9
- ## Layout
11
+ Files installed here (skills, agents, hooks, rules) are owned by the `codebyplan` package. Running `codebyplan claude update` will overwrite any local changes to managed files.
10
12
 
11
- | Path | Count | Shape |
12
- | --------- | ------------------------------------ | ----------------------------------------------------------------------------------------------- |
13
- | `skills/` | 41 folders | each is a `SKILL.md` plus optional `templates/`, `reference/`, `examples/`, `scripts/` siblings |
14
- | `agents/` | 16 files | flat `.md` agent prompts (NOT `AGENT.md` subdirs) |
15
- | `hooks/` | 20 `.sh` + `hooks.json` + `README.md` | event hooks and manifest |
16
- | `rules/` | 1+ files | flat `<name>.md` rule files; see `rules/README.md` for bar and format |
13
+ To change managed behaviour, make the change upstream in the `codebyplan` package and publish a new version.
17
14
 
18
- ## This directory IS the source of truth
15
+ ## Repo-specific additions
19
16
 
20
- Edit files in this directory directly. There is no upstream tree — CHK-111 TASK-10 retired the prior in-monorepo plugin distribution path and replaced rsync-based distribution with an npm publish lifecycle. CHK-132 then consolidated that lifecycle into the merged `codebyplan` package; the assets now ship as the `claude` subcommand group (`install` / `update` / `uninstall`).
17
+ Additions that belong only to this repo go in repo-scoped files that `codebyplan` does not touch:
18
+
19
+ - **Root `CLAUDE.md`** — repo-level context and instructions always loaded by Claude Code.
20
+ - **`rules/` files with `scope: repo-only:<repo-name>`** — behavioral constraints specific to this repo.
21
+ - **`context/` and `docs/`** — repo-specific reference material referenced by your own agents or skills.
22
+
23
+ Repo-scoped files coexist with managed files and are never overwritten by `codebyplan claude update`.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  scope: org-shared
3
3
  name: cbp-cc-executor
4
- description: Authoring executor for `.claude/` infrastructure. Applies approved changes across rules, skills, agents, context, CLAUDE.md, settings, hooks, and auto-memory — with update-first discipline, scope-marker enforcement, and length-limit awareness. Callable by the main conversation, `/cbp-checkpoint-end`, and `round-executor` (for in-scope `.claude/` infra deliverables).
4
+ description: Authoring executor for `.claude/` infrastructure. Applies approved changes across rules, skills, agents, context, CLAUDE.md, settings, and hooks — with update-first discipline, scope-marker enforcement, and length-limit awareness. Callable by the main conversation, `/cbp-checkpoint-end`, and `round-executor` (for in-scope `.claude/` infra deliverables).
5
5
  tools: Read, Write, Edit, Glob, Grep, Skill, Task, AskUserQuestion, mcp__codebyplan__create_task
6
6
  model: sonnet
7
7
  effort: xhigh
@@ -40,7 +40,7 @@ input:
40
40
  source: 'main' | 'checkpoint-end' | 'round-executor' # additional internal sources may exist in your CBP setup; extend as needed
41
41
  changes:
42
42
  - id: string | number
43
- type: 'rule' | 'skill' | 'agent' | 'context' | 'architecture' | 'CLAUDE.md' | 'settings' | 'hook' | 'memory'
43
+ type: 'rule' | 'skill' | 'agent' | 'context' | 'architecture' | 'CLAUDE.md' | 'settings' | 'hook'
44
44
  target: string # Path under .claude/ (or CLAUDE.md)
45
45
  action: 'create' | 'update' | 'delete'
46
46
  description: string # What the change is
@@ -121,13 +121,12 @@ Per validated change, route to the correct authoring path:
121
121
  | CLAUDE.md | `/cbp-build-cc-claude-file` (only for a non-root CLAUDE.md — root exists) | Direct Edit |
122
122
  | settings | `/cbp-build-cc-settings` | `/cbp-build-cc-settings` (schema-critical — always route) |
123
123
  | hook | Direct Write with `# @scope:` header | Direct Edit |
124
- | memory | `/cbp-build-cc-memory` | `/cbp-build-cc-memory` (MEMORY.md index must update) |
125
124
 
126
125
  Routing rules:
127
126
 
128
127
  - **Creates always go through the build-cc skill** when one exists — the skill embeds the signature (`scope:` / `$schema:` / `type:`) the build-cc skills require.
129
128
  - **Updates use direct Edit** on already-signed files. The signature travels with the file; editing preserves it.
130
- - **Settings and memory always route** — their schema/index semantics are non-trivial.
129
+ - **Settings always route** — their schema semantics are non-trivial.
131
130
 
132
131
  Record every applied change with `authored_via` and `status`.
133
132
 
@@ -143,9 +142,8 @@ Record every applied change with `authored_via` and `status`.
143
142
  After all changes applied:
144
143
 
145
144
  1. For every touched file, re-check: still within length limit? scope marker still present?
146
- 2. If `MEMORY.md` touched: index lines ≤200 chars? No duplicate names?
147
- 3. If `settings.json` touched: valid JSON? Re-read the file and validate syntax — matched braces/brackets, quoted keys, no trailing commas. Reject the change if invalid.
148
- 4. Report any drift as `status: 'partial'` and list in `applied_changes[].note`.
145
+ 2. If `settings.json` touched: valid JSON? Re-read the file and validate syntax — matched braces/brackets, quoted keys, no trailing commas. Reject the change if invalid.
146
+ 3. Report any drift as `status: 'partial'` and list in `applied_changes[].note`.
149
147
 
150
148
  ### Phase 6: Return
151
149
 
@@ -164,7 +162,6 @@ Every managed file must carry its scope marker — checked by `validate-structur
164
162
  | agent | `scope: {value}` | YAML frontmatter |
165
163
  | hook | `# @scope: {value}` | Header comment |
166
164
  | settings | `$schema: {url}` (implicit scope via filename) | JSON field |
167
- | memory | `type: {user\|feedback\|project\|reference}` | YAML frontmatter |
168
165
  | context | _(signatureless)_ | n/a |
169
166
  | architecture | _(signatureless)_ | n/a |
170
167
  | CLAUDE.md | _(plain markdown)_ | n/a |
@@ -208,6 +205,6 @@ Block-limit violations are non-negotiable — split before applying.
208
205
  - **Spawned by**: main conversation (ad-hoc), `/cbp-checkpoint-end` (future), `round-executor` (in-scope `.claude/` infra deliverables, `source: 'round-executor'`)
209
206
  - **Reads**: `.claude/` inventory, `validate-structure-lengths.sh`, target files
210
207
  - **Writes**: `.claude/` files (via `/cbp-build-cc-*` skills for creates, direct Edit for updates)
211
- - **Calls skills**: `/cbp-build-cc-rule`, `/cbp-build-cc-skill`, `/cbp-build-cc-claude-file`, `/cbp-build-cc-settings`, `/cbp-build-cc-memory`
208
+ - **Calls skills**: `/cbp-build-cc-rule`, `/cbp-build-cc-skill`, `/cbp-build-cc-claude-file`, `/cbp-build-cc-settings`
212
209
  - **Creates tasks**: via MCP `create_task` when a change exceeds invocation scope
213
210
  - **Enforced by**: `validate-structure-lengths.sh` (length), `validate-structure-scope.sh` (scope marker), `validate-structure-patterns.sh` (path layout)
@@ -98,7 +98,7 @@ output:
98
98
 
99
99
  **Key Principle:** If something is unclear or you're blocked, ASK the user. Don't make assumptions.
100
100
 
101
- **Routing Principle:** For managed files requiring routing commands (`/cbp-build-cc-rule`, `/cbp-build-cc-agent`, `/cbp-build-cc-skill`, `/cbp-build-cc-claude-file`, `/cbp-build-cc-settings`, `/cbp-build-cc-memory`), use Skill tool. For other managed files (templates, architecture, research, stack docs), use direct Write/Edit.
101
+ **Routing Principle:** For managed files requiring routing commands (`/cbp-build-cc-rule`, `/cbp-build-cc-agent`, `/cbp-build-cc-skill`, `/cbp-build-cc-claude-file`, `/cbp-build-cc-settings`), use Skill tool. For other managed files (templates, architecture, research, stack docs), use direct Write/Edit.
102
102
 
103
103
  ## Execution Workflow
104
104
 
@@ -124,7 +124,6 @@ Skill tool: skill="cbp-build-cc-agent" # for .claude/agents/
124
124
  Skill tool: skill="cbp-build-cc-skill" # for .claude/skills/
125
125
  Skill tool: skill="cbp-build-cc-claude-file" # for .claude/CLAUDE.md
126
126
  Skill tool: skill="cbp-build-cc-settings" # for .claude/settings*.json
127
- Skill tool: skill="cbp-build-cc-memory" # for ~/.claude/projects/<project>/memory/
128
127
  Direct Write/Edit # for templates, docs/
129
128
  ```
130
129
 
@@ -34,14 +34,19 @@ The `install`/`update`/`uninstall` flow handles these files identically to how i
34
34
 
35
35
  ## Current status
36
36
 
37
- Four rules are shipped:
38
-
39
- | Rule file | Summary |
40
- |---|---|
41
- | `scope-vocabulary.md` | Canonical scope-marker enum (`org-shared` / `project-shared` / `repo-only:<name>`) enforced by three validators |
42
- | `context-file-loading.md` | Context-file load contract — who loads what, when, and how missing files are handled |
43
- | `todo-backend.md` | Todos queue contract, six DB-layer workflow invariants, and writer obligations for MCP mutators |
44
- | `supabase-branch-lifecycle.md` | Supabase preview-branch lifecycle mirrors the git feat-branch lifecycle — lazy create on first DB change, delete wherever the git branch is removed |
37
+ Nine rules are shipped:
38
+
39
+ | Rule file | Scope | Summary |
40
+ |---|---|---|
41
+ | `scope-vocabulary.md` | `org-shared` | Canonical scope-marker enum (`org-shared` / `project-shared` / `repo-only:<name>`) enforced by three validators |
42
+ | `context-file-loading.md` | `org-shared` | Context-file load contract — who loads what, when, and how missing files are handled |
43
+ | `todo-backend.md` | `org-shared` | Todos queue contract, six DB-layer workflow invariants, and writer obligations for MCP mutators |
44
+ | `supabase-branch-lifecycle.md` | `org-shared` | Supabase preview-branch lifecycle mirrors the git feat-branch lifecycle — lazy create on first DB change, delete wherever the git branch is removed |
45
+ | `agent-claim-verification.md` | `org-shared` | Verify an agent's claimed outcomes against ground truth (git, filesystem, tool results) before trusting them |
46
+ | `e2e-mandatory.md` | `org-shared` | E2E is opt-out: an eligible framework whose source changed in a round must run its specialist or record a valid skip |
47
+ | `parallel-waves.md` | `org-shared` | Wave-dispatch contract for parallel round execution — topological ordering and per-wave testing |
48
+ | `task-routing-recommendation.md` | `repo-only:codebyplan` | Two-family command surface (checkpoint-bound vs standalone) and identifier-format routing — installed only in codebyplan-family repos |
49
+ | `cbp-operating-gotchas.md` | `org-shared` | Cross-repo CBP-tooling traps (ship/timeout/MCP-replace/worktree/lint-baseline/approval-reconcile) + behavioral prefs, inherited once by all consumers |
45
50
 
46
51
  ## Contributing a rule
47
52
 
@@ -0,0 +1,64 @@
1
+ ---
2
+ scope: org-shared
3
+ ---
4
+
5
+ # CBP Operating Gotchas
6
+
7
+ Cross-repo traps in the CodeByPlan tooling surface (CLI, MCP, git, host platform) that
8
+ recur in every consuming repo. They are recorded **once** here so consumers inherit them via
9
+ `npx codebyplan claude update` instead of re-learning each one per repo. This file is for
10
+ SHARED tooling behavior only — repo-specific gotchas belong in that repo's own `CLAUDE.md`
11
+ (root or nested), never here.
12
+
13
+ ## Tooling Traps
14
+
15
+ - **`codebyplan ship` can report a false `checks_failed`.** The CLI polls
16
+ `gh pr checks --json name,state,conclusion` and treats a check as failed when its `state` is
17
+ `COMPLETED` and its `conclusion` is non-null and not a success value — but `gh` does not always
18
+ populate `conclusion` for every check type, so a green PR can be misread as failed. Do not trust
19
+ the CLI verdict alone: confirm with `gh pr checks <pr> --watch`, then merge manually with
20
+ `gh pr merge <pr> --merge`.
21
+
22
+ - **macOS has no `timeout` binary.** Wrapping a build/lint/test in `timeout …` fails with
23
+ `command not found: timeout` — meaning the wrapped command **never ran** (a misleading
24
+ "exit 127", not a real result). Never shell-wrap with `timeout`; use the Bash tool's own
25
+ `timeout` parameter to bound a command.
26
+
27
+ - **MCP `update_checkpoint` / `update_task` / `update_round` are REPLACE, not merge.** The
28
+ `context` JSONB and `files_changed[]` array overwrite wholesale — a partial write silently
29
+ clobbers existing `decisions` / `discoveries` / `check_results`. Always read the current row,
30
+ merge your change into the full object/array, then write the whole thing back.
31
+
32
+ - **`resolve-worktree` empty output = a NULL `(device, path, branch)` tuple, not a broken
33
+ resolver.** When identity is unresolved the server can collapse the caller to the repo's main
34
+ worktree, so feat-locked writes get rejected. Pass `caller_worktree_id` on every MCP mutation,
35
+ and confirm ownership by matching the row's repo path + branch to the current directory before
36
+ mutating.
37
+
38
+ - **Full-repo lint/type baselines are often pre-existing red.** A round must gate on the files
39
+ it changed, not the whole-repo baseline — scope lint/tsc checks to the round's changed set so a
40
+ pre-existing baseline error outside that set never fails the round.
41
+
42
+ - **`complete_task` checks file approval on the round's `files_changed`, not the task's.**
43
+ Reconcile approvals via `update_round` (set each entry `user_approved: true`), not
44
+ `update_task` alone — updating only the task leaves the round entries unapproved and
45
+ `complete_task` rejects with "files are not approved".
46
+
47
+ - **CLI transport uses REST (reads) and OAuth+MCP (writes) — a 502 from `codebyplan round sync-approvals` is transient MCP churn, not an outage.** The CLI exits 0 with a warning and MCP tools still work. A missing `CODEBYPLAN_API_KEY` surfaces as an `ApiError`, not a 502. `sync-approvals` can also drag untracked per-device dirs into `files_changed` — run it from the repo root or pass `--caller-worktree-id`.
48
+
49
+ - **`codebyplan claude update` requires a TTY.** On non-TTY stdin (CI, piped) it half-applies then errors. Re-run with `--yes` to accept defaults non-interactively.
50
+
51
+ - **Checkpoint locks are invisible until a mutation they block.** `get_checkpoints` / `get_tasks` succeed even when another worktree holds the lock; the 403 fires only on `update_*` / `complete_*`. Verify the row's `worktree_id` matches the caller before mutating. A null-`worktree_id` checkpoint can still be actively shipped by whichever worktree physically holds its feat branch — check `git worktree list` first.
52
+
53
+ - **`update_task` accepts `caller_worktree_id` for lock-verify only — it does NOT assign ownership.** Ownership assignment goes through the web UI or the dedicated assignment path. Don't conflate `caller_worktree_id` with `assigned_worktree_id`.
54
+
55
+ - **Re-run config-driven gates after merging main into a feat branch.** A merge can add or change `.codebyplan/shipment.json`, ports, branch config, `e2e.json`, and `eslint.json` — treat the post-merge state as a fresh baseline before continuing.
56
+
57
+ ## Behavioral Preferences
58
+
59
+ - **Never `git stash`** — for any reason. To inspect or compare other state use
60
+ `git diff <ref>`, `git show <ref>:<path>`, or `git worktree add`.
61
+
62
+ - **During MCP instability, verify tool results over narration.** When responses lag, servers
63
+ cycle, or calls 502, never state an expected output as fact — confirm against git and the
64
+ filesystem, which are the source of truth.
@@ -96,7 +96,6 @@
96
96
  "allow": [
97
97
  "Skill(cbp-build-cc-agent)",
98
98
  "Skill(cbp-build-cc-claude-file)",
99
- "Skill(cbp-build-cc-memory)",
100
99
  "Skill(cbp-build-cc-mode)",
101
100
  "Skill(cbp-build-cc-rule)",
102
101
  "Skill(cbp-build-cc-settings)",
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  scope: org-shared
3
3
  name: cbp-build-cc-agent
4
- 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, memory, hooks, skills preload, permission modes, isolation).
5
- argument-hint: "[agent-name] [--scope=project|user] [--memory=project|user|local] [--isolation=worktree]"
4
+ 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
+ argument-hint: "[agent-name] [--scope=project|user] [--isolation=worktree]"
6
6
  allowed-tools: Read, Write, Edit, Glob, Grep, Bash(mkdir *), Bash(chmod *)
7
7
  effort: xhigh
8
8
  ---
@@ -15,7 +15,7 @@ Create a Claude Code subagent following the official Claude Code sub-agents spec
15
15
 
16
16
  ## Arguments
17
17
 
18
- `$ARGUMENTS` — agent name (kebab-case, required). Flags: `--scope=project|user` (default `project`), `--memory=project|user|local`, `--isolation=worktree`.
18
+ `$ARGUMENTS` — agent name (kebab-case, required). Flags: `--scope=project|user` (default `project`), `--isolation=worktree`.
19
19
 
20
20
  ## When to Use
21
21
 
@@ -70,7 +70,6 @@ Check each against the task and include only when they add value:
70
70
 
71
71
  | Capability | Field | When to include |
72
72
  | -------------------- | --------------------------------------------------------------- | ------------------------------------------------------ |
73
- | Persistent memory | `memory: project\|user\|local` | Agent should accumulate learnings across conversations |
74
73
  | Preloaded skills | `skills: [skill-a, skill-b]` | Domain knowledge the agent needs every run |
75
74
  | Scoped MCP servers | `mcpServers: [...]` | Tools the parent session shouldn't have in context |
76
75
  | Lifecycle hooks | `hooks: { PreToolUse: [...], PostToolUse: [...], Stop: [...] }` | Need to validate tool calls or trigger side-effects |
@@ -4,7 +4,6 @@ description: Implement API endpoints following team conventions. Use when adding
4
4
  tools: Read, Write, Edit, Grep, Glob, Bash
5
5
  model: sonnet
6
6
  effort: xhigh
7
- memory: project
8
7
  skills:
9
8
  - api-conventions
10
9
  - error-handling-patterns
@@ -13,11 +12,11 @@ skills:
13
12
  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
13
 
15
14
  When invoked:
16
- 1. Read `MEMORY.md` to recall past learnings on this codebase
15
+ 1. Read the nearest folder-local `CLAUDE.md` (e.g. `src/api/CLAUDE.md`) for conventions specific to this area
17
16
  2. Locate the handler directory (`src/api/handlers/`)
18
17
  3. Implement the endpoint per the preloaded conventions
19
18
  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
19
+ 5. When you discover a durable pattern worth remembering, record it in the folder-local `CLAUDE.md` via `/cbp-build-cc-claude-file`
21
20
 
22
21
  Return:
23
22
  - Files created/modified
@@ -14,7 +14,6 @@ Source: official Claude Code sub-agents spec. Only `name` and `description` are
14
14
  | `skills` | list | Skills to preload — full content injected at startup |
15
15
  | `mcpServers` | list | String references (shared) or inline defs (scoped to this agent) |
16
16
  | `hooks` | object | Lifecycle hooks — `PreToolUse`, `PostToolUse`, `Stop` (→ `SubagentStop`) |
17
- | `memory` | string | `user` \| `project` \| `local` — persistent MEMORY.md directory |
18
17
  | `background` | boolean | Always run concurrent to the main thread |
19
18
  | `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
19
  | `isolation` | string | `worktree` — gives the agent a temporary git worktree |
@@ -54,12 +54,6 @@ if [ -n "$pm" ] && [[ ! "$pm" =~ ^(default|acceptEdits|auto|dontAsk|bypassPermis
54
54
  err "permissionMode invalid: got '$pm'"
55
55
  fi
56
56
 
57
- # Memory scope check
58
- mem=$(grep -E '^memory:' <<< "$fm" | head -1 | sed -E 's/^memory:[[:space:]]*//; s/[[:space:]]*$//; s/^"(.*)"$/\1/' || true)
59
- if [ -n "$mem" ] && [[ ! "$mem" =~ ^(user|project|local)$ ]]; then
60
- err "memory must be user|project|local: got '$mem'"
61
- fi
62
-
63
57
  if [ "$errors" -gt 0 ]; then
64
58
  echo "validation FAILED ($errors issue(s)) for $FILE" >&2
65
59
  exit 1
@@ -12,7 +12,6 @@ effort: xhigh
12
12
  # color: blue # red | blue | green | yellow | purple | orange | pink | cyan
13
13
  # background: false
14
14
  # isolation: worktree # only if the agent should work in an isolated git worktree
15
- # memory: project # project | user | local — enables persistent MEMORY.md
16
15
  # skills:
17
16
  # - api-conventions
18
17
  # - error-handling-patterns
@@ -33,7 +32,7 @@ effort: xhigh
33
32
  # hooks:
34
33
  # - type: command
35
34
  # command: "./scripts/run-linter.sh"
36
- # initialPrompt: "Start by reading MEMORY.md, then wait for instructions." # only used when run as main thread via --agent
35
+ # initialPrompt: "Start by reading the project CLAUDE.md, then wait for instructions." # only used when run as main thread via --agent
37
36
  ---
38
37
 
39
38
  You are a [role] specialising in [domain].
@@ -28,12 +28,12 @@ Actions:
28
28
  - Adding a new project-level fact (build command, architecture decision)
29
29
  - Restructuring when CLAUDE.md grows past ~200 lines
30
30
  - Migrating from AGENTS.md to CLAUDE.md (or bridging them)
31
+ - Capturing a folder-local learning (a `project`/`feedback` insight tied to one area of the tree) → author a **nested CLAUDE.md** next to that code (see "Authoring a nested CLAUDE.md" below). This is the home for durable learnings that previously went to auto-memory.
31
32
 
32
33
  Do NOT use this skill for:
33
34
 
34
35
  - Workflow details or behavioural rules → `/cbp-build-cc-rule`
35
36
  - Reusable step-by-step procedures → `/cbp-build-cc-skill`
36
- - Personal learnings across projects → `/cbp-build-cc-memory`
37
37
 
38
38
  ## Instructions
39
39
 
@@ -48,6 +48,20 @@ Do NOT use this skill for:
48
48
 
49
49
  Default: project. Either `./CLAUDE.md` or `./.claude/CLAUDE.md` works; pick one and stick to it.
50
50
 
51
+ ### Step 1.5 — Authoring a nested CLAUDE.md
52
+
53
+ A **nested** CLAUDE.md lives in a subdirectory (e.g. `apps/web/src/lib/CLAUDE.md`) rather than the repo root. It is the home for a folder-local learning — a `project`/`feedback` insight that only matters when working in that part of the tree (what previously went to auto-memory). Prefer a nested CLAUDE.md over the root file whenever the fact is scoped to one area: it keeps the root high-signal and loads the detail only when relevant.
54
+
55
+ **Discovery (how nested files load).** At session start Claude Code loads every `CLAUDE.md` on the path from the working directory **up** to the repo root. Files in subdirectories **below** the working directory load **on-demand** — the moment Claude reads any file inside that subdirectory. Unlike the root file, nested CLAUDE.md content does **not** survive compaction — it reloads when Claude next touches a matching subdirectory file. So a nested file is self-contained context for its folder, not a place for repo-wide rules.
56
+
57
+ **Placement.** Put the file in the shallowest directory that fully contains the concern:
58
+
59
+ - A gotcha about one package's build → that package root (`packages/foo/CLAUDE.md`)
60
+ - A convention for a feature area → that feature dir (`apps/web/src/lib/CLAUDE.md`)
61
+ - A repo-wide fact → the root CLAUDE.md, not a nested file
62
+
63
+ **Authoring.** Same quality gates as the root file (specific > vague, no duplication, keep it stable), but scope every line to the folder. Open with one line naming the area the file governs. Cross-link the root file or a rule with `@path` imports instead of repeating their content. To create one, run this skill with `create --scope=project` and write to the nested path.
64
+
51
65
  ### Step 2 — Read existing CLAUDE.md (for update/check)
52
66
 
53
67
  ```bash
@@ -165,7 +179,7 @@ Run `/memory` to confirm the file is loaded. The list shows all CLAUDE.md, CLAUD
165
179
  - **Triggered by**: user invocation
166
180
  - **Reads**: `${CLAUDE_SKILL_DIR}/templates/*.md`, `${CLAUDE_SKILL_DIR}/reference/*.md`, current CLAUDE.md, `.claude/rules/*.md`
167
181
  - **Writes**: CLAUDE.md at the chosen scope
168
- - **Related skills**: `/cbp-build-cc-rule` (behavioural constraints), `/cbp-build-cc-memory` (personal learnings), `/cbp-build-cc-settings` (for `claudeMdExcludes`)
182
+ - **Related skills**: `/cbp-build-cc-rule` (behavioural constraints), `/cbp-build-cc-settings` (for `claudeMdExcludes`)
169
183
 
170
184
  ## Key Rules
171
185
 
@@ -15,7 +15,7 @@ Source: official Claude Code memory spec — *Write effective instructions*.
15
15
  |-------------|------------------|
16
16
  | Multi-step procedure | Skill (`.claude/skills/{name}/SKILL.md`) |
17
17
  | File-specific constraint | Path-scoped rule (`.claude/rules/{name}.md` with `paths:`) |
18
- | Personal learning | Auto memory (`~/.claude/projects/<project>/memory/`) |
18
+ | Folder-local learning (project/feedback) | Nested CLAUDE.md placed next to the code it concerns (see SKILL.md "Authoring a nested CLAUDE.md") |
19
19
  | API endpoint documentation | `docs/` |
20
20
  | Architecture deep-dive | `docs/architecture/` |
21
21
  | Framework usage guide | `docs/stack/{framework}/` |
@@ -23,7 +23,7 @@ Audit or apply the canonical `model:` + `effort:` frontmatter convention across
23
23
 
24
24
  `model: sonnet` + `effort: xhigh`
25
25
 
26
- Fifteen of the 16 authoring agents take the default (`cbp-cc-executor`, `cbp-database-agent`, `cbp-improve-claude`, `cbp-improve-round`, `cbp-research`, `cbp-round-executor`, `cbp-security-agent`, `cbp-task-check`, `cbp-task-planner`, `cbp-testing-qa-agent`, `cbp-e2e-playwright`, `cbp-e2e-maestro`, `cbp-e2e-tauri`, `cbp-e2e-vscode`, `cbp-e2e-xcuitest`). The 16th — `cbp-mechanical-edits` — is an explicit haiku-low exception (see below). 27 skills take the default: cbp-round-start, cbp-round-input, cbp-round-execute, cbp-task-create, cbp-task-start, cbp-task-complete, cbp-task-testing, cbp-checkpoint-create, cbp-checkpoint-check, cbp-checkpoint-end, cbp-build-cc-mode, cbp-build-cc-agent, cbp-build-cc-skill, cbp-build-cc-rule, cbp-build-cc-claude-file, cbp-build-cc-memory, cbp-build-cc-settings, cbp-frontend-a11y, cbp-frontend-design, cbp-frontend-ui, cbp-frontend-ux, cbp-session-end, cbp-ship, cbp-ship-configure, cbp-supabase-setup, cbp-supabase-migrate, cbp-supabase-branch-check.
26
+ Fifteen of the 16 authoring agents take the default (`cbp-cc-executor`, `cbp-database-agent`, `cbp-improve-claude`, `cbp-improve-round`, `cbp-research`, `cbp-round-executor`, `cbp-security-agent`, `cbp-task-check`, `cbp-task-planner`, `cbp-testing-qa-agent`, `cbp-e2e-playwright`, `cbp-e2e-maestro`, `cbp-e2e-tauri`, `cbp-e2e-vscode`, `cbp-e2e-xcuitest`). The 16th — `cbp-mechanical-edits` — is an explicit haiku-low exception (see below). 26 skills take the default: cbp-round-start, cbp-round-input, cbp-round-execute, cbp-task-create, cbp-task-start, cbp-task-complete, cbp-task-testing, cbp-checkpoint-create, cbp-checkpoint-check, cbp-checkpoint-end, cbp-build-cc-mode, cbp-build-cc-agent, cbp-build-cc-skill, cbp-build-cc-rule, cbp-build-cc-claude-file, cbp-build-cc-settings, cbp-frontend-a11y, cbp-frontend-design, cbp-frontend-ui, cbp-frontend-ux, cbp-session-end, cbp-ship, cbp-ship-configure, cbp-supabase-setup, cbp-supabase-migrate, cbp-supabase-branch-check.
27
27
 
28
28
  ### Effort-lowered skills (5)
29
29
 
@@ -25,7 +25,7 @@ Create a rule at `.claude/rules/{name}.md` per the official Claude Code memory s
25
25
 
26
26
  - Step-by-step workflows → use `/cbp-build-cc-skill` (loads on invoke, doesn't burn context)
27
27
  - Project-level facts always needed → CLAUDE.md (use `/cbp-build-cc-claude-file`)
28
- - Accumulating learnings → auto memory (use `/cbp-build-cc-memory`)
28
+ - Accumulating learnings → nested CLAUDE.md (use `/cbp-build-cc-claude-file`)
29
29
 
30
30
  ## Instructions
31
31
 
@@ -164,7 +164,7 @@ Use the `InstructionsLoaded` hook if you need to debug exactly when and why a ru
164
164
  - **Triggered by**: user invocation
165
165
  - **Reads**: `${CLAUDE_SKILL_DIR}/templates/rule.md`, `${CLAUDE_SKILL_DIR}/reference/paths-patterns.md`
166
166
  - **Writes**: `.claude/rules/{name}.md` or `~/.claude/rules/{name}.md`
167
- - **Related skills**: `/cbp-build-cc-claude-file` (project facts), `/cbp-build-cc-skill` (workflows), `/cbp-build-cc-memory` (auto-learnings)
167
+ - **Related skills**: `/cbp-build-cc-claude-file` (project facts + nested-folder learnings), `/cbp-build-cc-skill` (workflows)
168
168
 
169
169
  ## Key Rules
170
170
 
@@ -1,201 +0,0 @@
1
- ---
2
- scope: org-shared
3
- name: cbp-build-cc-memory
4
- description: Create or update an auto-memory entry under the Claude Code auto-memory directory per the official spec. Handles path-slug encoding, per-repo redirection via autoMemoryDirectory, MEMORY.md index, and per-entry typing (user/feedback/project/reference).
5
- argument-hint: "[entry-name] [--type=user|feedback|project|reference] [--repo-local]"
6
- allowed-tools: Read, Write, Edit, Glob, Grep, Bash(mkdir *), Bash(cat *), Bash(ls *), Bash(jq *)
7
- effort: xhigh
8
- ---
9
-
10
- # Build Claude Code Auto-Memory Entry
11
-
12
- Create or update an entry in Claude Code's auto-memory directory per the official Claude Code memory spec (section _Auto memory_).
13
-
14
- Auto memory is machine-local knowledge Claude accumulates across sessions. Only the first 200 lines or 25KB of `MEMORY.md` load at session start.
15
-
16
- ## Arguments
17
-
18
- `$ARGUMENTS` — entry name (kebab-case, used as filename). Flags: `--type=user|feedback|project|reference` (see [reference/memory-types.md](reference/memory-types.md)), `--repo-local` (store at `.claude/memory/` via user-scope `autoMemoryDirectory` override; see Step 1).
19
-
20
- ## When to Use
21
-
22
- | Situation | Action |
23
- | ------------------------------------------------------------ | -------------------------------------- |
24
- | User tells you something about themselves | Save as `user` memory |
25
- | User corrects you, or confirms a non-obvious approach worked | Save as `feedback` memory |
26
- | User shares project info (deadline, stakeholder, WHY) | Save as `project` memory |
27
- | User points to external system (Linear, Slack, dashboard) | Save as `reference` memory |
28
- | User says "remember this" / "save this" | Save immediately, pick type by content |
29
- | User says "forget X" | Find and delete the entry |
30
-
31
- Do **NOT** save:
32
-
33
- - Things derivable from `git log`, `git blame`, or reading the current code
34
- - Debugging fixes (they're already in the commit)
35
- - CLAUDE.md content (different mechanism)
36
- - Ephemeral task/conversation state
37
-
38
- ## Instructions
39
-
40
- ### Step 1 — Locate the memory directory
41
-
42
- **Default (global auto-memory):** `~/.claude/projects/<project-slug>/memory/`.
43
-
44
- The `<project-slug>` is the **absolute git repo path with `/` replaced by `-`**, e.g. repo at `/Users/alice/my-app` → slug `-Users-alice-my-app`. The `<project>` placeholder in the docs is not a friendly name — it's this slug.
45
-
46
- Resolve it deterministically:
47
-
48
- ```bash
49
- REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
50
- SLUG="$(echo "$REPO_ROOT" | sed 's|/|-|g')"
51
- DEFAULT_DIR="$HOME/.claude/projects/$SLUG/memory"
52
- ```
53
-
54
- Worktrees get a separate slug (the spec says all worktrees share one dir, but the runtime slugs by path — verify with `ls ~/.claude/projects/ | grep "$SLUG"`).
55
-
56
- **Override (`autoMemoryDirectory`):** the runtime reads this key only from **user, local, or managed-policy** settings — never from project settings. Resolve in that priority order, then fall back to the default path.
57
-
58
- ```bash
59
- # Check overrides in priority order
60
- for f in "$HOME/.claude/settings.json" ".claude/settings.local.json"; do
61
- override=$(jq -r '.autoMemoryDirectory // empty' "$f" 2>/dev/null)
62
- [ -n "$override" ] && MEMORY_DIR="${override/#\~/$HOME}" && break
63
- done
64
- MEMORY_DIR="${MEMORY_DIR:-$DEFAULT_DIR}"
65
- mkdir -p "$MEMORY_DIR"
66
- ```
67
-
68
- ### Step 2 — Pick scope: global vs repo-local vs user-global
69
-
70
- Three valid configurations (decide before writing):
71
-
72
- | Scope | Where it lives | How to enable | When to use |
73
- | ---------------------------- | ----------------------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------- |
74
- | Global auto-memory (default) | `~/.claude/projects/<slug>/memory/` | No config — works by default | Personal learnings specific to this repo |
75
- | Repo-local | `<repo>/.claude/memory/` | Set `autoMemoryDirectory` in `.claude/settings.local.json` (NOT `settings.json`) | Team-shared repo memory; also gitignore if sensitive |
76
- | User-global | `~/my-notes/` or similar | Set `autoMemoryDirectory` in `~/.claude/settings.json` | One memory pool across all your projects |
77
-
78
- **CBP default: global.** Switch to repo-local only when (a) the memory would help a teammate on the same repo, (b) isn't already in CLAUDE.md, and (c) you're comfortable committing it (or gitignoring deliberately). Prefer global for automatic feedback-type memories.
79
-
80
- **Never save credentials, secrets, or PII** to any memory scope. Memory is loaded into every session.
81
-
82
- **Memory vs CLAUDE.md vs rules:**
83
-
84
- | Destination | What belongs |
85
- | ------------------------ | -------------------------------------------------------------------------------------- |
86
- | CLAUDE.md | Stable, team-shared facts needed every session (tech stack, branch strategy, repo IDs) |
87
- | `.claude/rules/` | Behavioural constraints enforced on specific files (paths-scoped) |
88
- | Auto-memory (global) | Personal learnings, user's working style, past corrections |
89
- | Auto-memory (repo-local) | Team facts not yet stable enough for CLAUDE.md |
90
-
91
- Don't duplicate across destinations.
92
-
93
- **Repo-local setup** (if `--repo-local` or user asks):
94
-
95
- 1. Invoke `/cbp-build-cc-settings` to add `"autoMemoryDirectory": "./.claude/memory"` to `.claude/settings.local.json` (user-scope is also accepted). Project-scope `settings.json` is **rejected** by the runtime.
96
- 2. Create the directory: `mkdir -p .claude/memory`
97
- 3. Decide: commit to git (team-shared) or add to `.gitignore` (personal in-repo).
98
-
99
- ### Step 3 — Read the existing MEMORY.md
100
-
101
- ```bash
102
- cat "$MEMORY_DIR/MEMORY.md" 2>/dev/null || echo "(no MEMORY.md yet)"
103
- ```
104
-
105
- MEMORY.md is the **index**, not a store. One-line pointer per entry, under ~150 chars. It's loaded every session (first 200 lines / 25KB). Keep it tight.
106
-
107
- ### Step 4 — Check for an existing entry
108
-
109
- ```bash
110
- ls "$MEMORY_DIR" | grep -i "{topic-keyword}"
111
- ```
112
-
113
- If a related entry exists:
114
-
115
- - Updating an existing fact → edit that file
116
- - Same topic, different angle → edit or merge
117
- - New but adjacent → create new file, cross-link from MEMORY.md
118
-
119
- Never duplicate.
120
-
121
- ### Step 5 — Classify the entry
122
-
123
- Pick the right type. Details: [reference/memory-types.md](reference/memory-types.md).
124
-
125
- | Type | Saves | Example trigger |
126
- | ----------- | ----------------------------- | ----------------------------------------- |
127
- | `user` | Who they are, how they work | "I've been writing Go for 10 years" |
128
- | `feedback` | Corrections AND confirmations | "stop summarizing", "yeah that was right" |
129
- | `project` | Work context, deadlines, WHY | "we're freezing after Thursday" |
130
- | `reference` | Pointers to external systems | "bugs live in Linear project INGEST" |
131
-
132
- ### Step 6 — Write the entry file
133
-
134
- Read `${CLAUDE_SKILL_DIR}/templates/memory-entry.md` for the canonical format.
135
-
136
- Filename convention: `{type}_{topic}.md` (e.g. `feedback_testing.md`, `user_role.md`, `project_q1_freeze.md`).
137
-
138
- Frontmatter:
139
-
140
- ```yaml
141
- ---
142
- name: Human-readable entry name
143
- description: One-line relevance hint — used to judge if this memory matters in a new conversation
144
- type: user | feedback | project | reference
145
- ---
146
- ```
147
-
148
- For `feedback` and `project` types, structure the body as:
149
-
150
- 1. Lead line — the rule or fact itself
151
- 2. **Why:** — reason the user gave (incident, preference, deadline)
152
- 3. **How to apply:** — when this guidance kicks in
153
-
154
- See [examples/feedback-memory.md](examples/feedback-memory.md) and [examples/project-memory.md](examples/project-memory.md).
155
-
156
- ### Step 7 — Update MEMORY.md
157
-
158
- MEMORY.md is an index, not a memory. No frontmatter. One line per entry:
159
-
160
- ```markdown
161
- # Memory
162
-
163
- - [Title](file.md) — one-line hook
164
- - [Another title](another.md) — one-line hook
165
- ```
166
-
167
- Keep each line under ~150 characters. Organize by topic, not chronology.
168
-
169
- ### Step 8 — Handle absolute dates
170
-
171
- Convert relative dates to absolute when saving:
172
-
173
- | User said | Save as |
174
- | -------------- | --------------------------- |
175
- | "by Thursday" | `2026-04-23` (today + days) |
176
- | "next week" | `2026-04-29 to 2026-05-05` |
177
- | "last quarter" | `2026-Q1` |
178
-
179
- Memories persist — relative dates rot.
180
-
181
- ### Step 9 — Verify with `/memory`
182
-
183
- Run `/memory` in Claude Code to browse the directory. New entries appear immediately in the index load (on next session).
184
-
185
- ## Integration
186
-
187
- - **Triggered by**: user asking to remember, feedback during work
188
- - **Reads**: `${CLAUDE_SKILL_DIR}/templates/*.md`, `${CLAUDE_SKILL_DIR}/reference/*.md`
189
- - **Writes**: resolved `$MEMORY_DIR` (default `~/.claude/projects/<slug>/memory/`, or `autoMemoryDirectory` override)
190
- - **Related skills**: `/cbp-build-cc-settings` (configure `autoMemoryDirectory`), `/cbp-build-cc-claude-file` (team-shared facts → CLAUDE.md, not memory), `/cbp-build-cc-rule` (behavioural constraints → rules)
191
-
192
- ## Key Rules
193
-
194
- - `<project>` in the docs is a **slug** (`/` → `-`), not a friendly name
195
- - `autoMemoryDirectory` is **rejected** from project `settings.json` — only user / local / managed-policy accept it
196
- - MEMORY.md is an **index** — pointer lines only, no frontmatter, no long content
197
- - Lines after 200 (or 25KB) are not loaded at session start — keep MEMORY.md concise
198
- - Global auto memory is machine-local; for team-shared use repo-local and commit to git
199
- - Verify facts before recommending — memory can go stale; re-read the code when acting
200
- - When the user says "don't use memory," do not cite or act on it for this session
201
- - For a memory that names a file/function/flag — grep before relying on it
@@ -1,11 +0,0 @@
1
- ---
2
- name: Integration tests hit a real database
3
- description: Never mock the DB in integration tests — prior incident taught the team this
4
- type: feedback
5
- ---
6
-
7
- Integration tests must hit a real database, not mocks.
8
-
9
- **Why:** Prior incident (2025-Q4) — mocked tests passed but a prod migration failed because the mock diverged from the real schema. Team agreed to never mock the DB in integration tests afterwards.
10
-
11
- **How to apply:** Whenever writing or reviewing tests under `tests/integration/`, `apps/*/tests/integration/`, or anything tagged `@integration`. Unit tests may still mock. If you see a mock in an integration test, flag it.