claudeos-core 2.3.2 → 2.4.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 (36) hide show
  1. package/CHANGELOG.md +736 -74
  2. package/CODE_OF_CONDUCT.md +15 -0
  3. package/README.de.md +321 -883
  4. package/README.es.md +322 -883
  5. package/README.fr.md +322 -883
  6. package/README.hi.md +322 -883
  7. package/README.ja.md +322 -883
  8. package/README.ko.md +322 -882
  9. package/README.md +321 -883
  10. package/README.ru.md +322 -885
  11. package/README.vi.md +322 -883
  12. package/README.zh-CN.md +321 -881
  13. package/SECURITY.md +51 -0
  14. package/bin/commands/init.js +192 -37
  15. package/content-validator/index.js +97 -4
  16. package/health-checker/index.js +44 -10
  17. package/package.json +92 -90
  18. package/pass-json-validator/index.js +58 -7
  19. package/pass-prompts/templates/angular/pass3.md +15 -14
  20. package/pass-prompts/templates/common/claude-md-scaffold.md +81 -0
  21. package/pass-prompts/templates/common/pass3-footer.md +104 -0
  22. package/pass-prompts/templates/java-spring/pass3.md +19 -18
  23. package/pass-prompts/templates/kotlin-spring/pass3.md +23 -22
  24. package/pass-prompts/templates/node-express/pass3.md +18 -17
  25. package/pass-prompts/templates/node-fastify/pass3.md +11 -10
  26. package/pass-prompts/templates/node-nestjs/pass3.md +11 -10
  27. package/pass-prompts/templates/node-nextjs/pass3.md +18 -17
  28. package/pass-prompts/templates/node-vite/pass3.md +11 -10
  29. package/pass-prompts/templates/python-django/pass3.md +18 -17
  30. package/pass-prompts/templates/python-fastapi/pass3.md +18 -17
  31. package/pass-prompts/templates/python-flask/pass3.md +9 -8
  32. package/pass-prompts/templates/vue-nuxt/pass3.md +9 -8
  33. package/plan-installer/domain-grouper.js +45 -5
  34. package/plan-installer/index.js +11 -1
  35. package/plan-installer/scanners/scan-java.js +98 -2
  36. package/plan-installer/stack-detector.js +44 -0
