claudeos-core 2.1.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +1649 -481
  2. package/CONTRIBUTING.md +92 -92
  3. package/README.de.md +64 -5
  4. package/README.es.md +64 -5
  5. package/README.fr.md +64 -5
  6. package/README.hi.md +64 -5
  7. package/README.ja.md +64 -5
  8. package/README.ko.md +1018 -959
  9. package/README.md +1020 -960
  10. package/README.ru.md +66 -5
  11. package/README.vi.md +1019 -960
  12. package/README.zh-CN.md +64 -5
  13. package/bin/cli.js +152 -148
  14. package/bin/commands/init.js +1673 -1518
  15. package/bin/commands/lint.js +62 -0
  16. package/bin/commands/memory.js +438 -438
  17. package/bin/lib/cli-utils.js +206 -206
  18. package/claude-md-validator/index.js +184 -0
  19. package/claude-md-validator/reporter.js +66 -0
  20. package/claude-md-validator/structural-checks.js +528 -0
  21. package/content-validator/index.js +666 -436
  22. package/lib/env-parser.js +317 -0
  23. package/lib/expected-guides.js +23 -23
  24. package/lib/expected-outputs.js +90 -90
  25. package/lib/language-config.js +35 -35
  26. package/lib/memory-scaffold.js +1058 -1052
  27. package/lib/plan-parser.js +165 -165
  28. package/lib/staged-rules.js +118 -118
  29. package/manifest-generator/index.js +174 -174
  30. package/package.json +90 -87
  31. package/pass-json-validator/index.js +337 -337
  32. package/pass-prompts/templates/angular/pass3.md +28 -13
  33. package/pass-prompts/templates/common/claude-md-scaffold.md +686 -0
  34. package/pass-prompts/templates/common/pass3-footer.md +402 -39
  35. package/pass-prompts/templates/common/pass3b-core-header.md +43 -0
  36. package/pass-prompts/templates/common/pass4.md +375 -302
  37. package/pass-prompts/templates/common/staging-override.md +26 -26
  38. package/pass-prompts/templates/java-spring/pass3.md +31 -21
  39. package/pass-prompts/templates/kotlin-spring/pass3.md +34 -22
  40. package/pass-prompts/templates/node-express/pass3.md +30 -21
  41. package/pass-prompts/templates/node-fastify/pass3.md +28 -14
  42. package/pass-prompts/templates/node-nestjs/pass3.md +29 -14
  43. package/pass-prompts/templates/node-nextjs/pass3.md +34 -21
  44. package/pass-prompts/templates/node-vite/pass1.md +117 -117
  45. package/pass-prompts/templates/node-vite/pass2.md +78 -78
  46. package/pass-prompts/templates/node-vite/pass3.md +30 -13
  47. package/pass-prompts/templates/python-django/pass3.md +32 -21
  48. package/pass-prompts/templates/python-fastapi/pass3.md +33 -21
  49. package/pass-prompts/templates/python-flask/pass1.md +119 -119
  50. package/pass-prompts/templates/python-flask/pass2.md +85 -85
  51. package/pass-prompts/templates/python-flask/pass3.md +31 -13
  52. package/pass-prompts/templates/vue-nuxt/pass3.md +32 -13
  53. package/plan-installer/domain-grouper.js +76 -76
  54. package/plan-installer/index.js +137 -129
  55. package/plan-installer/prompt-generator.js +188 -128
  56. package/plan-installer/scanners/scan-frontend.js +505 -473
  57. package/plan-installer/scanners/scan-java.js +226 -226
  58. package/plan-installer/scanners/scan-node.js +57 -57
  59. package/plan-installer/scanners/scan-python.js +85 -85
  60. package/plan-installer/stack-detector.js +482 -466
  61. package/plan-installer/structure-scanner.js +65 -65
  62. package/sync-checker/index.js +177 -177
