codebyplan 1.13.29 → 1.13.31

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 (32) 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/hooks/cbp-mcp-caller-worktree-inject.sh +79 -0
  7. package/templates/hooks/cbp-test-hooks.sh +81 -0
  8. package/templates/hooks/hooks.json +9 -0
  9. package/templates/rules/README.md +13 -8
  10. package/templates/rules/cbp-operating-gotchas.md +64 -0
  11. package/templates/settings.project.base.json +0 -1
  12. package/templates/skills/cbp-build-cc-agent/SKILL.md +3 -4
  13. package/templates/skills/cbp-build-cc-agent/examples/with-skills-preload.md +2 -3
  14. package/templates/skills/cbp-build-cc-agent/reference/frontmatter-fields.md +0 -1
  15. package/templates/skills/cbp-build-cc-agent/scripts/validate-agent.sh +0 -6
  16. package/templates/skills/cbp-build-cc-agent/templates/agent.md +1 -2
  17. package/templates/skills/cbp-build-cc-claude-file/SKILL.md +16 -2
  18. package/templates/skills/cbp-build-cc-claude-file/reference/what-belongs.md +1 -1
  19. package/templates/skills/cbp-build-cc-mode/SKILL.md +1 -1
  20. package/templates/skills/cbp-build-cc-rule/SKILL.md +2 -2
  21. package/templates/skills/cbp-checkpoint-start/SKILL.md +2 -2
  22. package/templates/skills/cbp-task-complete/SKILL.md +1 -1
  23. package/templates/skills/cbp-task-start/SKILL.md +2 -2
  24. package/templates/skills/cbp-build-cc-memory/SKILL.md +0 -201
  25. package/templates/skills/cbp-build-cc-memory/examples/feedback-memory.md +0 -11
  26. package/templates/skills/cbp-build-cc-memory/examples/project-memory.md +0 -11
  27. package/templates/skills/cbp-build-cc-memory/examples/reference-memory.md +0 -13
  28. package/templates/skills/cbp-build-cc-memory/examples/user-memory.md +0 -14
  29. package/templates/skills/cbp-build-cc-memory/reference/memory-types.md +0 -59
  30. package/templates/skills/cbp-build-cc-memory/reference/when-to-save.md +0 -62
  31. package/templates/skills/cbp-build-cc-memory/templates/MEMORY-index.md +0 -4
  32. package/templates/skills/cbp-build-cc-memory/templates/memory-entry.md +0 -15
@@ -136,7 +136,7 @@ Skip the push only when nothing was committed in Step 5 AND `/cbp-merge-main` re
136
136
 
137
137
  ### Step 7: Complete Task
138
138
 
139
- Call `complete_task(task_id)`. The server resolves the caller's worktree identity from the JWT/ctx and enforces the mutate-lock (CHK-140 TASK-3 `caller_worktree_id` input field removed). The server auto-clears `assigned_user_id` + `assigned_worktree_id` on the task; if this was the last sibling task, it also clears the parent checkpoint's assignment. (Per CHK-104 hard-lock.)
139
+ Call `complete_task(task_id)`. `caller_worktree_id` (CHK-140 TASK-7) identifies the calling worktree and is auto-injected by the `cbp-mcp-caller-worktree-inject.sh` PreToolUse hook (CHK-198 TASK-2); the server falls back to the repo `main` worktree only when it is absent, then enforces the mutate-lock. The server auto-clears `assigned_user_id` + `assigned_worktree_id` on the task; if this was the last sibling task, it also clears the parent checkpoint's assignment. (Per CHK-104 hard-lock.)
140
140
 
141
141
  ### Step 8: Run Cleanup + Migration (inline)
142
142
 
@@ -171,7 +171,7 @@ See `dependency-vulnerability-fixes.md` "Audit Sweep at Task Start" for the sour
171
171
 
172
172
  ### Step 3.5: Worktree-Match Verification
173
173
 
174
- Before activating the task, verify the caller's worktree matches the assigned worktree on the target row. (Per CHK-104 — DB-level hard-lock prevents cross-worktree mutations; the server resolves caller identity from the JWT/ctx.)
174
+ Before activating the task, verify the caller's worktree matches the assigned worktree on the target row. (Per CHK-104 — DB-level hard-lock prevents cross-worktree mutations.)
175
175
 
176
176
  1. Read caller worktree: `CALLER_WT=$(npx codebyplan resolve-worktree 2>/dev/null)`.