package/package.json CHANGED
@@ -1,90 +1,92 @@
1
- {
2
- "name": "claudeos-core",
3
- "version": "2.3.2",
4
- "description": "Auto-generate Claude Code documentation from your actual source code — Standards, Rules, Skills, and Guides tailored to your project",
5
- "main": "bin/cli.js",
6
- "bin": {
7
- "claudeos-core": "bin/cli.js"
8
- },
9
- "files": [
10
- "bin/",
11
- "lib/",
12
- "claude-md-validator/",
13
- "content-validator/",
14
- "health-checker/",
15
- "manifest-generator/",
16
- "pass-json-validator/",
17
- "pass-prompts/",
18
- "plan-installer/",
19
- "plan-validator/",
20
- "sync-checker/",
21
- "bootstrap.sh",
22
- "README.md",
23
- "README.ko.md",
24
- "LICENSE",
25
- "CHANGELOG.md",
26
- "CONTRIBUTING.md",
27
- "README.zh-CN.md",
28
- "README.ja.md",
29
- "README.es.md",
30
- "README.vi.md",
31
- "README.hi.md",
32
- "README.ru.md",
33
- "README.fr.md",
34
- "README.de.md"
35
- ],
36
- "scripts": {
37
- "init": "node bin/cli.js init",
38
- "lint": "node bin/cli.js lint",
39
- "health": "node bin/cli.js health",
40
- "validate": "node bin/cli.js validate",
41
- "refresh": "node bin/cli.js refresh",
42
- "restore": "node bin/cli.js restore",
43
- "pretest": "node -e \"try{require('glob')}catch(e){process.exit(1)}\" || npm install",
44
- "test": "node scripts/run-tests.js",
45
- "test:health": "node health-checker/index.js"
46
- },
47
- "keywords": [
48
- "claude-code",
49
- "automation",
50
- "code-analysis",
51
- "CLAUDE.md",
52
- "standards",
53
- "rules",
54
- "skills",
55
- "scaffolding",
56
- "i18n",
57
- "multi-language",
58
- "spring-boot",
59
- "kotlin",
60
- "exposed",
61
- "jooq",
62
- "cqrs",
63
- "bff",
64
- "multi-module",
65
- "monorepo",
66
- "nextjs",
67
- "express",
68
- "fastify",
69
- "angular",
70
- "django",
71
- "fastapi"
72
- ],
73
- "author": "claudeos-core <claudeoscore@gmail.com> (https://github.com/claudeos-core)",
74
- "license": "ISC",
75
- "repository": {
76
- "type": "git",
77
- "url": "git+https://github.com/claudeos-core/claudeos-core.git"
78
- },
79
- "homepage": "https://github.com/claudeos-core/claudeos-core#readme",
80
- "bugs": {
81
- "url": "https://github.com/claudeos-core/claudeos-core/issues"
82
- },
83
- "engines": {
84
- "node": ">=18.0.0"
85
- },
86
- "dependencies": {
87
- "glob": "^13.0.6",
88
- "gray-matter": "^4.0.3"
89
- }
90
- }
1
+ {
2
+ "name": "claudeos-core",
3
+ "version": "2.4.0",
4
+ "description": "Auto-generate Claude Code documentation from your actual source code — Standards, Rules, Skills, and Guides tailored to your project",
5
+ "main": "bin/cli.js",
6
+ "bin": {
7
+ "claudeos-core": "bin/cli.js"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "lib/",
12
+ "claude-md-validator/",
13
+ "content-validator/",
14
+ "health-checker/",
15
+ "manifest-generator/",
16
+ "pass-json-validator/",
17
+ "pass-prompts/",
18
+ "plan-installer/",
19
+ "plan-validator/",
20
+ "sync-checker/",
21
+ "bootstrap.sh",
22
+ "README.md",
23
+ "README.ko.md",
24
+ "LICENSE",
25
+ "CHANGELOG.md",
26
+ "CONTRIBUTING.md",
27
+ "CODE_OF_CONDUCT.md",
28
+ "SECURITY.md",
29
+ "README.zh-CN.md",
30
+ "README.ja.md",
31
+ "README.es.md",
32
+ "README.vi.md",
33
+ "README.hi.md",
34
+ "README.ru.md",
35
+ "README.fr.md",
36
+ "README.de.md"
37
+ ],
38
+ "scripts": {
39
+ "init": "node bin/cli.js init",
40
+ "lint": "node bin/cli.js lint",
41
+ "health": "node bin/cli.js health",
42
+ "validate": "node bin/cli.js validate",
43
+ "refresh": "node bin/cli.js refresh",
44
+ "restore": "node bin/cli.js restore",
45
+ "pretest": "node -e \"try{require('glob')}catch(e){process.exit(1)}\" || npm install",
46
+ "test": "node scripts/run-tests.js",
47
+ "test:health": "node health-checker/index.js"
48
+ },
49
+ "keywords": [
50
+ "claude-code",
51
+ "automation",
52
+ "code-analysis",
53
+ "CLAUDE.md",
54
+ "standards",
55
+ "rules",
56
+ "skills",
57
+ "scaffolding",
58
+ "i18n",
59
+ "multi-language",
60
+ "spring-boot",
61
+ "kotlin",
62
+ "exposed",
63
+ "jooq",
64
+ "cqrs",
65
+ "bff",
66
+ "multi-module",
67
+ "monorepo",
68
+ "nextjs",
69
+ "express",
70
+ "fastify",
71
+ "angular",
72
+ "django",
73
+ "fastapi"
74
+ ],
75
+ "author": "claudeos-core <claudeoscore@gmail.com> (https://github.com/claudeos-core)",
76
+ "license": "ISC",
77
+ "repository": {
78
+ "type": "git",
79
+ "url": "git+https://github.com/claudeos-core/claudeos-core.git"
80
+ },
81
+ "homepage": "https://github.com/claudeos-core/claudeos-core#readme",
82
+ "bugs": {
83
+ "url": "https://github.com/claudeos-core/claudeos-core/issues"
84
+ },
85
+ "engines": {
86
+ "node": ">=18.0.0"
87
+ },
88
+ "dependencies": {
89
+ "glob": "^13.0.6",
90
+ "gray-matter": "^4.0.3"
91
+ }
92
+ }
@@ -70,10 +70,17 @@ async function main() {
70
70
 
71
71
  // ─── 1. project-analysis.json ──────────────────────────
72
72
  console.log(" [1/5] project-analysis.json...");
73
+ // v2.4.0 — `template` (singular, legacy single-stack form) removed from
74
+ // recommended-keys list. `templates` (plural object {backend, frontend})
75
+ // is the canonical form since multi-stack support landed; the consumer
76
+ // at line ~88 already does `pa.templates || pa.template` fallback for
77
+ // back-compat. Listing `template` as recommended caused a false-positive
78
+ // MISSING_KEY WARNING on every healthy multi-stack-aware project where
79
+ // only `templates` exists.
73
80
  const pa = validateJson(
74
81
  path.join(GEN_DIR, "project-analysis.json"),
75
82
  ["analyzedAt", "stack", "domains", "frontend", "summary"],
76
- ["lang", "template", "templates", "rootPackage", "activeDomains"]
83
+ ["lang", "templates", "rootPackage", "activeDomains"]
77
84
  );
78
85
  if (pa) {
79
86
  if (!pa.stack || !pa.stack.language) {
@@ -167,6 +174,32 @@ async function main() {
167
174
  "codeQuality", // 12. Code quality tools
168
175
  ];
169
176
 
177
+ // v2.4.0 — Semantic alias map for sections.
178
+ //
179
+ // Pass 2 LLM frequently emits section keys with numeric prefixes
180
+ // ("1_universalPatterns") or alternate vocabulary ("majorityPatterns"
181
+ // instead of "sharedPatterns"). The fuzzy normalizer can't catch
182
+ // these because the stems don't overlap. This alias map adds known
183
+ // semantic equivalents so the existence check matches when ANY of
184
+ // the canonical name OR its aliases is present.
185
+ //
186
+ // Each entry: canonical name → [...alternate keys (case/separator
187
+ // insensitive — normalized identically to keys at check time)].
188
+ const SECTION_ALIASES = {
189
+ commonPatterns: ["universalPatterns", "1_universalPatterns", "1universalPatterns", "patterns_universal"],
190
+ sharedPatterns: ["majorityPatterns", "2_majorityPatterns", "2majorityPatterns", "patterns_majority"],
191
+ domainSpecific: ["domainSpecificPatterns", "3_domainSpecific", "perDomain", "domains"],
192
+ antiPatterns: ["antipatternSummary", "4_antiPatterns", "5_antiPatternSummary", "antiPatternSummary"],
193
+ namingConventions: ["naming", "5_namingConventions", "6_namingConventions"],
194
+ commonUtilities: ["sharedUtilities", "utilities", "6_commonUtilities", "7_commonUtilities"],
195
+ security: ["securityPatterns", "auth", "authentication", "7_security", "8_security"],
196
+ testing: ["testStrategy", "testingStrategy", "9_testing", "10_testing"],
197
+ logging: ["loggingStrategy", "monitoring", "loggingMonitoring", "10_logging", "11_logging"],
198
+ codeQuality: ["quality", "codeQualityTools", "12_codeQuality", "13_codeQuality"],
199
+ database: ["dbPatterns", "8_database"],
200
+ performance: ["perfPatterns", "11_performance"],
201
+ };
202
+
170
203
  // Sections only in backend stacks (java/node-express/django/fastapi/kotlin)
171
204
  const BACKEND_SECTIONS = [
172
205
  "database", // 8. DB patterns
@@ -208,15 +241,19 @@ async function main() {
208
241
  ...(isKotlinCqrs ? KOTLIN_CQRS_SECTIONS : []),
209
242
  ];
210
243
 
211
- // Key existence validation (case-insensitive fuzzy matching)
244
+ // Key existence validation (case-insensitive fuzzy matching + alias map)
212
245
  // Normalize a key to a comparable form: lowercase, strip separators
213
- const normalize = (s) => s.toLowerCase().replace(/[_\-\s]/g, "");
246
+ const normalize = (s) => s.toLowerCase().replace(/[_\-\s\.]/g, "");
214
247
  const normalizedKeys = keys.map(normalize);
215
248
  for (const section of sectionsToCheck) {
216
249
  const sectionNorm = normalize(section);
217
- // Exact normalized match first, then check if any key contains the section name (one-direction only to avoid false positives)
250
+ // (1) Exact normalized match
251
+ // (2) Substring match on canonical (one-direction, length >= 6 to avoid false positives)
252
+ // (3) v2.4.0 — Alias map: any aliased name (normalized) matches a key (normalized)
253
+ const aliases = (SECTION_ALIASES[section] || []).map(normalize);
218
254
  const found = normalizedKeys.some(k => k === sectionNorm)
219
- || (sectionNorm.length >= 6 && normalizedKeys.some(k => k.includes(sectionNorm)));
255
+ || (sectionNorm.length >= 6 && normalizedKeys.some(k => k.includes(sectionNorm)))
256
+ || aliases.some(a => normalizedKeys.some(k => k === a || (a.length >= 6 && k.includes(a))));
220
257
  if (!found) {
221
258
  warnings.push({
222
259
  file: "pass2-merged.json",
@@ -270,7 +307,13 @@ async function main() {
270
307
  console.log(" [5a/5] pass3-complete.json (optional)...");
271
308
  const p3path = path.join(GEN_DIR, "pass3-complete.json");
272
309
  if (fs.existsSync(p3path)) {
273
- const p3 = validateJson(p3path, ["completedAt"], ["backfilled", "reason"]);
310
+ // v2.4.0 `backfilled` and `reason` removed from recommended-keys list.
311
+ // Both are scenario-specific: `backfilled: true` is set only when init.js
312
+ // backfilled the marker for a pre-v1.7 CLAUDE.md (rare upgrade path),
313
+ // and `reason` documents that backfill source. Normal Claude-driven
314
+ // Pass 3 completion never has either — listing them as "recommended"
315
+ // produced a false-positive MISSING_KEY WARNING on every healthy run.
316
+ const p3 = validateJson(p3path, ["completedAt"], []);
274
317
  if (p3) {
275
318
  if (typeof p3.completedAt !== "string" || !/^\d{4}-\d{2}-\d{2}T/.test(p3.completedAt)) {
276
319
  warnings.push({ file: "pass3-complete.json", type: "INVALID_TIMESTAMP", msg: `completedAt should be ISO 8601 (got ${JSON.stringify(p3.completedAt)})` });
@@ -286,9 +329,17 @@ async function main() {
286
329
  console.log(" [5b/5] pass4-memory.json (optional)...");
287
330
  const p4path = path.join(GEN_DIR, "pass4-memory.json");
288
331
  if (fs.existsSync(p4path)) {
332
+ // v2.4.0 — `planFiles` removed from optional list because master plan
333
+ // generation was removed in v2.1.0. Pass 4 normal completion never has
334
+ // it, so the recommendation produced a false-positive WARNING on every
335
+ // healthy run. Same for `fallback` (only set when Claude-driven Pass 4
336
+ // failed and static fallback ran) — its absence is the SUCCESS path.
337
+ // `seededDecisions` (only when initial decision-log is seeded) and
338
+ // `ruleFiles` (only when Pass 4 emits rules outside scaffold) are also
339
+ // scenario-specific; demoted from "recommended" to "purely optional".
289
340
  const p4 = validateJson(p4path,
290
341
  ["analyzedAt", "passNum", "memoryFiles"],
291
- ["planFiles", "ruleFiles", "seededDecisions", "fallback"]
342
+ [] // No recommended optional keys; all scenario-specific (see comment above)
292
343
  );
293
344
  if (p4) {
294
345
  if (typeof p4.passNum !== "number" || p4.passNum !== 4) {
@@ -47,26 +47,26 @@ Generation targets:
47
47
  - 00.core/01.project-overview.md — Stack (Angular version, TypeScript version), project structure
48
48
  - 00.core/02.architecture.md — Module hierarchy, DI tree, data flow, lazy loading map
49
49
  - 00.core/03.naming-conventions.md — File/class/selector/module naming conventions
50
- - 20.frontend-ui/01.component-patterns.md — Component structure, lifecycle, OnPush, Signals, I/O
51
- - 20.frontend-ui/02.routing-patterns.md — Route config, lazy loading, guards, resolvers
52
- - 20.frontend-ui/03.service-di-patterns.md — Injectable, providers, injection tokens, inject()
53
- - 20.frontend-ui/04.rxjs-patterns.md — Observable management, operators, subscription cleanup
54
- - 20.frontend-ui/05.template-patterns.md — Directives, content projection, control flow (@if/@for)
55
- - 20.frontend-ui/06.form-patterns.md — Reactive/Template forms, validators, error handling
56
- - 20.frontend-ui/07.state-management.md — NgRx/NGXS/Signal Store patterns
57
- - 20.frontend-ui/08.http-patterns.md — HttpClient, interceptors, caching, error handling
58
- - 20.frontend-ui/09.styling-patterns.md — ViewEncapsulation, theming, responsive
59
- - 10.backend-api/01.api-integration.md — API service abstraction, interceptors (if backend exists)
50
+ - 20.frontend/01.component-patterns.md — Component structure, lifecycle, OnPush, Signals, I/O
51
+ - 20.frontend/02.routing-patterns.md — Route config, lazy loading, guards, resolvers
52
+ - 20.frontend/03.service-di-patterns.md — Injectable, providers, injection tokens, inject()
53
+ - 20.frontend/04.rxjs-patterns.md — Observable management, operators, subscription cleanup
54
+ - 20.frontend/05.template-patterns.md — Directives, content projection, control flow (@if/@for)
55
+ - 20.frontend/06.form-patterns.md — Reactive/Template forms, validators, error handling
56
+ - 20.frontend/07.state-management.md — NgRx/NGXS/Signal Store patterns
57
+ - 20.frontend/08.http-patterns.md — HttpClient, interceptors, caching, error handling
58
+ - 20.frontend/09.styling-patterns.md — ViewEncapsulation, theming, responsive
59
+ - 10.backend/01.api-integration.md — API service abstraction, interceptors (if backend exists)
60
60
  - 30.security-db/01.security-auth.md — Auth guards, JWT interceptor, route protection
61
61
  - 40.infra/01.environment-config.md — environment.ts, angular.json, build configuration
62
62
  - 40.infra/02.logging-monitoring.md — Error tracking, performance monitoring
63
63
  - 40.infra/03.cicd-deployment.md — CI/CD pipeline, ng build --configuration, Docker
64
- - 50.verification/01.development-verification.md — ng serve, ng build, Lighthouse
65
- - 50.verification/02.testing-strategy.md — TestBed, component harness, E2E strategy
64
+ - 80.verification/01.development-verification.md — ng serve, ng build, Lighthouse
65
+ - 80.verification/02.testing-strategy.md — TestBed, component harness, E2E strategy
66
66
 
67
67
  Each file MUST include:
68
- - Correct examples (code blocks in TypeScript)
69
- - Incorrect examples (code blocks showing common Angular mistakes)
68
+ - Correct examples (code blocks in TypeScript)
69
+ - Incorrect examples (code blocks showing common Angular mistakes)
70
70
  - Key rules summary table
71
71
 
72
72
  3. .claude/rules/ (active domains only)
@@ -83,6 +83,7 @@ Generation targets:
83
83
  - `40.infra/03.cicd-deployment-rules.md` paths: `["**/*.yml", "**/*.yaml", "**/Dockerfile*", "**/*.ts"]` — CI config + source
84
84
  - `50.sync/*` rules: `paths: ["**/claudeos-core/**", "**/.claude/**"]`
85
85
  - `60.memory/*` rules: forward reference — Pass 4 will generate 4 files (01.decision-log, 02.failure-patterns, 03.compaction, 04.auto-rule-update), each with file-specific `paths`. Pass 3 must STILL list ```.claude/rules/60.memory/*``` as a row in CLAUDE.md Section 6 Rules table so developers/Claude see the category exists.
86
+ - `70.domains/*` rules (multi-domain projects only): per-domain rules at `.claude/rules/70.domains/{type}/{domain}-rules.md` (where `{type}` is `backend` or `frontend`, ALWAYS present even in single-stack projects for uniform layout + zero-migration future-proofing), each with a `paths:` glob scoped to that domain's source directories so the rule auto-loads only when editing files within the relevant domain. Folder name is PLURAL (`domains/`) — collection of N per-domain files — and each file inside uses the SINGULAR domain name (`{domain}-rules.md`). DO NOT use `60.domains/` (collides with `60.memory/`) and DO NOT skip the `{type}/` sub-folder. See pass3-footer.md "Per-domain folder convention" for the full rationale.
86
87
  - MUST generate `.claude/rules/00.core/00.standard-reference.md` as a directory of all standard files
87
88
 
88
89
  4. .claude/rules/50.sync/ (2 sync rules)
@@ -279,6 +279,12 @@ Unlike rules that auto-load via `paths` glob, this layer is referenced **on-dema
279
279
  4. **Record repeated errors**: If the same error occurs ≥2 times and the root cause is non-obvious, register it in `failure-patterns.md` with a new pattern-id.
280
280
  5. **Periodic compaction**: When a memory file approaches 400 lines or has not been tidied up for over a month, run `npx claudeos-core memory compact`.
281
281
  6. **Review rule-update proposals**: Review proposals in `auto-rule-update.md` with confidence ≥ 0.70. When accepting, edit the corresponding rule file and log the decision in `decision-log.md`.
282
+
283
+ **Session Resume (after auto-compact or restart)**: Claude Code's auto-compact feature may truncate session context mid-work, and a restarted session starts with a fresh context window. When resuming work:
284
+
285
+ - **Re-scan** `failure-patterns.md` — error patterns referenced pre-compact may have been dropped from context.
286
+ - **Re-read the 3 most recent entries** of `decision-log.md` — new decisions may have been recorded during the truncated portion of the session.
287
+ - **Re-match rules by `paths` glob** for the current working files — CLAUDE.md is always loaded, but `paths`-conditional rules may not have been re-loaded after compact. Explicitly Read the relevant rule files if needed.
282
288
  ```
283
289
 
284
290
  ---
@@ -555,6 +561,63 @@ Format: `**{category}**: {explanation}`
555
561
  Example row for 60.memory:
556
562
  `.claude/rules/60.memory/*` | Auto-loaded when editing L4 memory
557
563
  files (decision-log · failure-patterns · compaction · auto-rule-update) |
564
+ Example row for 70.domains (only when the project has multi-batch
565
+ domain output — see "Per-domain folder convention" below):
566
+ `.claude/rules/70.domains/*` | Auto-loaded when editing files within
567
+ a specific domain (paths-scoped, one rule file per domain) |
568
+
569
+ **Per-domain folder convention (canonical, v2.4.0+)**:
570
+
571
+ When a project has multiple distinct domains and Pass 3 emits per-domain
572
+ output (typical for backends with ≥4 domains, multi-batch runs, or
573
+ projects where rules need domain-specific `paths` glob scoping), the
574
+ canonical folder is **`70.domains/{type}/`** (PLURAL collection +
575
+ ALWAYS-typed sub-folder), and each file inside uses the singular
576
+ domain name:
577
+
578
+ - `claudeos-core/standard/70.domains/{type}/{domain}.md` — `{type}`
579
+ is `backend` or `frontend`
580
+ - `.claude/rules/70.domains/{type}/{domain}-rules.md` — per-domain rule
581
+ (with `paths` frontmatter scoping to that domain's source directories)
582
+
583
+ The `{type}/` sub-folder is ALWAYS present, even in single-stack
584
+ projects (backend-only or frontend-only). Reasons: (1) zero file moves
585
+ when a single-stack project later adds the other stack, (2) no LLM
586
+ probabilistic drift between Pass 3 runs (one pattern always), (3) one
587
+ pattern for validators to recognize, (4) future-proof for new stack
588
+ types (mobile/cli/agent).
589
+
590
+ The Pass 3 orchestrator (`bin/commands/init.js`) classifies each domain
591
+ via `project-analysis.json` and emits per-domain target paths
592
+ explicitly in the batch scope note — you (the LLM) should follow the
593
+ explicit paths shown there.
594
+ - `claudeos-core/skills/{category}/domains/{domain}.md` — per-domain
595
+ skill notes (sub-folder under skill category, no number prefix
596
+ because skills/ is a separate namespace from standard/rules)
597
+ - `claudeos-core/skills/{category}/02.domains.md` — sibling
598
+ ORCHESTRATOR for the `domains/` sub-folder (REQUIRED whenever
599
+ `domains/` is populated). Mirrors the canonical pattern
600
+ `01.scaffold-*-feature.md` ↔ `scaffold-*-feature/`: orchestrator
601
+ file at category root + sub-folder of the same stem. Stem
602
+ (`domains`) MUST match sub-folder name so `content-validator`'s
603
+ standard orchestrator-stem matching covers the sub-skills
604
+ directly without depending on the global-MANIFEST coverage
605
+ fallback. The per-domain note files INSIDE `domains/` carry NO
606
+ numeric prefix (`payment.md`, not `01.payment.md`) — domains are
607
+ independent siblings without execution order, unlike the
608
+ sequenced CRUD sub-skills (`01.dto.md` → `08.test.md`) where
609
+ numbers encode the scaffolding step order.
610
+
611
+ The `70.` prefix sits AFTER `60.memory` (which is regression-guarded to
612
+ 60) and BEFORE `90.optional`, giving per-domain content its own clean
613
+ slot in the rules numbering. The folder name is plural (`domains/`)
614
+ because it holds N files, one per project domain — matching the standard
615
+ filesystem convention `users/user.md`, `posts/post.md`. The other
616
+ numbered category folders (`00.core/`, `10.backend/`, etc.) are singular
617
+ because each represents ONE topic, not a collection.
618
+
619
+ DO NOT use `60.domains/` (collides with `60.memory/`) and DO NOT use
620
+ `70.domain/` (singular folder is incorrect for a collection).
558
621
 
559
622
  **Sub-section 3**: `### Skills (Automated Repeated-task Procedures)`
560
623
  - Bullet list
@@ -644,6 +707,24 @@ Workflow: `#### Memory Workflow` — FIXED 6-step numbered list
644
707
  5. Periodic compaction — memory compact command
645
708
  6. Review rule-update proposals — auto-rule-update review
646
709
 
710
+ **Session Resume block** (RECOMMENDED, follows the 6-step numbered list
711
+ as prose — not a new H4 subsection). Opens with bold label
712
+ `**Session Resume (after auto-compact or restart)**:` followed by a
713
+ 3-bullet list covering: re-scan `failure-patterns.md`, re-read the 3
714
+ most recent entries of `decision-log.md`, and re-match rules by `paths`
715
+ glob for current working files. This block addresses Claude Code's
716
+ auto-compact behavior that may truncate session context mid-work.
717
+
718
+ New CLAUDE.md generation (`npx claudeos-core init`) emits this block
719
+ by default. Existing CLAUDE.md files without it remain structurally
720
+ valid — the validator does not enforce Session Resume presence, only
721
+ that if present it follows the prose-not-H4 form.
722
+
723
+ The Session Resume block MUST NOT be a `####` subsection — the Section
724
+ 8 structural validator enforces EXACTLY 2 `####` headings (L4 Memory
725
+ Files + Memory Workflow). Session Resume is prose inside the Memory
726
+ Workflow section, not a sibling heading.
727
+
647
728
  **Section 8 single-occurrence rule** (enforces the "one canonical home"
648
729
  principle):
649
730
  - The L4 Memory Files table appears EXACTLY ONCE in the entire document
@@ -535,5 +535,109 @@ level (the scaffold's PROJECT_CONTEXT mentions architecture style),
535
535
  but it does NOT enumerate rules. Section 6 "Standard / Rules / Skills
536
536
  Reference" provides a REFERENCE INDEX (what exists), not rule content.
537
537
 
538
+ CRITICAL — Standard files MUST include both ✅ and ❌ examples:
539
+ Every file under `claudeos-core/standard/**/*.md` (except pure index/overview
540
+ files like `00.core/01.project-overview.md`) MUST contain BOTH:
541
+ - At least one ✅ Correct example (a fenced code block showing the right way)
542
+ - At least one ❌ Incorrect example (a fenced code block showing the wrong way)
543
+
544
+ Skipping the ❌ block is a common Pass 3b LLM failure mode that produces
545
+ `[NO_BAD_EXAMPLE]` advisories from `content-validator`. Even if you can only
546
+ think of a minimal contrastive ❌ (a one-line wrong call, a missing
547
+ annotation, a typo'd config key), include it. The contrast is what gives
548
+ the standard its didactic value — a file with only ✅ examples reads as
549
+ "this is one way to do it", whereas ✅+❌ reads as "this is the way; here is
550
+ the failure mode".
551
+
552
+ Self-check before finalizing each standard file:
553
+ - Does this file have at least one ```...``` block marked ✅?
554
+ - Does this file have at least one ```...``` block marked ❌?
555
+ If either is missing, add it before moving on.
556
+
557
+ CRITICAL — Per-domain folder convention (`70.domains/{type}/`, plural):
558
+
559
+ When generating per-domain files (any output that's specific to one
560
+ project domain — e.g. `payment.md`, `order.md`, `member.md`), use the
561
+ canonical `70.domains/` folder (PLURAL, collection-style) and ALWAYS
562
+ include a `{type}/` sub-folder (`backend/` or `frontend/`) regardless
563
+ of single-stack or multi-stack project. Uniform-convention rationale
564
+ in the next paragraph.
565
+
566
+ - Per-domain standard:
567
+ `claudeos-core/standard/70.domains/{type}/{domain}.md`
568
+ where `{type}` is `backend` or `frontend`
569
+ - Per-domain rule:
570
+ `.claude/rules/70.domains/{type}/{domain}-rules.md`
571
+ (via staging-override path
572
+ `claudeos-core/generated/.staged-rules/70.domains/{type}/{domain}-rules.md`,
573
+ each rule file MUST have a `paths:` frontmatter glob scoping to that
574
+ domain's source directories)
575
+
576
+ **Why ALWAYS the `{type}/` sub-folder, even for single-stack projects?**
577
+ A single-stack project pays a 1-folder depth cost
578
+ (`70.domains/backend/order.md` instead of `70.domains/order.md`). In
579
+ exchange:
580
+
581
+ 1. **Zero migration when the other stack is added.** A backend-only
582
+ project that later adds a Next.js frontend does NOT need to move
583
+ existing files to `backend/` — they're already there.
584
+ 2. **No LLM probabilistic drift.** Pass 3 LLM never has to decide
585
+ "is this single-stack or multi?" — the pattern is always the
586
+ same.
587
+ 3. **One pattern for validators.** `content-validator` and
588
+ `claude-md-validator` recognize a single layout instead of
589
+ branching.
590
+ 4. **Future-proof for new stack types** (mobile, cli, agent, ...).
591
+
592
+ The Pass 3 orchestrator (`bin/commands/init.js`) classifies each
593
+ domain via `project-analysis.json` and emits per-domain target paths
594
+ explicitly in the batch scope note. **Follow the explicit
595
+ per-domain target paths shown in the scope note** rather than infer
596
+ from the domain name. If the scope note shows
597
+ `order → claudeos-core/standard/70.domains/backend/order.md`, that's
598
+ the path to use — the type sub-folder is already classified for you.
599
+
600
+ - Per-domain skill notes:
601
+ `claudeos-core/skills/{category}/domains/{domain}.md`
602
+ (sub-folder under skill category — `skills/` is a separate namespace
603
+ from standard/rules, so no number prefix here. The `{category}`
604
+ folder name already encodes stack: `10.backend-crud/`,
605
+ `20.frontend-page/`. So skills don't need the additional `{type}/`
606
+ sub-folder that standard/rules use.)
607
+ - Per-domain skill ORCHESTRATOR (sibling to the `domains/` sub-folder):
608
+ `claudeos-core/skills/{category}/02.domains.md`
609
+ The orchestrator is REQUIRED when the `domains/` sub-folder is
610
+ populated. It mirrors the canonical pattern already used for
611
+ `01.scaffold-crud-feature.md` ↔ `scaffold-crud-feature/` (orchestrator
612
+ file at category root + sub-folder of the same stem). The basename
613
+ stem (`domains`) MUST match the sub-folder name so
614
+ `content-validator`'s standard orchestrator-stem matching covers
615
+ the sub-skills directly — without depending on the
616
+ global-MANIFEST coverage fallback. The orchestrator content lists
617
+ every per-domain note file in the `domains/` sub-folder, links to
618
+ `00.shared/MANIFEST.md`, and describes the per-domain anti-pattern
619
+ catalog if applicable. Numbered `02.` because `01.scaffold-*-feature.md`
620
+ already occupies the `01.` slot at the category root.
621
+
622
+ Why `70.` and not `60.`: `60.memory/*` is the canonical L4 memory rules
623
+ folder (regression-guarded since v2.0.0; cannot move to 70). Putting
624
+ domains at `60.domains/` causes a `60.` prefix collision with
625
+ `60.memory/` that makes directory listings ambiguous. `70.domains/` sits
626
+ after memory and before `90.optional/`, giving per-domain content its
627
+ own clean slot.
628
+
629
+ Why PLURAL `domains/`: the folder holds N files, one per project domain
630
+ — `payment.md`, `order.md`, etc. This matches the standard filesystem
631
+ convention for collections (`users/user.md`, `posts/post.md`). The other
632
+ numbered category folders (`00.core/`, `10.backend/`, etc.) are singular
633
+ because each represents ONE topic, not a collection of items.
634
+
635
+ DO NOT use:
636
+ - `60.domains/` (collides with `60.memory/`)
637
+ - `70.domain/` (singular is wrong for a collection folder)
638
+ - Inlining per-domain content into `00.core/*` or topical files
639
+ (per-domain content is DOMAIN-scoped, topical files are TOPIC-scoped
640
+ — `paths` glob scoping breaks if they share files)
641
+
538
642
  After completion, run the following commands in order:
539
643
  1. npx claudeos-core health
@@ -79,21 +79,21 @@ Generation targets:
79
79
  - 00.core/01.project-overview.md — Stack, modules, API server info
80
80
  - 00.core/02.architecture.md — Layer structure, request flow, package structure
81
81
  - 00.core/03.naming-conventions.md — Class/DTO/Entity/table naming conventions
82
- - 10.backend-api/01.controller-patterns.md — Controller writing rules + examples
83
- - 10.backend-api/02.service-patterns.md — Transactions, DI, business logic patterns
84
- - 10.backend-api/03.data-access-patterns.md — ORM patterns (tailored to detected MyBatis/JPA/QueryDSL)
85
- - 10.backend-api/04.response-exception.md — Response/error handling patterns
86
- - 10.backend-api/05.dto-validation.md — DTO writing rules, Validation
87
- - 10.backend-api/06.interceptor-filter-aop.md — Middleware, AOP, logging interceptors
88
- - 20.frontend-ui/* — (generate only if frontend detected)
82
+ - 10.backend/01.controller-patterns.md — Controller writing rules + examples
83
+ - 10.backend/02.service-patterns.md — Transactions, DI, business logic patterns
84
+ - 10.backend/03.data-access-patterns.md — ORM patterns (tailored to detected MyBatis/JPA/QueryDSL)
85
+ - 10.backend/04.response-exception.md — Response/error handling patterns
86
+ - 10.backend/05.dto-validation.md — DTO writing rules, Validation
87
+ - 10.backend/06.interceptor-filter-aop.md — Middleware, AOP, logging interceptors
88
+ - 20.frontend/* — (generate only if frontend detected)
89
89
  - 30.security-db/01.security-auth.md — Authentication, authorization, CORS
90
90
  - 30.security-db/02.database-schema.md — DDL, migrations, audit columns
91
91
  - 30.security-db/03.common-utilities.md — Common utilities, constants, Base classes
92
92
  - 40.infra/01.environment-config.md — Profiles, environment variables, configuration management
93
93
  - 40.infra/02.logging-monitoring.md — Logging standards, monitoring, alerts
94
94
  - 40.infra/03.cicd-deployment.md — CI/CD pipeline, deployment strategy
95
- - 50.verification/01.development-verification.md — Build, startup, API testing
96
- - 50.verification/02.testing-strategy.md — Testing strategy, mocking, coverage
95
+ - 80.verification/01.development-verification.md — Build, startup, API testing
96
+ - 80.verification/02.testing-strategy.md — Testing strategy, mocking, coverage
97
97
 
98
98
  Each file MUST include:
99
99
  - Correct examples (✅ code blocks)
@@ -107,7 +107,7 @@ Generation targets:
107
107
  - Each rule file MUST end with a `## Reference` section linking to the corresponding standard file(s):
108
108
  ```
109
109
  ## Reference
110
- > For detailed patterns and examples, Read: claudeos-core/standard/10.backend-api/01.controller-patterns.md
110
+ > For detailed patterns and examples, Read: claudeos-core/standard/10.backend/01.controller-patterns.md
111
111
  ```
112
112
  - `paths:` frontmatter per rule category:
113
113
  - `00.core/*` rules: `paths: ["**/*"]` — always loaded (architecture, naming are universally needed)
@@ -118,6 +118,7 @@ Generation targets:
118
118
  - `40.infra/03.cicd-deployment-rules.md` paths: `["**/*.yml", "**/*.yaml", "**/Dockerfile*", "**/*.gradle*", "**/pom.xml", "**/*.java"]` — CI / build config + source
119
119
  - `50.sync/*` rules: `paths: ["**/claudeos-core/**", "**/.claude/**"]` — loaded only when editing claudeos-core files
120
120
  - `60.memory/*` rules: forward reference — Pass 4 will generate 4 files (01.decision-log, 02.failure-patterns, 03.compaction, 04.auto-rule-update), each with file-specific `paths`. Pass 3 must STILL list ```.claude/rules/60.memory/*``` as a row in CLAUDE.md Section 6 Rules table so developers/Claude see the category exists.
121
+ - `70.domains/*` rules (multi-domain projects only): per-domain rules at `.claude/rules/70.domains/{type}/{domain}-rules.md` (where `{type}` is `backend` or `frontend`, ALWAYS present even in single-stack projects for uniform layout + zero-migration future-proofing), each with a `paths:` glob scoped to that domain's source directories so the rule auto-loads only when editing files within the relevant domain. Folder name is PLURAL (`domains/`) — collection of N per-domain files — and each file inside uses the SINGULAR domain name (`{domain}-rules.md`). DO NOT use `60.domains/` (collides with `60.memory/`) and DO NOT skip the `{type}/` sub-folder. See pass3-footer.md "Per-domain folder convention" for the full rationale.
121
122
  - MUST generate `.claude/rules/00.core/00.standard-reference.md` — a directory of all standard files. This is NOT a "read all" instruction. Claude should Read ONLY the standards relevant to the current task. Structure it as:
122
123
  ```
123
124
  ---
@@ -134,12 +135,12 @@ Generation targets:
134
135
  - claudeos-core/standard/00.core/03.naming-conventions.md
135
136
  - claudeos-core/standard/00.core/04.doc-writing-guide.md
136
137
  ## Backend API
137
- - claudeos-core/standard/10.backend-api/01.controller-patterns.md
138
- - claudeos-core/standard/10.backend-api/02.service-patterns.md
139
- - claudeos-core/standard/10.backend-api/03.data-access-patterns.md
140
- - claudeos-core/standard/10.backend-api/04.response-exception.md
141
- - claudeos-core/standard/10.backend-api/05.dto-validation.md
142
- - claudeos-core/standard/10.backend-api/06.interceptor-filter-aop.md
138
+ - claudeos-core/standard/10.backend/01.controller-patterns.md
139
+ - claudeos-core/standard/10.backend/02.service-patterns.md
140
+ - claudeos-core/standard/10.backend/03.data-access-patterns.md
141
+ - claudeos-core/standard/10.backend/04.response-exception.md
142
+ - claudeos-core/standard/10.backend/05.dto-validation.md
143
+ - claudeos-core/standard/10.backend/06.interceptor-filter-aop.md
143
144
  ## Security & DB
144
145
  - claudeos-core/standard/30.security-db/01.security-auth.md
145
146
  - claudeos-core/standard/30.security-db/02.database-schema.md
@@ -148,8 +149,8 @@ Generation targets:
148
149
  - claudeos-core/standard/40.infra/01.environment-config.md
149
150
  - claudeos-core/standard/40.infra/02.logging-monitoring.md
150
151
  - claudeos-core/standard/40.infra/03.cicd-deployment.md
151
- - claudeos-core/standard/50.verification/01.development-verification.md
152
- - claudeos-core/standard/50.verification/02.testing-strategy.md
152
+ - claudeos-core/standard/80.verification/01.development-verification.md
153
+ - claudeos-core/standard/80.verification/02.testing-strategy.md
153
154
  ```
154
155
  List only the standard files that were actually generated above. Include frontend standards only if frontend was detected. NOTE: `00.core/04.doc-writing-guide.md` is a FORWARD REFERENCE — Pass 4 will generate it; include it anyway. Do NOT add a "DO NOT Read" section here — that information lives in CLAUDE.md Section 7 (the single source of truth).
155
156