@@ -1,302 +1,375 @@
1
- # Pass 4 — L4 Memory & Feedback Layer
2
-
3
- You are generating the initial scaffolding for the L4 Memory layer on top of the
4
- existing ClaudeOS-Core output. Read these two files to understand the project:
5
-
6
- - `{{PROJECT_ROOT}}/claudeos-core/generated/project-analysis.json`
7
- - `{{PROJECT_ROOT}}/claudeos-core/generated/pass2-merged.json`
8
-
9
- Then generate the files listed below **exactly as specified**. Do NOT invent
10
- additional files. Do NOT modify existing Pass 3 output in `standard/`, `skills/`,
11
- `guide/`, `plan/`, `database/`, `mcp-guide/`.
12
-
13
- You **WILL** create new rule files in `.claude/rules/60.memory/`,
14
- and **append** a new section to the existing `CLAUDE.md`.
15
-
16
- **Language rule:** All generated content (rule descriptions, CLAUDE.md append section,
17
- compaction categories, decision-log seeds) must be written in **{{LANG_NAME}}**.
18
- Frontmatter keys (`name`, `paths`) and file paths remain in English.
19
-
20
- Memory scaffold files (sections 1–4) follow these rules:
21
- - **Headings and description text** may be written in **{{LANG_NAME}}**.
22
- - **CLI-parsed keywords MUST remain in English** (the CLI parses these literally):
23
- - `## Last Compaction` (compaction.md section heading)
24
- - `frequency:`, `importance:`, `last seen:` (failure-patterns.md field keys)
25
- - `fix` or `solution` (failure-patterns.md fix line detection)
26
- - **Title lines** (`# Decision Log`, `# Failure Patterns`, etc.) may be translated.
27
- - **Instructional text** should be translated.
28
-
29
- ---
30
-
31
- ## Required output L4 Memory (`{{PROJECT_ROOT}}/claudeos-core/memory/`)
32
-
33
- ### 1. `memory/decision-log.md`
34
- Start with the template below, then **append 3–5 seed entries** extracted from
35
- `pass2-merged.json` that represent foundational architectural decisions already
36
- made in this codebase. Each seed entry must be grounded in evidence from
37
- pass2-merged.json do NOT invent decisions.
38
- Write the **title** (`# Decision Log`), the **descriptive italics** below it, and the seed entry **body text** in **{{LANG_NAME}}**. Keep the format specification's inline code literal (`## YYYY-MM-DD — <Title>`, `Context / Options / Decision / Consequences`).
39
-
40
- Template header (translate the title and italics):
41
- ```markdown
42
- # Decision Log
43
-
44
- _Permanent record of "why" behind design choices. Append-only._
45
- _Format: `## YYYY-MM-DD <Title>` then Context / Options / Decision / Consequences._
46
- ```
47
-
48
- Seed entry format (for each of the 3–5 seeds, dated today in `YYYY-MM-DD` format
49
- — use the current UTC date; do NOT leave a literal placeholder):
50
- ```markdown
51
- ## <YYYY-MM-DD> <Short title of the architectural choice>
52
-
53
- - **Context:** <what in pass2-merged.json this is grounded on>
54
- - **Options considered:** <optional list if pass2-merged mentions alternatives>
55
- - **Decision:** <the pattern observed>
56
- - **Consequences:** <what this locks in for future work>
57
- ```
58
-
59
- ### 2. `memory/failure-patterns.md`
60
- Write the title and descriptive italics in **{{LANG_NAME}}**. Keep CLI commands (`npx claudeos-core memory score`) literal. In the `_Format:` italics line, keep the format keywords `Frequency`, `Last Seen`, `Importance`, `Fix` literal in English (these names reappear as parsed field keys `frequency:`, `last seen:`, `importance:`, `fix:` in actual entries, and the memory CLI parser depends on that spelling surviving). Baseline template (translate the prose parts):
61
-
62
- ```markdown
63
- # Failure Patterns
64
-
65
- _Recurring errors and their fixes. Importance auto-scored by `npx claudeos-core memory score`._
66
- _Format: `## <pattern-id>` with Frequency / Last Seen / Importance / Fix._
67
- ```
68
-
69
- Do NOT add any seed entries — this file fills up as failures are encountered.
70
-
71
- ### 3. `memory/compaction.md`
72
- Write the full compaction strategy document. Adapt it to this project:
73
- - Include a "Project-specific error categories" section listing 2–4 categories
74
- based on the detected stack (e.g., for Kotlin: "Kotlin compilation errors",
75
- "Gradle build failures"; for Python: "Import errors", "Virtualenv drift").
76
- - Write the project-specific categories section in **{{LANG_NAME}}**.
77
-
78
- **Translate into {{LANG_NAME}}**: the title (`# Compaction Strategy`), descriptive italics, all `##`/`###` section headings (`Preservation Priority`, `Stages`, `Stage 1 — Summarize aged entries`, `Stage 2 — Merge duplicate patterns`, `Stage 3 — Drop low-importance entries`, `Stage 4 — Enforce file size cap`, `Project-specific error categories`), and the prose explanations under each heading (including bullet-point explanations like "Keep: pattern-id, frequency, one-line fix summary").
79
-
80
- **Keep literal (do NOT translate)**: the `## Last Compaction` heading (CLI-parsed verbatim), all inline code values (`importance >= 7`, `lastSeen`, `frequency = sum`, `fix`, `rule-manifest.json`, `decision-log.md`, `failure-patterns.md`), and all CLI commands (`npx claudeos-core memory compact`).
81
-
82
- Baseline template (translate per above, then append the project-specific section at the end):
83
- ```markdown
84
- # Compaction Strategy
85
-
86
- _4-stage compaction rules for `decision-log.md` and `failure-patterns.md`._
87
- _Run via `npx claudeos-core memory compact`._
88
-
89
- ## Preservation Priority
90
- Entries are preserved if ANY of:
91
- - `importance >= 7`
92
- - `lastSeen` within 30 days
93
- - Referenced by an active rule (path listed in rule-manifest.json)
94
-
95
- ## Stages
96
-
97
- ### Stage 1 Summarize aged entries
98
- Entries older than 30 days with no recent reference are summarized:
99
- - Keep: pattern-id, frequency, one-line fix summary
100
- - Drop: verbose context, full stack traces
101
-
102
- ### Stage 2 — Merge duplicate patterns
103
- Failure entries with the same root cause are merged:
104
- - `frequency = sum`
105
- - `lastSeen = max`
106
- - `fix` unified to the most recent working solution
107
-
108
- ### Stage 3 Drop low-importance entries
109
- Entries with `importance < 3` AND `lastSeen > 60 days` are removed.
110
-
111
- ### Stage 4 — Enforce file size cap
112
- Each target file is capped at 400 lines.
113
- When exceeded, the oldest (by `lastSeen`) low-importance entries are dropped first.
114
-
115
- ## Project-specific error categories
116
- <2–4 categories based on the detected stack, written in {{LANG_NAME}}>
117
-
118
- ## Last Compaction
119
- (never run `npx claudeos-core memory compact`)
120
- ```
121
-
122
- ### 4. `memory/auto-rule-update.md`
123
- Write the title, descriptive italics, "How to apply" heading, the 3 how-to-apply steps, the "Proposals" heading, and the placeholder line in **{{LANG_NAME}}**. Keep CLI commands (`npx claudeos-core memory propose-rules`), file references (`decision-log.md`), and inline code literal. Baseline template (translate the prose parts):
124
-
125
- ```markdown
126
- # Auto Rule Update Proposals
127
-
128
- _Generated by `npx claudeos-core memory propose-rules`._
129
- _Each proposal: failure pattern → affected rule → diff → confidence._
130
-
131
- ## How to apply
132
- 1. Review each proposal below.
133
- 2. If accepted, edit the affected rule file and commit.
134
- 3. Move the accepted proposal into `decision-log.md` as a record.
135
-
136
- ## Proposals
137
- (none yet — run `npx claudeos-core memory propose-rules` after accumulating failure patterns)
138
- ```
139
-
140
- ---
141
-
142
- ## Required output Rules (`.claude/rules/`)
143
-
144
- Generate 6 rule files. Each file must include YAML frontmatter (`name`, `paths`) and markdown body.
145
- **Frontmatter values stay in English; all body text (bullet points, descriptions, section headings like `## Reference`) MUST be written in {{LANG_NAME}}.** Keep literal in English: file paths, CLI commands, inline code (`` `...` ``), and the CLI-parsed field names (`frequency:`, `last seen:`, `importance:`, `fix:`) when they appear in examples.
146
-
147
- ### 5. `.claude/rules/00.core/51.doc-writing-rules.md`
148
- Frontmatter: `name: Document Writing Rules`, `paths: ["**/*"]`
149
- Body (write in **{{LANG_NAME}}**) must cover:
150
- - [CRITICAL] Rules file paths frontmatter required every `.claude/rules/` file must have `paths` in frontmatter, do not propose narrowing `**/*` to specific patterns
151
- - [CRITICAL] No domain-specific or path hardcoding in rules; use generic placeholder patterns
152
- - [CRITICAL] Code examples must mirror actual project structure (verify directory paths before writing examples)
153
- - Topic repetition across rules/standard is intentional reinforcement, not duplication
154
- - Planned references (paths that don't yet exist) are forward declarations; do not flag them as missing
155
- - `## Reference` section at the end linking to corresponding standard files
156
-
157
- ### 6. `.claude/rules/00.core/52.ai-work-rules.md`
158
- Frontmatter: `name: AI Work Rules`, `paths: ["**/*"]`
159
- Body (write in **{{LANG_NAME}}**) must cover:
160
- - Accuracy over token saving; verify before claiming
161
- - 13 hallucination prevention patterns (see memory-scaffold static fallback for reference list)
162
- - No unsolicited suggestions; ask when unsure
163
- - Memory vs Rules no duplication judgment (Memory is on-demand, Rules are auto-loaded)
164
- - Planned references — no "missing" judgment
165
- - Code/document generation accuracy — check actual source before guessing field names
166
-
167
- ### 7. `.claude/rules/60.memory/01.decision-log.md`
168
- Frontmatter: `name: Decision Log`, `paths: ["claudeos-core/memory/decision-log.md"]`
169
- Body (write in **{{LANG_NAME}}**): read timing (session start + before architectural changes), write timing
170
- (competing patterns / library choice / convention / NOT doing something),
171
- entry format (ISO date heading + Context / Options / Decision / Consequences),
172
- append-only rule.
173
-
174
- ### 8. `.claude/rules/60.memory/02.failure-patterns.md`
175
- Frontmatter: `name: Failure Patterns`, `paths: ["claudeos-core/memory/failure-patterns.md"]`
176
- Body (write in **{{LANG_NAME}}**): read timing (session start + encountering an error), write timing (2nd occurrence +
177
- non-obvious root cause + undocumented workaround), entry format with
178
- **frequency**, **last seen**, **symptoms**, **root cause**, **fix** fields (keep these field names literal in English when showing example entries; prose explanations around them translate).
179
- Never delete entries manually use `npx claudeos-core memory compact`.
180
-
181
- ### 9. `.claude/rules/60.memory/03.compaction.md`
182
- Frontmatter: `name: Compaction Strategy`, `paths: ["claudeos-core/memory/compaction.md"]`
183
- Body (write in **{{LANG_NAME}}**): reference to the 4 stages and preservation rules. Do NOT edit unless intentionally
184
- changing the compaction policy; do NOT run compaction logic manually — always use the CLI.
185
-
186
- ### 10. `.claude/rules/60.memory/04.auto-rule-update.md`
187
- Frontmatter: `name: Auto Rule Update`, `paths: ["claudeos-core/memory/auto-rule-update.md"]`
188
- Body (write in **{{LANG_NAME}}**): machine-generated proposals; review → accept → edit rule → record in decision-log.
189
- Proposals with confidence >= 0.70 deserve serious consideration. Do NOT edit proposals directly.
190
-
191
- ---
192
-
193
- ## Required output CLAUDE.md append
194
-
195
- ### 11. Append a new section to existing `CLAUDE.md`
196
-
197
- Do NOT overwrite existing CLAUDE.md content — **append only** at the end.
198
- The new section must include the `(L4)` marker in its top heading (the marker
199
- is language-independent so the CLI fallback can detect it). For example, English:
200
- `## Memory (L4)`, Korean: `## 메모리 (L4)`.
201
-
202
- Include:
203
- - Common rules table (references to `00.core/51.doc-writing-rules.md` and `52.ai-work-rules.md`)
204
- - L4 Memory table with 4 files (decision-log, failure-patterns, compaction, auto-rule-update)
205
- — include Purpose and Action columns
206
- - Memory workflow (6 numbered steps: scan failure-patterns at session start →
207
- skim recent decision-log record decisions record repeat errors
208
- periodic `memory compact` → review `auto-rule-update.md` proposals)
209
-
210
- Write this section in **{{LANG_NAME}}**, but keep the `(L4)` heading marker,
211
- file paths, and CLI command names in English.
212
-
213
- ---
214
-
215
- ## Required output Standard (`{{PROJECT_ROOT}}/claudeos-core/standard/00.core/`)
216
-
217
- ### 12. `claudeos-core/standard/00.core/XX.doc-writing-guide.md`
218
- Scan `claudeos-core/standard/00.core/` for existing numbered files. Use the **next sequential number**
219
- (e.g., if `01`, `02`, `03` exist, create `04.doc-writing-guide.md`).
220
-
221
- This is the **detailed guide** corresponding to `.claude/rules/00.core/51.doc-writing-rules.md`.
222
- Write entirely in **{{LANG_NAME}}**.
223
-
224
- Body must cover:
225
- 1. **Document layer structure** table with Layer/Path/Role/Loading for CLAUDE.md, Rules, Standard, Skills, Memory. Include a relationship diagram showing CLAUDE.md → Rules → Standard flow.
226
- 2. **Rules file writing rules** — paths frontmatter required, paths scope settings table, file structure template with `## Reference` section. Do not propose narrowing `**/*`.
227
- 3. **Standard file writing rules** — long files are normal, file naming (`number.name.md`), register in `00.standard-reference.md`.
228
- 4. **Skills file writing rules** — MANIFEST.md registration, paths frontmatter in generated rules, verify reference paths.
229
- 5. **Planned references** paths that don't yet exist are forward declarations. Do not label as missing/stale/dead.
230
- 6. **Multi-layer defensive rule placement is intentional** repetition across Rules files is reinforcement, not duplication. Do not propose consolidation.
231
- 7. **Topic repetition is not duplication** same topic in CLAUDE.md + Rules + Standard serves different layer/domain roles. Trivial expression differences are not inconsistency risks.
232
- 8. **No domain-specific hardcoding** use generic placeholder patterns.
233
- 9. **No system absolute path hardcoding** use relative paths, include ❌/✅ examples.
234
- 10. **Code examples must follow project conventions** verify directory structure, follow project naming conventions.
235
- 11. **Change synchronization procedure**table showing Standard→Rules, Rules→Standard (verify `## Reference` link), Skills→MANIFEST sync targets.
236
-
237
- ---
238
-
239
- ## Completion marker
240
-
241
- After all files are written, create:
242
-
243
- `{{PROJECT_ROOT}}/claudeos-core/generated/pass4-memory.json`
244
-
245
- ```json
246
- {
247
- "analyzedAt": "<ISO timestamp>",
248
- "passNum": 4,
249
- "memoryFiles": [
250
- "claudeos-core/memory/decision-log.md",
251
- "claudeos-core/memory/failure-patterns.md",
252
- "claudeos-core/memory/compaction.md",
253
- "claudeos-core/memory/auto-rule-update.md"
254
- ],
255
- "ruleFiles": [
256
- ".claude/rules/00.core/51.doc-writing-rules.md",
257
- ".claude/rules/00.core/52.ai-work-rules.md",
258
- ".claude/rules/60.memory/01.decision-log.md",
259
- ".claude/rules/60.memory/02.failure-patterns.md",
260
- ".claude/rules/60.memory/03.compaction.md",
261
- ".claude/rules/60.memory/04.auto-rule-update.md"
262
- ],
263
- "standardFiles": [
264
- "claudeos-core/standard/00.core/XX.doc-writing-guide.md"
265
- ],
266
- "claudeMdAppended": true,
267
- "seededDecisions": <integer count of seed entries written to decision-log.md>
268
- }
269
- ```
270
-
271
- ---
272
-
273
- ## Guardrails
274
-
275
- - Do NOT modify existing Pass 3 output files in `claudeos-core/standard/` (except adding the new doc-writing-guide),
276
- `claudeos-core/skills/`, `claudeos-core/guide/`, `claudeos-core/database/`,
277
- `claudeos-core/mcp-guide/`.
278
- - Do NOT modify existing `.claude/rules/00.core/00.*` through `.claude/rules/00.core/02.*` files (Pass 3 output).
279
- - Do NOT modify existing `.claude/rules/10.backend/` through `.claude/rules/50.sync/` files.
280
- - DO create `.claude/rules/00.core/51.doc-writing-rules.md` and `.claude/rules/00.core/52.ai-work-rules.md` (Pass 4 output).
281
- - DO create `claudeos-core/standard/00.core/XX.doc-writing-guide.md` with the next sequential number (Pass 4 output).
282
- - Do NOT overwrite existing CLAUDE.md content **append only**.
283
- - Do NOT translate CLI-parsed keywords in memory files: `## Last Compaction`, `frequency:`, `importance:`, `last seen:`, `fix`, `solution`.
284
- - DO translate all other text in memory files (titles, descriptions, instructions) into **{{LANG_NAME}}**.
285
- - DO write rule files (sections 5–10), standard file (section 13), and CLAUDE.md append section in **{{LANG_NAME}}**.
286
- - Keep seed decision-log entries **grounded** in pass2-merged.json only. No hallucination.
287
- - Use the current date (UTC, YYYY-MM-DD) for dated headings — substitute the real date,
288
- never leave `<YYYY-MM-DD>` or any placeholder-looking token as literal text.
289
-
290
- ---
291
-
292
- ## Output discipline (CRITICAL)
293
-
294
- Do your work by writing files with the Write tool. When you finish, **end the conversation with a single short line only** — specifically:
295
-
296
- ```
297
- Pass 4 complete.
298
- ```
299
-
300
- Do NOT print a summary of what you created. Do NOT list the files you wrote. Do NOT report files that you "failed" to write because of tool errors or permission issues — those errors are visible in the tool result stream already, and duplicating them in prose confuses the init pipeline downstream.
301
-
302
- The init orchestrator verifies completion by checking that `{{PROJECT_ROOT}}/claudeos-core/generated/pass4-memory.json` exists nothing you print to the console affects that check. A verbose summary is at best redundant, and at worst (e.g. when you say "failed to create X" but the file actually got written) actively misleads the user. Stay silent and trust the marker file.
1
+ # Pass 4 — L4 Memory & Feedback Layer
2
+
3
+ You are generating the initial scaffolding for the L4 Memory layer on top of the
4
+ existing ClaudeOS-Core output. Read these three files to understand the project:
5
+
6
+ - `{{PROJECT_ROOT}}/claudeos-core/generated/project-analysis.json`
7
+ - `{{PROJECT_ROOT}}/claudeos-core/generated/pass2-merged.json`
8
+ - `{{PROJECT_ROOT}}/claudeos-core/generated/pass3a-facts.md` ← **MANDATORY**
9
+
10
+ Then generate the files listed below **exactly as specified**. Do NOT invent
11
+ additional files. Do NOT modify existing Pass 3 output in `standard/`, `skills/`,
12
+ `guide/`, `plan/`, `database/`, `mcp-guide/`.
13
+
14
+ You **WILL** create new rule files in `.claude/rules/60.memory/`.
15
+ You **WILL NOT** modify `CLAUDE.md` — it was fully authored by Pass 3,
16
+ and its Section 8 already covers Common Rules + L4 Memory completely.
17
+
18
+ **Language rule:** All generated content (rule descriptions,
19
+ compaction categories, decision-log seeds) must be written in **{{LANG_NAME}}**.
20
+ Frontmatter keys (`name`, `paths`) and file paths remain in English.
21
+
22
+ ---
23
+
24
+ ## CRITICAL Path fact grounding (MANDATORY for all rule and standard files)
25
+
26
+ Every source-tree path (`src/...`, `packages/...`, `apps/...`, or equivalent
27
+ language-specific source root) you write in any rule file or standard file
28
+ MUST appear verbatim in `pass3a-facts.md` or `pass2-merged.json`. If a
29
+ concrete path is not in those analysis artifacts, OMIT it — do NOT write it.
30
+
31
+ Do NOT invent paths based on framework convention, prior training knowledge,
32
+ or extrapolation from symbol names. The most common v2.3.0 dogfood failures
33
+ observed were all in this class:
34
+
35
+ `src/feature/main.tsx`
36
+ invented based on Vite's stock convention. This project may use a
37
+ different entry (e.g. `index.html` referencing a non-`main.tsx` file),
38
+ or may be a multi-entry project where no single `main.tsx` exists.
39
+ Check pass3a-facts.md; if no such path is listed, do not write it.
40
+
41
+ ❌ `src/feature/routers/featureRoutePath.ts`
42
+ invented by prepending the parent directory name ("feature") to the
43
+ filename, or by converting a TypeScript constant name
44
+ (`FEATURE_ROUTE_PATH`) into a filename. TypeScript identifiers and
45
+ filenames are independent. The authoritative filename is in
46
+ pass3a-facts.md under the "Routing" or "Shared imports" section.
47
+ If pass3a-facts.md says `routePath.ts`, write `routePath.ts`, not
48
+ `featureRoutePath.ts`.
49
+
50
+ ❌ `src/components/utils/classNameMaker.ts`
51
+ plausibly-named utility, but unverified. "Plausible" is not a
52
+ sufficient ground for a concrete path claim. If you want to reference
53
+ a utility layer in a rule file, reference the directory
54
+ (`src/components/utils/`) rather than inventing a filename.
55
+
56
+ `src/__mocks__/handlers.ts`, `src/test/setup.ts`, `src/test-utils.tsx`,
57
+ `src/setupTests.ts`
58
+ — invented based on testing-library conventions (MSW, Vitest, Jest,
59
+ React Testing Library). If the project has no tests (0% coverage in
60
+ pass3a-facts.md) or uses a different layout, these paths do not
61
+ exist. Anti-pattern triggers: writing a `testing-strategy.md` or
62
+ similar standard file and reaching for "the canonical test-setup
63
+ location" from the library's docs. There is no canonical location —
64
+ every project chooses its own, and only pass3a-facts.md knows which.
65
+ If pass3a-facts.md lists no test files, write the testing guidance
66
+ in general terms ("a shared setup module under a test directory of
67
+ your choice") rather than naming a specific path.
68
+
69
+ If pass3a-facts.md shows `ApiClient` (`src/admin/api/apiClient.ts`) as
70
+ the response wrapper, write `src/admin/api/apiClient.ts` verbatim.
71
+
72
+ When in doubt, write the rule in terms of the pattern (e.g., "handwritten
73
+ API modules under `src/admin/api/`") rather than a specific file name.
74
+ A directory-scoped rule is correct; an invented file path is a bug.
75
+
76
+ ✅ For testing-strategy documents specifically: if the project has zero
77
+ test coverage, describe the RECOMMENDED strategy in abstract terms
78
+ (test runner, assertion style, what to cover) without naming concrete
79
+ files. Paths are only appropriate once the tests exist and are in
80
+ pass3a-facts.md.
81
+
82
+ This rule is enforced post-generation by `content-validator [10/10]
83
+ path-claim verification`. Fabricated paths will be flagged as `STALE_PATH`
84
+ errors the same class that the v2.3.0 validator was created to detect.
85
+ Every STALE_PATH in a Pass 4-generated file is a bug the user sees and
86
+ reports; every STALE_PATH avoided here is one the user never hits.
87
+
88
+ ---
89
+
90
+ Memory scaffold files (sections 1–4) follow these rules:
91
+ - **Headings and description text** may be written in **{{LANG_NAME}}**.
92
+ - **CLI-parsed keywords MUST remain in English** (the CLI parses these literally):
93
+ - `## Last Compaction` (compaction.md section heading)
94
+ - `frequency:`, `importance:`, `last seen:` (failure-patterns.md field keys)
95
+ - `fix` or `solution` (failure-patterns.md fix line detection)
96
+ - **Title lines** (`# Decision Log`, `# Failure Patterns`, etc.) may be translated.
97
+ - **Instructional text** should be translated.
98
+
99
+ ---
100
+
101
+ ## Required output — L4 Memory (`{{PROJECT_ROOT}}/claudeos-core/memory/`)
102
+
103
+ ### 1. `memory/decision-log.md`
104
+ Start with the template below, then **append 3–5 seed entries** extracted from
105
+ `pass2-merged.json` that represent foundational architectural decisions already
106
+ made in this codebase. Each seed entry must be grounded in evidence from
107
+ pass2-merged.json — do NOT invent decisions.
108
+ Write the **title** (`# Decision Log`), the **descriptive italics** below it, and the seed entry **body text** in **{{LANG_NAME}}**. Keep the format specification's inline code literal (`## YYYY-MM-DD — <Title>`, `Context / Options / Decision / Consequences`).
109
+
110
+ Template header (translate the title and italics):
111
+ ```markdown
112
+ # Decision Log
113
+
114
+ _Permanent record of "why" behind design choices. Append-only._
115
+ _Format: `## YYYY-MM-DD <Title>` then Context / Options / Decision / Consequences._
116
+ ```
117
+
118
+ Seed entry format (for each of the 3–5 seeds, dated today in `YYYY-MM-DD` format
119
+ use the current UTC date; do NOT leave a literal placeholder):
120
+ ```markdown
121
+ ## <YYYY-MM-DD> — <Short title of the architectural choice>
122
+
123
+ - **Context:** <what in pass2-merged.json this is grounded on>
124
+ - **Options considered:** <optional — list if pass2-merged mentions alternatives>
125
+ - **Decision:** <the pattern observed>
126
+ - **Consequences:** <what this locks in for future work>
127
+ ```
128
+
129
+ ### 2. `memory/failure-patterns.md`
130
+ Write the title and descriptive italics in **{{LANG_NAME}}**. Keep CLI commands (`npx claudeos-core memory score`) literal. In the `_Format:` italics line, keep the format keywords `Frequency`, `Last Seen`, `Importance`, `Fix` literal in English (these names reappear as parsed field keys `frequency:`, `last seen:`, `importance:`, `fix:` in actual entries, and the memory CLI parser depends on that spelling surviving). Baseline template (translate the prose parts):
131
+
132
+ ```markdown
133
+ # Failure Patterns
134
+
135
+ _Recurring errors and their fixes. Importance auto-scored by `npx claudeos-core memory score`._
136
+ _Format: `## <pattern-id>` with Frequency / Last Seen / Importance / Fix._
137
+ ```
138
+
139
+ Do NOT add any seed entries — this file fills up as failures are encountered.
140
+
141
+ ### 3. `memory/compaction.md`
142
+ Write the full compaction strategy document. Adapt it to this project:
143
+ - Include a "Project-specific error categories" section listing 2–4 categories
144
+ based on the detected stack (e.g., for Kotlin: "Kotlin compilation errors",
145
+ "Gradle build failures"; for Python: "Import errors", "Virtualenv drift").
146
+ - Write the project-specific categories section in **{{LANG_NAME}}**.
147
+
148
+ **Translate into {{LANG_NAME}}**: the title (`# Compaction Strategy`), descriptive italics, all `##`/`###` section headings (`Preservation Priority`, `Stages`, `Stage 1 — Summarize aged entries`, `Stage 2 — Merge duplicate patterns`, `Stage 3 — Drop low-importance entries`, `Stage 4 — Enforce file size cap`, `Project-specific error categories`), and the prose explanations under each heading (including bullet-point explanations like "Keep: pattern-id, frequency, one-line fix summary").
149
+
150
+ **Keep literal (do NOT translate)**: the `## Last Compaction` heading (CLI-parsed verbatim), all inline code values (`importance >= 7`, `lastSeen`, `frequency = sum`, `fix`, `rule-manifest.json`, `decision-log.md`, `failure-patterns.md`), and all CLI commands (`npx claudeos-core memory compact`).
151
+
152
+ Baseline template (translate per above, then append the project-specific section at the end):
153
+ ```markdown
154
+ # Compaction Strategy
155
+
156
+ _4-stage compaction rules for `decision-log.md` and `failure-patterns.md`._
157
+ _Run via `npx claudeos-core memory compact`._
158
+
159
+ ## Preservation Priority
160
+ Entries are preserved if ANY of:
161
+ - `importance >= 7`
162
+ - `lastSeen` within 30 days
163
+ - Referenced by an active rule (path listed in rule-manifest.json)
164
+
165
+ ## Stages
166
+
167
+ ### Stage 1 — Summarize aged entries
168
+ Entries older than 30 days with no recent reference are summarized:
169
+ - Keep: pattern-id, frequency, one-line fix summary
170
+ - Drop: verbose context, full stack traces
171
+
172
+ ### Stage 2 — Merge duplicate patterns
173
+ Failure entries with the same root cause are merged:
174
+ - `frequency = sum`
175
+ - `lastSeen = max`
176
+ - `fix` unified to the most recent working solution
177
+
178
+ ### Stage 3 Drop low-importance entries
179
+ Entries with `importance < 3` AND `lastSeen > 60 days` are removed.
180
+
181
+ ### Stage 4 — Enforce file size cap
182
+ Each target file is capped at 400 lines.
183
+ When exceeded, the oldest (by `lastSeen`) low-importance entries are dropped first.
184
+
185
+ ## Project-specific error categories
186
+ <2–4 categories based on the detected stack, written in {{LANG_NAME}}>
187
+
188
+ ## Last Compaction
189
+ (never run `npx claudeos-core memory compact`)
190
+ ```
191
+
192
+ ### 4. `memory/auto-rule-update.md`
193
+ Write the title, descriptive italics, "How to apply" heading, the 3 how-to-apply steps, the "Proposals" heading, and the placeholder line in **{{LANG_NAME}}**. Keep CLI commands (`npx claudeos-core memory propose-rules`), file references (`decision-log.md`), and inline code literal. Baseline template (translate the prose parts):
194
+
195
+ ```markdown
196
+ # Auto Rule Update Proposals
197
+
198
+ _Generated by `npx claudeos-core memory propose-rules`._
199
+ _Each proposal: failure pattern affected rule diff confidence._
200
+
201
+ ## How to apply
202
+ 1. Review each proposal below.
203
+ 2. If accepted, edit the affected rule file and commit.
204
+ 3. Move the accepted proposal into `decision-log.md` as a record.
205
+
206
+ ## Proposals
207
+ (none yet run `npx claudeos-core memory propose-rules` after accumulating failure patterns)
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Required output — Rules (`.claude/rules/`)
213
+
214
+ Generate 6 rule files. Each file must include YAML frontmatter (`name`, `paths`) and markdown body.
215
+ **Frontmatter values stay in English; all body text (bullet points, descriptions, section headings like `## Reference`) MUST be written in {{LANG_NAME}}.** Keep literal in English: file paths, CLI commands, inline code (`` `...` ``), and the CLI-parsed field names (`frequency:`, `last seen:`, `importance:`, `fix:`) when they appear in examples.
216
+
217
+ ### 5. `.claude/rules/00.core/51.doc-writing-rules.md`
218
+ Frontmatter: `name: Document Writing Rules`, `paths: ["**/*"]`
219
+ Body (write in **{{LANG_NAME}}**) must cover:
220
+ - [CRITICAL] Rules file paths frontmatter required — every `.claude/rules/` file must have `paths` in frontmatter, do not propose narrowing `**/*` to specific patterns
221
+ - [CRITICAL] No domain-specific or path hardcoding in rules; use generic placeholder patterns
222
+ - [CRITICAL] Code examples must mirror actual project structure (verify directory paths before writing examples)
223
+ - Topic repetition across rules/standard is intentional reinforcement, not duplication
224
+ - Planned references (paths that don't yet exist) are forward declarations; do not flag them as missing
225
+ - `## Reference` section at the end linking to corresponding standard files
226
+
227
+ ### 6. `.claude/rules/00.core/52.ai-work-rules.md`
228
+ Frontmatter: `name: AI Work Rules`, `paths: ["**/*"]`
229
+ Body (write in **{{LANG_NAME}}**) must cover:
230
+ - Accuracy over token saving; verify before claiming
231
+ - 13 hallucination prevention patterns (see memory-scaffold static fallback for reference list)
232
+ - No unsolicited suggestions; ask when unsure
233
+ - Memory vs Rules no duplication judgment (Memory is on-demand, Rules are auto-loaded)
234
+ - Planned referencesno "missing" judgment
235
+ - Code/document generation accuracycheck actual source before guessing field names
236
+
237
+ ### 7. `.claude/rules/60.memory/01.decision-log.md`
238
+ Frontmatter: `name: Decision Log`, `paths: ["claudeos-core/memory/decision-log.md"]`
239
+ Body (write in **{{LANG_NAME}}**): read timing (session start + before architectural changes), write timing
240
+ (competing patterns / library choice / convention / NOT doing something),
241
+ entry format (ISO date heading + Context / Options / Decision / Consequences),
242
+ append-only rule.
243
+
244
+ ### 8. `.claude/rules/60.memory/02.failure-patterns.md`
245
+ Frontmatter: `name: Failure Patterns`, `paths: ["claudeos-core/memory/failure-patterns.md"]`
246
+ Body (write in **{{LANG_NAME}}**): read timing (session start + encountering an error), write timing (2nd occurrence +
247
+ non-obvious root cause + undocumented workaround), entry format with
248
+ **frequency**, **last seen**, **symptoms**, **root cause**, **fix** fields (keep these field names literal in English when showing example entries; prose explanations around them translate).
249
+ Never delete entries manually — use `npx claudeos-core memory compact`.
250
+
251
+ ### 9. `.claude/rules/60.memory/03.compaction.md`
252
+ Frontmatter: `name: Compaction Strategy`, `paths: ["claudeos-core/memory/compaction.md"]`
253
+ Body (write in **{{LANG_NAME}}**): reference to the 4 stages and preservation rules. Do NOT edit unless intentionally
254
+ changing the compaction policy; do NOT run compaction logic manually — always use the CLI.
255
+
256
+ ### 10. `.claude/rules/60.memory/04.auto-rule-update.md`
257
+ Frontmatter: `name: Auto Rule Update`, `paths: ["claudeos-core/memory/auto-rule-update.md"]`
258
+ Body (write in **{{LANG_NAME}}**): machine-generated proposals; review → accept → edit rule → record in decision-log.
259
+ Proposals with confidence >= 0.70 deserve serious consideration. Do NOT edit proposals directly.
260
+
261
+ ---
262
+
263
+ ## CLAUDE.md MUST NOT BE MODIFIED
264
+
265
+ CLAUDE.md has already been fully authored by Pass 3. Section 8 ("Common
266
+ Rules & Memory (L4)") inside CLAUDE.md is the single canonical place
267
+ that documents both the Common Rules table AND the L4 Memory table +
268
+ workflow. Pass 4 MUST NOT write to, append to, or otherwise modify
269
+ CLAUDE.md under any circumstances.
270
+
271
+ Historical note (v2.3.0 fix): prior Pass 4 templates instructed the
272
+ model to append a new `## N. ... (L4)` section to CLAUDE.md. That
273
+ instruction interacted incorrectly with the current Pass 3 scaffold,
274
+ which already produces Section 8 covering the same ground. The result
275
+ was a CLAUDE.md with 9 top-level sections and every memory file
276
+ appearing in two separate tables — precisely the `[S1]`, `[M-*]`, and
277
+ `[F2-*]` anti-patterns the v2.3.0 validator was designed to catch. The
278
+ validator is working as intended; the fix is to stop generating the
279
+ duplication at its source, which is this prompt.
280
+
281
+ If the CLAUDE.md the model is reading already contains a `## 9.` (or
282
+ `## 10.`, …) section with `(L4)` in its heading, that is stale output
283
+ from an older build leave it alone; it will be hand-removed by the
284
+ user, not by Pass 4.
285
+
286
+ ---
287
+
288
+ ## Required output Standard (`{{PROJECT_ROOT}}/claudeos-core/standard/00.core/`)
289
+
290
+ ### 11. `claudeos-core/standard/00.core/XX.doc-writing-guide.md`
291
+ Scan `claudeos-core/standard/00.core/` for existing numbered files. Use the **next sequential number**
292
+ (e.g., if `01`, `02`, `03` exist, create `04.doc-writing-guide.md`).
293
+
294
+ This is the **detailed guide** corresponding to `.claude/rules/00.core/51.doc-writing-rules.md`.
295
+ Write entirely in **{{LANG_NAME}}**.
296
+
297
+ Body must cover:
298
+ 1. **Document layer structure** — table with Layer/Path/Role/Loading for CLAUDE.md, Rules, Standard, Skills, Memory. Include a relationship diagram showing CLAUDE.md → Rules → Standard flow.
299
+ 2. **Rules file writing rules** — paths frontmatter required, paths scope settings table, file structure template with `## Reference` section. Do not propose narrowing `**/*`.
300
+ 3. **Standard file writing rules** long files are normal, file naming (`number.name.md`), register in `00.standard-reference.md`.
301
+ 4. **Skills file writing rules** — MANIFEST.md registration, paths frontmatter in generated rules, verify reference paths.
302
+ 5. **Planned references**paths that don't yet exist are forward declarations. Do not label as missing/stale/dead.
303
+ 6. **Multi-layer defensive rule placement is intentional** — repetition across Rules files is reinforcement, not duplication. Do not propose consolidation.
304
+ 7. **Topic repetition is not duplication** — same topic in CLAUDE.md + Rules + Standard serves different layer/domain roles. Trivial expression differences are not inconsistency risks.
305
+ 8. **No domain-specific hardcoding** — use generic placeholder patterns.
306
+ 9. **No system absolute path hardcoding** — use relative paths, include ❌/✅ examples.
307
+ 10. **Code examples must follow project conventions** — verify directory structure, follow project naming conventions.
308
+ 11. **Change synchronization procedure** — table showing Standard→Rules, Rules→Standard (verify `## Reference` link), Skills→MANIFEST sync targets.
309
+
310
+ ---
311
+
312
+ ## Completion marker
313
+
314
+ After all files are written, create:
315
+
316
+ `{{PROJECT_ROOT}}/claudeos-core/generated/pass4-memory.json`
317
+
318
+ ```json
319
+ {
320
+ "analyzedAt": "<ISO timestamp>",
321
+ "passNum": 4,
322
+ "memoryFiles": [
323
+ "claudeos-core/memory/decision-log.md",
324
+ "claudeos-core/memory/failure-patterns.md",
325
+ "claudeos-core/memory/compaction.md",
326
+ "claudeos-core/memory/auto-rule-update.md"
327
+ ],
328
+ "ruleFiles": [
329
+ ".claude/rules/00.core/51.doc-writing-rules.md",
330
+ ".claude/rules/00.core/52.ai-work-rules.md",
331
+ ".claude/rules/60.memory/01.decision-log.md",
332
+ ".claude/rules/60.memory/02.failure-patterns.md",
333
+ ".claude/rules/60.memory/03.compaction.md",
334
+ ".claude/rules/60.memory/04.auto-rule-update.md"
335
+ ],
336
+ "standardFiles": [
337
+ "claudeos-core/standard/00.core/XX.doc-writing-guide.md"
338
+ ],
339
+ "claudeMdAppended": true,
340
+ "seededDecisions": <integer count of seed entries written to decision-log.md>
341
+ }
342
+ ```
343
+
344
+ ---
345
+
346
+ ## Guardrails
347
+
348
+ - Do NOT modify existing Pass 3 output files in `claudeos-core/standard/` (except adding the new doc-writing-guide),
349
+ `claudeos-core/skills/`, `claudeos-core/guide/`, `claudeos-core/database/`,
350
+ `claudeos-core/mcp-guide/`.
351
+ - Do NOT modify existing `.claude/rules/00.core/00.*` through `.claude/rules/00.core/02.*` files (Pass 3 output).
352
+ - Do NOT modify existing `.claude/rules/10.backend/` through `.claude/rules/50.sync/` files.
353
+ - DO create `.claude/rules/00.core/51.doc-writing-rules.md` and `.claude/rules/00.core/52.ai-work-rules.md` (Pass 4 output).
354
+ - DO create `claudeos-core/standard/00.core/XX.doc-writing-guide.md` with the next sequential number (Pass 4 output).
355
+ - Do NOT touch CLAUDE.md. Pass 3 already authored all 8 sections, including Section 8's full Common Rules + L4 Memory content. No append, no edit, no create of a new CLAUDE.md.
356
+ - Do NOT translate CLI-parsed keywords in memory files: `## Last Compaction`, `frequency:`, `importance:`, `last seen:`, `fix`, `solution`.
357
+ - DO translate all other text in memory files (titles, descriptions, instructions) into **{{LANG_NAME}}**.
358
+ - DO write rule files (sections 5–10) and the standard file (section 11) in **{{LANG_NAME}}**.
359
+ - Keep seed decision-log entries **grounded** in pass2-merged.json only. No hallucination.
360
+ - Use the current date (UTC, YYYY-MM-DD) for dated headings — substitute the real date,
361
+ never leave `<YYYY-MM-DD>` or any placeholder-looking token as literal text.
362
+
363
+ ---
364
+
365
+ ## Output discipline (CRITICAL)
366
+
367
+ Do your work by writing files with the Write tool. When you finish, **end the conversation with a single short line only** — specifically:
368
+
369
+ ```
370
+ Pass 4 complete.
371
+ ```
372
+
373
+ Do NOT print a summary of what you created. Do NOT list the files you wrote. Do NOT report files that you "failed" to write because of tool errors or permission issues — those errors are visible in the tool result stream already, and duplicating them in prose confuses the init pipeline downstream.
374
+
375
+ The init orchestrator verifies completion by checking that `{{PROJECT_ROOT}}/claudeos-core/generated/pass4-memory.json` exists — nothing you print to the console affects that check. A verbose summary is at best redundant, and at worst (e.g. when you say "failed to create X" but the file actually got written) actively misleads the user. Stay silent and trust the marker file.