177
177
  2. Determine target worktree:
@@ -232,7 +232,7 @@ Display context summary:
232
232
 
233
233
  Use MCP `update_task(task_id, status: "in_progress")`.
234
234
 
235
- If worktree_id present, include `claim_worktree_id` to auto-claim the checkpoint. The server resolves the caller's worktree identity from the JWT/ctx (CHK-140 TASK-3 `caller_worktree_id` input field removed).
235
+ If worktree_id present, include `claim_worktree_id` to auto-claim the checkpoint. `caller_worktree_id` (CHK-140 TASK-7) identifies the calling worktree and is auto-injected by the `cbp-mcp-caller-worktree-inject.sh` PreToolUse hook (CHK-198 TASK-2); the server falls back to the repo `main` worktree only when it is absent.
236
236
 
237
237
  ### Step 6: Auto-trigger Round Start
238
238
 
@@ -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.
@@ -1,11 +0,0 @@
1
- ---
2
- name: Auth middleware rewrite is compliance-driven
3
- description: Compliance context for the auth rewrite — affects scope decisions
4
- type: project
5
- ---
6
-
7
- Auth middleware rewrite is driven by legal/compliance requirements around session token storage, not tech-debt cleanup.
8
-
9
- **Why:** Legal flagged the current middleware in 2026-Q1 because session tokens are stored in a way that doesn't meet the new compliance requirements. Deadline: 2026-05-15.
10
-
11
- **How to apply:** When making scope decisions on this rewrite, favour compliance over ergonomics. Don't add unrelated refactors. Don't defer compliance work for "cleaner" architecture. If asked to trade off — compliance wins.
@@ -1,13 +0,0 @@
1
- ---
2
- name: Pipeline bugs tracked in Linear INGEST
3
- description: External system pointer for pipeline-related tickets and dashboards
4
- type: reference
5
- ---
6
-
7
- Pipeline bugs are tracked in Linear project **INGEST** (https://linear.app/acme/team/INGEST).
8
-
9
- Related dashboards:
10
- - `grafana.internal/d/api-latency` — oncall latency dashboard; check when editing request-path code
11
- - `https://status.acme.com/pipeline` — customer-facing pipeline status
12
-
13
- When the user mentions a pipeline bug by ID (e.g. INGEST-4123), look there first.
@@ -1,14 +0,0 @@
1
- ---
2
- name: User role and frontend experience
3
- description: User's technical background — use to calibrate explanation depth
4
- type: user
5
- ---
6
-
7
- User has deep Go backend experience (10+ years) and is newly touching the React side of this repo.
8
-
9
- Frame frontend explanations in terms of backend analogues:
10
- - Components ≈ structs + methods
11
- - Hooks ≈ middleware-like composition
12
- - React state ≈ mutex-guarded field on a struct
13
-
14
- Skip JS fundamentals (closures, async). Go deeper on React-specific patterns (render cycles, effect semantics, ref semantics).
@@ -1,59 +0,0 @@
1
- # Memory Types Reference
2
-
3
- Four discrete types of auto-memory entries. Pick by content, not by user phrasing.
4
-
5
- ## `user`
6
-
7
- **Contains:** role, goals, responsibilities, existing knowledge.
8
-
9
- **Save when:** you learn details about who the user is or how they collaborate. Tailors future behaviour.
10
-
11
- **Skip when:** the info would be a negative judgement, or it's not relevant to work.
12
-
13
- **Example trigger:** "I'm a data scientist investigating logging."
14
-
15
- ## `feedback`
16
-
17
- **Contains:** guidance the user has given about how to approach work — corrections AND confirmations.
18
-
19
- **Save when:**
20
- - User corrects you ("no not that", "don't", "stop")
21
- - User confirms a non-obvious approach worked ("yes exactly", "that was the right call")
22
-
23
- **Structure:** rule → **Why:** (reason) → **How to apply:** (when).
24
-
25
- **Example trigger:** "stop summarizing at the end of every response."
26
-
27
- Record successes too — otherwise you drift toward cautious defaults and away from validated approaches.
28
-
29
- ## `project`
30
-
31
- **Contains:** ongoing work context — goals, deadlines, incidents, stakeholders, WHY behind initiatives.
32
-
33
- **Save when:** you learn who is doing what, why, or by when — things not derivable from code or git history.
34
-
35
- **Convert dates to absolute** when saving (never "Thursday" — always `2026-04-23`).
36
-
37
- **Structure:** fact → **Why:** → **How to apply:**.
38
-
39
- **Example trigger:** "we're freezing after Thursday for the mobile cut."
40
-
41
- Project memories decay fast. The **Why** helps future-you judge whether the memory is still load-bearing.
42
-
43
- ## `reference`
44
-
45
- **Contains:** pointers to external systems (Linear, Slack, Grafana, Notion, Confluence).
46
-
47
- **Save when:** user mentions a resource by name. Memory just says *where to look*.
48
-
49
- **Example trigger:** "the Grafana dashboard at grafana.internal/d/api-latency is what oncall watches."
50
-
51
- ## What NOT to save (any type)
52
-
53
- - Code patterns, file paths, project structure (re-derivable from code)
54
- - Git history, who-changed-what (`git log`, `git blame` are authoritative)
55
- - Debugging fixes (already in the commit; PR body has the why)
56
- - CLAUDE.md content (that's a different mechanism)
57
- - Ephemeral task state (in-progress work, current conversation)
58
-
59
- Applies **even when the user asks you to save**. If they ask to save a PR list, ask what was *surprising* — that's the part worth keeping.
@@ -1,62 +0,0 @@
1
- # When to Save vs Skip
2
-
3
- Decision tree for auto-memory entries.
4
-
5
- ## Save immediately
6
-
7
- | Signal | Type |
8
- |--------|------|
9
- | User corrects you ("no", "don't", "stop") | feedback |
10
- | User confirms a non-obvious choice worked | feedback |
11
- | User shares their role, experience, preferences | user |
12
- | User explains **why** something is the way it is | project |
13
- | User names an external system (ticket tracker, dashboard, channel) | reference |
14
- | User says "remember this" / "save this" | pick by content |
15
-
16
- ## Skip
17
-
18
- - "What's the status of X?" — derivable from code/DB, don't save
19
- - "Here's the PR list" — derivable from `gh pr list`, don't save unless something was surprising
20
- - Fix you just made — the commit has the why, don't duplicate
21
- - Architecture you just read — re-read when needed
22
-
23
- ## Update an existing entry instead of creating
24
-
25
- Before writing a new file:
26
-
27
- ```bash
28
- ls ~/.claude/projects/<project>/memory/ | grep -i {topic}
29
- ```
30
-
31
- If anything matches:
32
- - Fact has changed → edit the existing file, update description if needed
33
- - New angle on same topic → merge into existing, keep one file per topic
34
-
35
- ## Remove stale entries
36
-
37
- When a memory turns out wrong:
38
-
39
- 1. Delete the file
40
- 2. Remove the index line from MEMORY.md
41
-
42
- When a memory references something that no longer exists (file renamed/removed):
43
-
44
- 1. Grep the codebase for the referenced symbol/path
45
- 2. If truly gone, delete the memory
46
- 3. If renamed, update the memory
47
-
48
- ## Verify before acting
49
-
50
- A memory naming a specific function, file, or flag is a claim that it existed *when written*. Before recommending it:
51
-
52
- - Memory names a file path → check the file exists
53
- - Memory names a function or flag → grep for it
54
- - User is about to act on your recommendation → always verify first
55
-
56
- "Memory says X exists" is not the same as "X exists now."
57
-
58
- ## Session gates
59
-
60
- - `/clear` wipes conversation context but NOT memory — memory reloads on next session
61
- - When the user says "ignore memory" or "don't use memory" — do not cite or act on memory content for this session; do not say "memory says X"
62
- - When memory conflicts with current code — trust the code, update or remove the stale memory
@@ -1,4 +0,0 @@
1
- # Memory
2
-
3
- - [Entry title](filename.md) — one-line hook under ~150 chars
4
- - [Another entry](another.md) — one-line hook
@@ -1,15 +0,0 @@
1
- ---
2
- name: Entry title
3
- description: One-line relevance hint — future sessions read this to decide if the memory matters
4
- type: user | feedback | project | reference
5
- ---
6
-
7
- [Memory content]
8
-
9
- # For feedback and project types, structure as:
10
-
11
- The rule or fact itself in one sentence.
12
-
13
- **Why:** The reason the user gave — often a past incident or strong preference.
14
-
15
- **How to apply:** When/where this guidance kicks in, so future-you can judge edge cases.