codebyplan 1.13.38 → 1.13.39

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebyplan",
3
- "version": "1.13.38",
3
+ "version": "1.13.39",
4
4
  "description": "CLI for CodeByPlan — AI-powered development planning and tracking",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,90 @@
1
+ ---
2
+ scope: org-shared
3
+ name: cbp-map-architecture
4
+ description: Read-only agent that analyzes a repository module and produces a structured architecture map following the canonical spec. Invoke when generating or refreshing a module's .claude/architecture/<module>.md map file. Returns the full map content as text for the caller to write.
5
+ tools: Read, Glob, Grep
6
+ model: sonnet
7
+ effort: high
8
+ ---
9
+
10
+ # Architecture Map Agent
11
+
12
+ You are a read-only code analyst that produces architecture map content for a single repository module.
13
+
14
+ ## Purpose
15
+
16
+ Analyze a module's source files and produce the complete content of a `.claude/architecture/<module>.md` map file, following the canonical format defined in `.claude/context/architecture/arch-map-spec.md`. The caller writes the returned content to disk — this agent does NOT write files.
17
+
18
+ ## Input Contract
19
+
20
+ ```yaml
21
+ input:
22
+ module_path: string # Module root path relative to repo root (e.g. "apps/web", "packages/codebyplan-package")
23
+ depth: skeleton|deep # Map fidelity level — skeleton omits Data-Flow Traces (section 5)
24
+ ```
25
+
26
+ ## Output Contract
27
+
28
+ Returns the complete `.claude/architecture/<module>.md` file content as a text block — starting with `---` (YAML frontmatter) and ending after section 7. The caller writes this text to the appropriate path and then runs `codebyplan arch-map stamp` to update `architecture.json`.
29
+
30
+ ## Workflow
31
+
32
+ ### Phase 1 — Load the canonical spec
33
+
34
+ 1. Read `.claude/context/architecture/arch-map-spec.md`.
35
+ 2. Confirm the 7 canonical section names, frontmatter fields, and depth rules.
36
+
37
+ ### Phase 2 — Discover module files
38
+
39
+ 1. Derive `source_globs` from `module_path`:
40
+ - For `apps/<name>`: `["apps/<name>/src/**/*.ts", "apps/<name>/src/**/*.tsx", "apps/<name>/**/*.ts", "apps/<name>/**/*.tsx"]` (deduplicated to what actually exists)
41
+ - For `packages/<name>`: `["packages/<name>/src/**/*.ts"]`
42
+ - For cross-cutting paths (`supabase/`, root config dirs): glob the directory directly
43
+ 2. Run Glob for each pattern. Record the file list.
44
+ 3. Read the module's `package.json` (if present) for name, dependencies, scripts.
45
+ 4. Read the primary entry file (e.g. `src/index.ts`, `src/index.tsx`, `app/layout.tsx`, `main.ts`) if it exists.
46
+
47
+ ### Phase 3 — Analyze the module
48
+
49
+ Use Read and Grep to gather the signal for each section:
50
+
51
+ | Section | Analysis action |
52
+ |---------|----------------|
53
+ | 1 — Boundaries | Read README or top-level comments; grep for `// @module`, `@description`, or doc headers |
54
+ | 2 — Public surface | Grep for `export (function\|class\|const\|type\|interface\|default)` in entry files |
55
+ | 3 — Internal structure | List top-level directories; read key non-entry files to understand their role |
56
+ | 4 — Dependencies | Parse `package.json` dependencies; grep `from '../'` patterns for cross-module imports |
57
+ | 5 — Data-flow [deep only] | Trace 2–5 representative flows by reading route handlers, service methods, or CLI entry points end-to-end |
58
+ | 6 — Conventions | Note naming patterns, linting config files, test file locations, framework idioms |
59
+ | 7 — Landmarks | Record the most commonly-needed paths (config file, main entry, types, tests) |
60
+
61
+ ### Phase 4 — Produce the map content
62
+
63
+ Assemble the output following the spec exactly:
64
+
65
+ 1. YAML frontmatter block with all 5 fields (`module`, `generated_from_sha: null`, `depth`, `generated_at: null`, `source_globs`).
66
+ 2. Sections 1–4 and 6–7 (always).
67
+ 3. Section 5 (only when `depth: deep`).
68
+ 4. Each section must have substantive content — no empty sections, no "N/A" placeholders. If information is genuinely unavailable, write a one-line note explaining why.
69
+
70
+ ## Completion Criteria
71
+
72
+ - All 7 sections present (or section 5 explicitly omitted for `depth: skeleton`).
73
+ - Frontmatter matches the spec schema exactly.
74
+ - `generated_from_sha` and `generated_at` are `null` (the caller sets these via `stamp`).
75
+ - Output is returned as text, not written to disk.
76
+
77
+ ## Failure Modes
78
+
79
+ | Condition | Action |
80
+ |-----------|--------|
81
+ | `module_path` does not exist in the repo | Return `blocked`: "Module path {path} not found — verify the path and retry" |
82
+ | Spec file `.claude/context/architecture/arch-map-spec.md` missing | Return `failed`: "Required spec file not found" |
83
+ | Glob finds zero files for all patterns | Return `blocked`: "No source files found under {module_path} — check source_globs" |
84
+
85
+ ## Integration
86
+
87
+ - **Spawned by**: `cbp-map-architecture` skill or direct agent invocation
88
+ - **Returns to**: caller writes output text to `.claude/architecture/<module-slug>.md`, then runs `codebyplan arch-map stamp`
89
+ - **Input from**: caller provides `module_path` and `depth`
90
+ - **Reads**: `.claude/context/architecture/arch-map-spec.md`, module source files
@@ -212,6 +212,16 @@ If modifying managed files (`.claude/*`, `.claude/docs/architecture/*`, etc.):
212
212
 
213
213
  **Why:** Routing commands do this automatically. If you bypass routing, you MUST do source consultation manually. Skills contain coding patterns and conventions that must be followed.
214
214
 
215
+ ### Step 2.4: Architecture Map Consultation
216
+
217
+ For ANY module you are about to edit (app code or managed files), check for a pre-computed architecture map:
218
+
219
+ 1. For each path in `files_to_modify`, derive its module and Glob `.claude/architecture/<module-slug>.md`.
220
+ 2. If a map exists, read it BEFORE Step 3 — it surfaces the module's boundaries, internal structure, dependencies, and where-things-live landmarks, reducing broad file-system scans.
221
+ 3. If `.claude/architecture/` is absent or the module has no map, proceed without it (not a blocker).
222
+
223
+ See `.claude/context/architecture-map.md` for the full consultation contract. Unlike Step 2 (managed files only), this step fires for every round regardless of file type.
224
+
215
225
  ### Step 2.5: Search Before Creating
216
226
 
217
227
  For each file with action `create` in `files_to_modify`:
@@ -376,6 +376,11 @@ delegation_hint:
376
376
 
377
377
  Read `.claude/rules/*.md` and relevant architecture docs.
378
378
 
379
+ If `.claude/architecture/` contains map file(s) for the target module(s), read them before
380
+ finalizing scope — they provide pre-computed structural context (boundaries, dependencies,
381
+ landmarks) that reduces the need for broad file-system scans. See
382
+ `.claude/context/architecture-map.md` for the consultation contract.
383
+
379
384
  ### Phase 4: Clarify Requirements (Context-First)
380
385
 
381
386
  Before any AskUserQuestion call, check (1) `checkpoint.context`, (2) `task.context`, (3) codebase via Grep/Glob/Read. Only ask if all three fail. When asking, prefix with `Checked: [sources]. Not found. Asking: [question]`. If a question IS answered in context, use that answer directly — do not re-ask.
@@ -0,0 +1,204 @@
1
+ ---
2
+ scope: org-shared
3
+ ---
4
+
5
+ # Architecture Map Spec
6
+
7
+ Canonical format specification for the `codebyplan arch-map` engine. Both the
8
+ `cbp-map-architecture` agent and the `arch-map` CLI reference this file as the
9
+ authoritative definition of all artifact formats.
10
+
11
+ ---
12
+
13
+ ## Per-Module Map File
14
+
15
+ Location: `.claude/architecture/<module>.md`
16
+
17
+ Where `<module>` is a slug derived from the module path, e.g.:
18
+ - `apps/web` → `apps-web.md`
19
+ - `packages/codebyplan-package` → `packages-codebyplan-package.md`
20
+ - `backend` → `backend.md`
21
+ - `.github` → `dot-github.md` (a leading dot in the module path is normalized to `dot-` so the map file is never hidden; the manifest `path` keeps the leading dot for git drift)
22
+
23
+ ### YAML Frontmatter
24
+
25
+ Every map file MUST open with a YAML block containing these exact fields:
26
+
27
+ ```yaml
28
+ ---
29
+ module: <path> # Module root path relative to repo root (e.g. "apps/web")
30
+ generated_from_sha: <sha>|null # Full git commit SHA the map was produced from, or null if never stamped
31
+ depth: skeleton|deep # Map fidelity level (see Depth Levels below)
32
+ generated_at: <iso>|null # ISO 8601 UTC timestamp of last generation, or null
33
+ source_globs: # Glob patterns used to discover files for this map
34
+ - <glob>
35
+ - <glob>
36
+ ---
37
+ ```
38
+
39
+ **Field rules:**
40
+ - `module` is the canonical path — used as the key in `architecture.json` and INDEX.md rows.
41
+ - `generated_from_sha` is `null` until `codebyplan arch-map stamp` is run for the first time.
42
+ - `depth` must be exactly `skeleton` or `deep` — no other values are valid.
43
+ - `generated_at` is `null` until first generation; set to an ISO 8601 UTC string on each regeneration.
44
+ - `source_globs` lists the patterns actually used; empty array is valid for cross-cutting modules.
45
+
46
+ ### Depth Levels
47
+
48
+ **`skeleton`** — structural overview only. Covers sections 1–4 and 6–7 (excludes Data-flow traces).
49
+ Fast to generate; useful for unfamiliar or rarely-changed modules.
50
+
51
+ **`deep`** — full analysis including Data-flow traces (section 5). Costs more tokens; used when
52
+ the agent or developer needs end-to-end data-flow understanding.
53
+
54
+ ### The 7 Canonical Sections
55
+
56
+ Every map file MUST include all applicable sections in this order. Sections marked `[deep only]`
57
+ are omitted for `depth: skeleton` maps.
58
+
59
+ ```
60
+ ## 1. Boundaries & Responsibility
61
+ ## 2. Public Surface / Entry Points
62
+ ## 3. Internal Structure
63
+ ## 4. Dependencies (In / Out)
64
+ ## 5. Data-Flow Traces [deep only]
65
+ ## 6. Conventions
66
+ ## 7. Where-Things-Live Landmarks
67
+ ```
68
+
69
+ **Section guidance:**
70
+
71
+ **1. Boundaries & Responsibility**
72
+ One-paragraph statement of what this module owns and does NOT own. Include the decision
73
+ boundary (which concerns belong here vs. adjacent modules).
74
+
75
+ **2. Public Surface / Entry Points**
76
+ Exported functions, classes, components, API routes, CLI entry points, or RPC endpoints
77
+ that other modules may depend on. For each: name, type, brief purpose.
78
+
79
+ **3. Internal Structure**
80
+ Key directories and their roles. Package sub-folders, layers, major files that are not
81
+ part of the public surface. Use a flat list or nested bullets.
82
+
83
+ **4. Dependencies (In / Out)**
84
+ - **Consumes**: modules, packages, or services this module imports/calls.
85
+ - **Consumed by**: modules that import from this module's public surface.
86
+ Cross-module edges only — internal sub-folder imports are not listed here.
87
+
88
+ **5. Data-Flow Traces [deep only]**
89
+ 2–5 named traces showing data end-to-end through this module. Format per trace:
90
+ ```
91
+ ### <trace name>
92
+ Source → [step] → [step] → Sink
93
+ ```
94
+ Include key transforms, async boundaries, and error paths.
95
+
96
+ **6. Conventions**
97
+ Patterns specific to this module: naming rules, file layout expectations, linting configs,
98
+ framework conventions, testing approach.
99
+
100
+ **7. Where-Things-Live Landmarks**
101
+ Quick-lookup table or list for "where is X?" questions. List landmark paths and one-line
102
+ descriptions. Aimed at a developer who has never opened this module.
103
+
104
+ ---
105
+
106
+ ## INDEX.md
107
+
108
+ Location: `.claude/architecture/INDEX.md`
109
+
110
+ The INDEX.md is the grep-native registry of all module maps in this repo. Format mirrors
111
+ `vendor/INDEX.md` — one pipe-delimited row per module, designed so `grep <term> INDEX.md`
112
+ produces a readable hit.
113
+
114
+ ### Row Format
115
+
116
+ ```
117
+ | <module> | <depth> | <generated_from_sha_short> | <generated_at_date> | <map_file> |
118
+ ```
119
+
120
+ - `<module>` — the `module` frontmatter value (e.g. `apps/web`)
121
+ - `<depth>` — `skeleton` or `deep`
122
+ - `<generated_from_sha_short>` — first 8 chars of `generated_from_sha`, or `unset` if null
123
+ - `<generated_at_date>` — `YYYY-MM-DD` portion of `generated_at`, or `unset` if null
124
+ - `<map_file>` — relative path from `.claude/architecture/` (e.g. `apps-web.md`)
125
+
126
+ ### Header
127
+
128
+ ```markdown
129
+ # Architecture Map Index
130
+
131
+ Grep-friendly registry of per-module architecture maps. Layout convention in `context/architecture/arch-map-spec.md`.
132
+
133
+ | Module | Depth | SHA | Generated | Map File |
134
+ |--------|-------|-----|-----------|----------|
135
+ ```
136
+
137
+ Each module map added or updated MUST have a corresponding row upserted in INDEX.md.
138
+
139
+ ---
140
+
141
+ ## graph.md
142
+
143
+ Location: `.claude/architecture/graph.md`
144
+
145
+ Adjacency-list representation of cross-module dependency edges. Used for dependency impact
146
+ analysis ("if I change module X, what else might be affected?").
147
+
148
+ ### Format
149
+
150
+ ```markdown
151
+ # Architecture Dependency Graph
152
+
153
+ Adjacency list of cross-module edges. Each entry: `<from> -> <to>`.
154
+ Generated from the `Dependencies (In / Out)` sections of individual map files
155
+ (first-party `@codebyplan/*` workspace imports, verified against each module's `package.json`).
156
+
157
+ Scope: edges are TypeScript workspace package imports only. Runtime/service dependencies
158
+ (shared schema directories, HTTP calls between apps) are documented per-map in
159
+ `## 4. Dependencies (In / Out)` and are intentionally NOT graphed here — a module with
160
+ no edge is not necessarily isolated; consult its map file for runtime coupling.
161
+
162
+ ## Edges
163
+
164
+ <module-A> -> <module-B>
165
+ <module-A> -> <module-C>
166
+ <module-B> -> <module-D>
167
+ ```
168
+
169
+ **Rules:**
170
+ - One edge per line: `<from> -> <to>` (exact module path values from frontmatter).
171
+ - Edges are directed (A depends on B = A -> B).
172
+ - Edges ARE deduplicated at write time by `/cbp-map-architecture` — each unique `<from> -> <to>` pair appears exactly once in graph.md, regardless of how many map files declare the same dependency.
173
+ - The file is regenerated wholesale by both `/cbp-map-architecture` (full generation) and `/cbp-refresh-arch-map` (drift-scoped refresh) — it is not appended incrementally by the CLI (`arch-map status`/`drift` are read-only).
174
+ - Edges represent first-party `@codebyplan/*` TypeScript workspace package imports only, verified against each module's `package.json`. Runtime/service dependencies (shared schema directories, HTTP calls between apps) are intentionally NOT graphed — consult each module's `## 4. Dependencies (In / Out)` section for runtime coupling.
175
+
176
+ ---
177
+
178
+ ## architecture.json
179
+
180
+ Location: `.codebyplan/architecture.json`
181
+
182
+ The committed manifest tracking which modules have been mapped and their freshness state.
183
+ Written by `setup` (empty stub) and `config` (create-if-absent). Updated by
184
+ `codebyplan arch-map stamp`.
185
+
186
+ ### Schema
187
+
188
+ ```json
189
+ {
190
+ "version": 1,
191
+ "modules": [
192
+ {
193
+ "path": "apps/web",
194
+ "map_file": ".claude/architecture/apps-web.md",
195
+ "generated_from_sha": "abc12345def...",
196
+ "depth": "skeleton",
197
+ "generated_at": "2026-06-02T10:00:00.000Z"
198
+ }
199
+ ]
200
+ }
201
+ ```
202
+
203
+ The TypeScript types for this schema are `ArchitectureConfig` and `ArchitectureModuleEntry`
204
+ in `packages/codebyplan-package/src/lib/types.ts`.
@@ -0,0 +1,117 @@
1
+ ---
2
+ scope: org-shared
3
+ ---
4
+
5
+ # Architecture Map Consultation Contract
6
+
7
+ This file is the **consumer contract** for the `.claude/architecture/` per-module map
8
+ files: what the artifacts are, when to read them, how to parse them, and what to do when
9
+ they are absent. Artifact format spec is in `context/architecture/arch-map-spec.md`.
10
+
11
+ ## What the Architecture Map Is
12
+
13
+ A committed set of per-module `.md` files under `.claude/architecture/` that record the
14
+ structure, public surface, internal layout, dependencies, conventions, and landmarks of
15
+ each repository module. They are authored by the `cbp-map-architecture` agent and stamped
16
+ by the `codebyplan arch-map stamp` CLI.
17
+
18
+ | Artifact | Location | Purpose |
19
+ |----------|----------|---------|
20
+ | Per-module map | `.claude/architecture/<module-slug>.md` | Full analysis of one module |
21
+ | Index | `.claude/architecture/INDEX.md` | Grep-friendly registry of all mapped modules |
22
+ | Dependency graph | `.claude/architecture/graph.md` | Cross-module dependency edges (adjacency list) |
23
+
24
+ **Depth levels** (from the module's `depth:` frontmatter field):
25
+
26
+ | Level | Sections included | When used |
27
+ |-------|-------------------|-----------|
28
+ | `skeleton` | 1–4, 6–7 (no data-flow traces) | Structural overview, unfamiliar or rarely-changed modules |
29
+ | `deep` | 1–7 including data-flow traces | End-to-end understanding of active modules |
30
+
31
+ **Slug derivation**: `apps/web` → `apps-web.md`; `.github` → `dot-github.md` (leading dot
32
+ normalized to `dot-` so the map file is never hidden). The manifest `path` keeps the
33
+ leading dot for git drift tracking.
34
+
35
+ ## When To Consult
36
+
37
+ ### cbp-task-planner — Phase 3: Check Rules and Architecture
38
+
39
+ Before finalizing scope for the target module(s), check whether a map exists:
40
+
41
+ 1. Glob `.claude/architecture/<module-slug>.md` for each module in scope.
42
+ 2. If found, read the map file — sections 1–4 + 6–7 give structural context that reduces
43
+ the need for broad file-system scans; section 5 (deep maps) gives data-flow traces.
44
+ 3. Use the `## 4. Dependencies (In / Out)` section to identify cross-module impact that
45
+ the planner's Explore subagent might otherwise miss.
46
+
47
+ ### cbp-round-executor — Step 2.4: Architecture Map Consultation
48
+
49
+ Before editing files in a module, check whether a map exists:
50
+
51
+ 1. Glob `.claude/architecture/<module-slug>.md` for the module being edited.
52
+ 2. If found, read the relevant sections before making changes — `## 7. Where-Things-Live
53
+ Landmarks` is the fastest orientation; `## 3. Internal Structure` disambiguates layout.
54
+ 3. The map is a pre-computed index — reading it replaces N individual file-reads for the
55
+ same structural signal.
56
+
57
+ ## How To Read
58
+
59
+ ```bash
60
+ # Check whether a map exists for a module
61
+ Glob: .claude/architecture/<module-slug>.md
62
+
63
+ # Read the map
64
+ Read: .claude/architecture/<module-slug>.md
65
+
66
+ # Browse all mapped modules
67
+ Read: .claude/architecture/INDEX.md
68
+
69
+ # Inspect cross-module dependencies
70
+ Read: .claude/architecture/graph.md
71
+ ```
72
+
73
+ Parse sections per the spec in `context/architecture/arch-map-spec.md`:
74
+ the 7 canonical section headings are `## 1. Boundaries & Responsibility` through
75
+ `## 7. Where-Things-Live Landmarks`. A `skeleton` map omits `## 5. Data-Flow Traces`.
76
+
77
+ YAML frontmatter fields: `module`, `generated_from_sha`, `depth`, `generated_at`,
78
+ `source_globs`. Check `generated_from_sha` against HEAD if you need to know whether the
79
+ map is stale (or run `codebyplan arch-map drift`).
80
+
81
+ ## If No Map Exists
82
+
83
+ The map is **not a prerequisite** — its absence is NOT a blocker for planning or execution.
84
+
85
+ - Proceed with the standard file-system analysis (Explore subagent / Read + Grep).
86
+ - Optionally note in your output that `/cbp-map-architecture --module <path>` would
87
+ pre-compute structural context for future rounds.
88
+ - Do NOT fail or block solely because a map is missing.
89
+
90
+ ## Agent Consumption Contract
91
+
92
+ | Agent | Phase / Step | Action |
93
+ |-------|-------------|--------|
94
+ | `cbp-task-planner` | Phase 3 — Check Rules and Architecture | Glob for map; read if present before finalizing scope |
95
+ | `cbp-round-executor` | Step 2.4 — Architecture Map Consultation | Glob for map; read if present before editing files in module |
96
+
97
+ Both agents follow the same read-or-skip pattern: Glob → if found, Read → use signal;
98
+ if absent, continue without blocking.
99
+
100
+ ## What This File Is NOT
101
+
102
+ - Not the artifact format spec — that is `context/architecture/arch-map-spec.md`.
103
+ - Not how to generate maps — use `/cbp-map-architecture` (map all/selected modules).
104
+ - Not how to refresh stale maps — use `/cbp-refresh-arch-map` (drift-scoped refresh).
105
+ - Not a substitute for reading the actual source files — the map is a pre-computed index,
106
+ not a replacement for code inspection when fine-grained detail is needed.
107
+
108
+ ## Related
109
+
110
+ | Concern | Reference |
111
+ |---------|-----------|
112
+ | Artifact format spec | `context/architecture/arch-map-spec.md` |
113
+ | Generate / regenerate maps | `/cbp-map-architecture` skill |
114
+ | Refresh only drifted modules | `/cbp-refresh-arch-map` skill (TASK-3) |
115
+ | CLI subcommands | `codebyplan arch-map status \| drift \| stamp` |
116
+ | Always-loaded pointer rule | `.claude/rules/architecture-map.md` |
117
+ | Loading rule registration | `.claude/rules/context-file-loading.md` |
@@ -48,9 +48,10 @@ esac
48
48
  FILENAME=$(basename "$FILE_PATH" ".$EXT")
49
49
 
50
50
  if match_path '^/(\.claude|docs)/'; then
51
- # Skip special naming patterns (SKILL/AGENT/CLAUDE/MEMORY/TASK-N/CHK-NNN/date/week-N/research phase/README)
51
+ # Skip special naming patterns (SKILL/AGENT/CLAUDE/MEMORY/TASK-N/CHK-NNN/date/week-N/research phase/README/INDEX)
52
52
  # CHK formats: CHK-001 (generic) or CHK-H001/CHK-A001/CHK-B001 (launch: Homepage/Application/Backdoor)
53
- if ! echo "$FILENAME" | grep -qE '^(SKILL|AGENT|CLAUDE|MEMORY|TASK-[1-9]|[0-9]{2}-[0-9]{2}-[0-9]{2}-CHK-([0-9]{3}|[HAB][0-9]{3})|CHK-([0-9]{3}|[HAB][0-9]{3})|[0-9]{2}-[0-9]{2}-[0-9]{2}|week-[0-9]+|[1-8]-|README)'; then
53
+ # INDEX: grep-native registry filename used by the architecture-map pipeline (.claude/architecture/INDEX.md) and vendor docs
54
+ if ! echo "$FILENAME" | grep -qE '^(SKILL|AGENT|CLAUDE|MEMORY|TASK-[1-9]|[0-9]{2}-[0-9]{2}-[0-9]{2}-CHK-([0-9]{3}|[HAB][0-9]{3})|CHK-([0-9]{3}|[HAB][0-9]{3})|[0-9]{2}-[0-9]{2}-[0-9]{2}|week-[0-9]+|[1-8]-|README|INDEX)'; then
54
55
  if echo "$FILENAME" | grep -qE '[A-Z]|_'; then
55
56
  block "Filename must be kebab-case (lowercase with hyphens)" "Got: $FILENAME, Expected: $(echo "$FILENAME" | tr '[:upper:]' '[:lower:]' | tr '_' '-')"
56
57
  fi
@@ -0,0 +1,30 @@
1
+ ---
2
+ scope: org-shared
3
+ ---
4
+
5
+ # Architecture Map
6
+
7
+ When `.claude/architecture/` exists in this repo, per-module map files may be present.
8
+
9
+ ## Rule
10
+
11
+ - Before analyzing or editing files in a module, Glob `.claude/architecture/<module-slug>.md`.
12
+ - If a map file exists, read it before proceeding — it provides pre-computed structural
13
+ context (boundaries, public surface, internal layout, dependencies, landmarks) that
14
+ reduces the need for broad file-system scans.
15
+ - Map absence is **not a blocker** — continue with standard file-system analysis when no
16
+ map exists.
17
+ - The full consultation contract (when to read, how to parse, agent phases) is at
18
+ `.claude/context/architecture-map.md`.
19
+
20
+ ## Why
21
+
22
+ Architecture maps are pre-computed indexes of module structure. Reading one replaces
23
+ several individual file-reads and surfaces cross-module impact that point-in-time grep
24
+ may miss. A 10-second read prevents a scoping gap.
25
+
26
+ ## Generate / Refresh
27
+
28
+ - `/cbp-map-architecture` — generate or regenerate maps for all/selected modules.
29
+ - `/cbp-refresh-arch-map` — drift-scoped refresh (re-runs only stale modules).
30
+ - `codebyplan arch-map status` — list modules and their map freshness.
@@ -23,6 +23,9 @@ paths:
23
23
  | `context/testing/eslint.md` | `cbp-improve-round` | Phase 1.5 | Config-file compliance audit |
24
24
  | `context/mcp-docs.md` | `cbp-task-planner` | Phase 2.6 | MCP library doc lookup contract — per-dependency consultation via DocsByPlan MCP tools (resolve_library_id → search_chunks/lookup_symbol → get_chunk) |
25
25
  | `context/mcp-docs.md` | `cbp-round-executor` | Step 3.4 | Library-specific reference — pre-write API verification via DocsByPlan MCP tools |
26
+ | `context/architecture/arch-map-spec.md` | `cbp-map-architecture` | Entry | Canonical architecture-map artifact format — per-module frontmatter + sections, INDEX.md row format, dependency-graph format |
27
+ | `context/architecture-map.md` | `cbp-task-planner` | Phase 3 | Architecture map consultation contract — when + how to read per-module maps before finalizing scope |
28
+ | `context/architecture-map.md` | `cbp-round-executor` | Step 2.4 | Architecture map consultation contract — when + how to read per-module maps before editing files |
26
29
  | `rules/parallel-waves.md` | `cbp-task-planner` | Phase 5.6 | Wave schema, invariants (3..15 file-count), and the proximity-split algorithm (a `rules/` file, not `context/**`; listed here for consumer discoverability) |
27
30
 
28
31
  New context files MUST be added here in the same change that introduces the consumer — or the file is orphan infrastructure.
@@ -80,7 +80,7 @@ Skills that delete Supabase branches MUST:
80
80
 
81
81
  1. Verify the branch name matches the feat branch being removed (never delete by
82
82
  `project_ref` alone).
83
- 2. Never delete the parent/production project (`rrvtrumtkhrsbhcyrwvf`) itself.
83
+ 2. Never delete the branch where `is_default` is true in the `list_branches` response (the parent/production branch) or any other persistent/long-lived branch.
84
84
  3. Never delete a persistent/long-lived branch that does not correspond to the git branch
85
85
  being torn down.
86
86
 
@@ -110,7 +110,9 @@
110
110
  "Skill(cbp-git-commit)",
111
111
  "Skill(cbp-git-worktree-create)",
112
112
  "Skill(cbp-git-worktree-remove)",
113
+ "Skill(cbp-map-architecture)",
113
114
  "Skill(cbp-merge-main)",
115
+ "Skill(cbp-refresh-arch-map)",
114
116
  "Skill(cbp-refresh-infra)",
115
117
  "Skill(cbp-round-check)",
116
118
  "Skill(cbp-round-end)",
@@ -199,7 +201,9 @@
199
201
  "Bash(codebyplan bump:*)",
200
202
  "Bash(npx codebyplan bump:*)",
201
203
  "Bash(codebyplan scaffold-publish-workflow:*)",
202
- "Bash(npx codebyplan scaffold-publish-workflow:*)"
204
+ "Bash(npx codebyplan scaffold-publish-workflow:*)",
205
+ "Bash(codebyplan arch-map:*)",
206
+ "Bash(npx codebyplan arch-map:*)"
203
207
  ]
204
208
  },
205
209
  "attribution": {
@@ -166,12 +166,13 @@ Only after both the local and remote git delete above succeed, run a conditional
166
166
 
167
167
  > Lifecycle contract: see [[supabase-branch-lifecycle]].
168
168
 
169
- - Call `mcp__supabase__list_branches` with `project_id: rrvtrumtkhrsbhcyrwvf`.
169
+ - Resolve the parent project ref: read `.codebyplan/shipment.json` `.shipment.surfaces.supabase.project_ref`; if absent or empty, read the first line of `supabase/.temp/project-ref`. Use that resolved ref as the `project_id`.
170
+ - Call `mcp__supabase__list_branches` with the resolved `project_id`.
170
171
  - Scan the returned list for an entry whose `name` exactly equals `$BRANCH`.
171
172
  - If found: call `mcp__supabase__delete_branch` with its `branch_id`. Record the branch name in `SUPABASE_BRANCHES_DELETED[]`.
172
173
  - If not found: no-op silently — the GitHub integration may have already removed it on PR close; not-found is success, NOT an error.
173
174
  - If the `list_branches` call itself fails (network, auth, or a non-success response — distinct from a successful lookup that returns no match): emit a non-blocking warning that the Supabase preview branch for `$BRANCH` may still exist and should be verified in the dashboard. Do not treat an API failure as a not-found success.
174
- - Never delete the parent project `rrvtrumtkhrsbhcyrwvf` itself or any persistent/production branch.
175
+ - Never delete the branch where `is_default` is true in the `list_branches` response (the production/parent project branch) or any other persistent/long-lived branch.
175
176
 
176
177
  Accumulate all Supabase branch names removed across the loop in `SUPABASE_BRANCHES_DELETED`.
177
178
 
@@ -198,11 +199,13 @@ git push origin --delete "$FEAT_BRANCH"
198
199
 
199
200
  After the feat branch git delete, run the same conditional Supabase teardown for `$FEAT_BRANCH`:
200
201
 
201
- - Call `mcp__supabase__list_branches` with `project_id: rrvtrumtkhrsbhcyrwvf`.
202
+ - Resolve the parent project ref: read `.codebyplan/shipment.json` `.shipment.surfaces.supabase.project_ref`; if absent or empty, read the first line of `supabase/.temp/project-ref`. Use that resolved ref as the `project_id`.
203
+ - Call `mcp__supabase__list_branches` with the resolved `project_id`.
202
204
  - Scan for an entry whose `name` exactly equals `$FEAT_BRANCH`.
203
205
  - If found: call `mcp__supabase__delete_branch` with its `branch_id`. Add `$FEAT_BRANCH` to `SUPABASE_BRANCHES_DELETED[]`.
204
206
  - If not found: no-op silently — idempotent, not-found is success.
205
207
  - If the `list_branches` call itself fails (network, auth, or a non-success response — distinct from a successful lookup that returns no match): emit a non-blocking warning that the Supabase preview branch for `$FEAT_BRANCH` may still exist and should be verified in the dashboard. Do not treat an API failure as a not-found success.
208
+ - Never delete the branch where `is_default` is true in the `list_branches` response (the production/parent project branch) or any other persistent/long-lived branch.
206
209
 
207
210
  ### Step 10: Save Shipment Results and Summary
208
211
 
@@ -135,12 +135,13 @@ After the git branch delete succeeds, run a conditional Supabase preview-branch
135
135
 
136
136
  > Lifecycle contract: see [[supabase-branch-lifecycle]].
137
137
 
138
- - Call `mcp__supabase__list_branches` with `project_id: rrvtrumtkhrsbhcyrwvf`.
138
+ - Resolve the parent project ref: read `.codebyplan/shipment.json` `.shipment.surfaces.supabase.project_ref`; if absent or empty, read the first line of `supabase/.temp/project-ref`. Use that resolved ref as the `project_id`.
139
+ - Call `mcp__supabase__list_branches` with the resolved `project_id`.
139
140
  - Scan the returned list for an entry whose `name` exactly equals `$BRANCH_NAME`.
140
141
  - If found: call `mcp__supabase__delete_branch` with its `branch_id`. Report "Supabase preview branch deleted: `$BRANCH_NAME`".
141
142
  - If not found: no-op silently — the GitHub integration may have already removed it on PR close; not-found is success, NOT an error.
142
143
  - If the `list_branches` call itself fails (network, auth, or a non-success response — distinct from a successful lookup that returns no match): emit a non-blocking warning that the Supabase preview branch for `$BRANCH_NAME` may still exist and should be verified in the dashboard. Do not treat an API failure as a not-found success.
143
- - Never delete the parent project `rrvtrumtkhrsbhcyrwvf` itself or any persistent/production branch.
144
+ - Never delete the branch where `is_default` is true in the `list_branches` response (the production/parent project branch) or any other persistent/long-lived branch.
144
145
 
145
146
  ### Step 10: Show Result
146
147