claudeos-core 2.0.2 → 2.1.1

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 (42) hide show
  1. package/CHANGELOG.md +208 -0
  2. package/README.de.md +961 -880
  3. package/README.es.md +960 -880
  4. package/README.fr.md +960 -880
  5. package/README.hi.md +960 -880
  6. package/README.ja.md +960 -880
  7. package/README.ko.md +126 -47
  8. package/README.md +126 -46
  9. package/README.ru.md +960 -880
  10. package/README.vi.md +128 -48
  11. package/README.zh-CN.md +959 -880
  12. package/bin/cli.js +7 -2
  13. package/bin/commands/init.js +733 -143
  14. package/bin/commands/memory.js +17 -5
  15. package/bootstrap.sh +81 -81
  16. package/lib/expected-outputs.js +6 -7
  17. package/lib/memory-scaffold.js +84 -46
  18. package/lib/plan-parser.js +12 -0
  19. package/manifest-generator/index.js +16 -18
  20. package/package.json +1 -1
  21. package/pass-prompts/templates/angular/pass3.md +2 -10
  22. package/pass-prompts/templates/common/pass3-phase1.md +131 -0
  23. package/pass-prompts/templates/common/pass3a-facts.md +143 -0
  24. package/pass-prompts/templates/common/pass3b-core-header.md +58 -0
  25. package/pass-prompts/templates/common/pass3c-skills-guide-header.md +53 -0
  26. package/pass-prompts/templates/common/pass3d-plan-aux-header.md +57 -0
  27. package/pass-prompts/templates/common/pass4.md +4 -19
  28. package/pass-prompts/templates/java-spring/pass3.md +5 -15
  29. package/pass-prompts/templates/kotlin-spring/pass3.md +5 -15
  30. package/pass-prompts/templates/node-express/pass3.md +5 -14
  31. package/pass-prompts/templates/node-fastify/pass3.md +2 -10
  32. package/pass-prompts/templates/node-nestjs/pass3.md +5 -13
  33. package/pass-prompts/templates/node-nextjs/pass3.md +5 -14
  34. package/pass-prompts/templates/node-vite/pass3.md +95 -103
  35. package/pass-prompts/templates/python-django/pass3.md +5 -14
  36. package/pass-prompts/templates/python-fastapi/pass3.md +5 -14
  37. package/pass-prompts/templates/python-flask/pass3.md +95 -103
  38. package/pass-prompts/templates/vue-nuxt/pass3.md +2 -10
  39. package/plan-installer/pass3-context-builder.js +258 -0
  40. package/plan-installer/prompt-generator.js +9 -1
  41. package/plan-validator/index.js +23 -8
  42. package/sync-checker/index.js +44 -0
package/README.md CHANGED
@@ -222,7 +222,7 @@ npx claudeos-core init --lang en # English (default)
222
222
 
223
223
  > **Note:** This sets the language for generated documentation files only. Code analysis (Pass 1–2) always runs in English; generated output (Pass 3) is written in your chosen language. Code examples inside the generated files remain in their original programming language syntax.
224
224
 
225
- That's it. After 5–20 minutes (Pass 1×N + Pass 2 + Pass 3 + Pass 4 memory scaffolding), all documentation is generated and ready to use. The CLI shows a progress bar with percentage, elapsed time, and ETA for each pass.
225
+ That's it. After 10 minutes (small project) to 2 hours (60+ domain monorepo), all documentation is generated and ready to use. The CLI shows a progress bar with percentage, elapsed time, and ETA for each pass. See [Auto-scaling by Project Size](#auto-scaling-by-project-size) for detailed timing by project size.
226
226
 
227
227
  ### Manual Step-by-Step Installation
228
228
 
@@ -249,11 +249,13 @@ mkdir -p claudeos-core/standard/{00.core,10.backend-api,20.frontend-ui,30.securi
249
249
  # Skills
250
250
  mkdir -p claudeos-core/skills/{00.shared,10.backend-crud/scaffold-crud-feature,20.frontend-page/scaffold-page-feature,50.testing,90.experimental}
251
251
 
252
- # Guide, Plan, Database, MCP, Generated, Memory (v2.0.0: added memory)
252
+ # Guide, Database, MCP, Generated, Memory (v2.0.0: added memory; v2.1.0: removed plan)
253
253
  mkdir -p claudeos-core/guide/{01.onboarding,02.usage,03.troubleshooting,04.architecture}
254
- mkdir -p claudeos-core/{plan,database,mcp-guide,generated,memory}
254
+ mkdir -p claudeos-core/{database,mcp-guide,generated,memory}
255
255
  ```
256
256
 
257
+ > **v2.1.0 note:** The `claudeos-core/plan/` directory is no longer created. Master plan generation was removed because master plans were an internal backup Claude Code never reads at runtime, and aggregating them triggered `Prompt is too long` failures. Use `git` for backup/restore.
258
+
257
259
  #### Step 3: Run plan-installer (project analysis)
258
260
 
259
261
  This scans your project, detects the stack, finds domains, splits them into groups, and generates prompts.
@@ -267,7 +269,8 @@ node claudeos-core-tools/plan-installer/index.js
267
269
  - `domain-groups.json` — domain groups for Pass 1
268
270
  - `pass1-backend-prompt.md` / `pass1-frontend-prompt.md` — analysis prompts
269
271
  - `pass2-prompt.md` — merge prompt
270
- - `pass3-prompt.md` — generation prompt (wrapped with `staging-override.md` directive see Step 6 note)
272
+ - `pass3-prompt.md` — Pass 3 prompt template with the Phase 1 "Read Once, Extract Facts" block prepended (Rules A–E). The automated pipeline splits Pass 3 into multiple stages at runtime; this template feeds each stage.
273
+ - `pass3-context.json` — slim project summary (< 5 KB, built after Pass 2) that Pass 3 prompts prefer over the full `pass2-merged.json` (v2.1.0)
271
274
  - `pass4-prompt.md` — L4 memory scaffolding prompt (v2.0.0; uses the same `staging-override.md` for `60.memory/` rule writes)
272
275
 
273
276
  You can inspect these files to verify detection accuracy before proceeding.
@@ -322,16 +325,35 @@ cat claudeos-core/generated/pass2-prompt.md \
322
325
 
323
326
  **Verify:** `claudeos-core/generated/pass2-merged.json` should exist with 9+ top-level keys.
324
327
 
325
- #### Step 6: Pass 3 — Generate all documentation
328
+ #### Step 6: Pass 3 — Generate all documentation (split into multiple stages)
329
+
330
+ **v2.1.0 note:** Pass 3 is **always run in split mode** by the automated pipeline. Each stage is a separate `claude -p` call with a fresh context window, so output-accumulation overflow is structurally impossible regardless of project size. The `pass3-prompt.md` template is assembled per-stage with a `STAGE:` directive that tells Claude which subset of files to emit. For manual mode, the simplest path is still to feed the full template and let Claude generate everything in one call — but this is only reliable on small projects (≤5 domains). For anything larger, use `npx claudeos-core init` so the split runner handles stage orchestration.
331
+
332
+ **Single-call mode (small projects only, ≤5 domains):**
326
333
 
327
334
  ```bash
328
335
  cat claudeos-core/generated/pass3-prompt.md \
329
336
  | claude -p --dangerously-skip-permissions
330
337
  ```
331
338
 
332
- **Verify:** `CLAUDE.md` should exist in your project root, and `claudeos-core/generated/pass3-complete.json` marker should be written.
339
+ **Stage-by-stage mode (recommended for all project sizes):**
340
+
341
+ The automated pipeline runs these stages. The stage list is:
342
+
343
+ | Stage | Writes | Notes |
344
+ |---|---|---|
345
+ | `3a` | `pass3a-facts.md` (5–10 KB distilled fact sheet) | Reads `pass2-merged.json` once; later stages reference this file |
346
+ | `3b-core` | `CLAUDE.md`, common `standard/`, common `.claude/rules/` | Cross-project files; no domain-specific output |
347
+ | `3b-1..N` | Domain-specific `standard/60.domains/*.md` + domain rules | Batch of ≤15 domains per stage (auto-divided at ≥16 domains) |
348
+ | `3c-core` | `guide/` (9 files), `skills/00.shared/MANIFEST.md`, `skills/*/` orchestrators | Shared skills and all user-facing guides |
349
+ | `3c-1..N` | Domain sub-skills under `skills/20.frontend-page/scaffold-page-feature/` | Batch of ≤15 domains per stage |
350
+ | `3d-aux` | `database/`, `mcp-guide/` | Fixed-size, independent of domain count |
333
351
 
334
- > **Note (v2.0.0):** Pass 3 writes rule files to `claudeos-core/generated/.staged-rules/` first because Claude Code's sensitive-path policy blocks direct writes to `.claude/`. The automated pipeline (`npx claudeos-core init`) handles the move automatically. If you run this step manually, you'll need to move the staged tree yourself: `mv claudeos-core/generated/.staged-rules/* .claude/rules/` (preserve subpaths).
352
+ For a 1–15 domain project this expands to 4 stages (`3a`, `3b-core`, `3c-core`, `3d-aux` no batch sub-division). For 16–30 domains it expands to 8 stages (`3b` and `3c` each sub-divided into 2 batches). See [Auto-scaling by Project Size](#auto-scaling-by-project-size) for the full table.
353
+
354
+ **Verify:** `CLAUDE.md` should exist in your project root, and `claudeos-core/generated/pass3-complete.json` marker should be written. In split mode, the marker contains `mode: "split"` and a `groupsCompleted` array listing every stage that finished — the partial-marker logic uses this to resume from the right stage after a crash rather than restarting from `3a` (which would double the token cost).
355
+
356
+ > **Staging note:** Pass 3 writes rule files to `claudeos-core/generated/.staged-rules/` first because Claude Code's sensitive-path policy blocks direct writes to `.claude/`. The automated pipeline handles the move automatically after each stage. If you run a stage manually, you'll need to move the staged tree yourself: `mv claudeos-core/generated/.staged-rules/* .claude/rules/` (preserve subpaths).
335
357
 
336
358
  #### Step 7: Pass 4 — Memory scaffolding
337
359
 
@@ -340,7 +362,9 @@ cat claudeos-core/generated/pass4-prompt.md \
340
362
  | claude -p --dangerously-skip-permissions
341
363
  ```
342
364
 
343
- **Verify:** `claudeos-core/memory/` should contain 4 files (`decision-log.md`, `failure-patterns.md`, `compaction.md`, `auto-rule-update.md`), `.claude/rules/60.memory/` should contain 4 rule files, `claudeos-core/plan/50.memory-master.md` should exist, and `CLAUDE.md` should now have a `## Memory (L4)` section appended. Marker: `claudeos-core/generated/pass4-memory.json`.
365
+ **Verify:** `claudeos-core/memory/` should contain 4 files (`decision-log.md`, `failure-patterns.md`, `compaction.md`, `auto-rule-update.md`), `.claude/rules/60.memory/` should contain 4 rule files, and `CLAUDE.md` should have a `## Memory (L4)` section appended. Marker: `claudeos-core/generated/pass4-memory.json`.
366
+
367
+ > **v2.1.0 gap-fill:** Pass 4 also ensures `claudeos-core/skills/00.shared/MANIFEST.md` exists. If Pass 3c omitted it (possible on skill-sparse projects because the stack `pass3.md` templates list `MANIFEST.md` among generation targets without marking it REQUIRED), the gap-fill creates a minimal stub so that `.claude/rules/50.sync/03.skills-sync.md` always has a valid reference target. Idempotent: skips if the file already has real content (>20 chars).
344
368
 
345
369
  > **Note:** If `claude -p` fails or `pass4-prompt.md` is missing, the automated pipeline falls back to a static scaffold via `lib/memory-scaffold.js` (with Claude-driven translation when `--lang` is non-English). The static fallback runs only inside `npx claudeos-core init` — manual mode requires Pass 4 to succeed.
346
370
 
@@ -396,31 +420,42 @@ ls .claude/rules/*/
396
420
  ```
397
421
  npx claudeos-core init
398
422
 
399
- ├── [1] npm install ← Dependencies (~10s)
400
- ├── [2] Directory structure ← Create folders (~1s)
401
- ├── [3] plan-installer (Node.js) ← Project scan (~5s)
423
+ ├── [1] npm install ← Dependencies (~10s)
424
+ ├── [2] Directory structure ← Create folders (~1s)
425
+ ├── [3] plan-installer (Node.js) ← Project scan (~5s)
402
426
  │ ├── Auto-detect stack (multi-stack aware)
403
427
  │ ├── Extract domain list (tagged: backend/frontend)
404
428
  │ ├── Split into domain groups (per type)
429
+ │ ├── Build pass3-context.json (slim summary, v2.1.0)
405
430
  │ └── Select stack-specific prompts (per type)
406
431
 
407
- ├── [4] Pass 1 × N (claude -p) ← Deep code analysis (~2-8min)
432
+ ├── [4] Pass 1 × N (claude -p) ← Deep code analysis (~2-8min)
408
433
  │ ├── ⚙️ Backend groups → backend-specific prompt
409
434
  │ └── 🎨 Frontend groups → frontend-specific prompt
410
435
 
411
- ├── [5] Pass 2 × 1 (claude -p) ← Merge analysis (~1min)
412
- │ └── Consolidate ALL Pass 1 results (backend + frontend)
436
+ ├── [5] Pass 2 × 1 (claude -p) ← Merge analysis (~1min)
437
+ │ └── Consolidate ALL Pass 1 results into pass2-merged.json
413
438
 
414
- ├── [6] Pass 3 × 1 (claude -p) ← Generate everything (~3-5min)
415
- └── Combined prompt (backend + frontend targets)
439
+ ├── [6] Pass 3 (split mode, v2.1.0) ← Generate everything
440
+
441
+ │ ├── 3a × 1 (claude -p) ← Fact extraction (~5-10min)
442
+ │ │ └── Read pass2-merged.json once → pass3a-facts.md
443
+ │ │
444
+ │ ├── 3b-core × 1 (claude -p) ← CLAUDE.md + common standard/rules
445
+ │ ├── 3b-1..N × N (claude -p) ← Domain standards/rules (≤15 domains/batch)
446
+ │ │
447
+ │ ├── 3c-core × 1 (claude -p) ← Guides + shared skills + MANIFEST.md
448
+ │ ├── 3c-1..N × N (claude -p) ← Domain sub-skills (≤15 domains/batch)
449
+ │ │
450
+ │ └── 3d-aux × 1 (claude -p) ← database/ + mcp-guide/ stubs
416
451
 
417
- ├── [7] Pass 4 × 1 (claude -p) ← Memory scaffolding (~30s)
452
+ ├── [7] Pass 4 × 1 (claude -p) ← Memory scaffolding (~30s-5min)
418
453
  │ ├── Seed memory/ (decision-log, failure-patterns, …)
419
454
  │ ├── Generate 60.memory/ rules
420
455
  │ ├── Append "Memory (L4)" section to CLAUDE.md
421
- │ └── Build 50.memory-master.md plan
456
+ │ └── Gap-fill: ensure skills/00.shared/MANIFEST.md exists (v2.1.0)
422
457
 
423
- └── [8] Verification ← Auto-run health checker
458
+ └── [8] Verification ← Auto-run health checker
424
459
  ```
425
460
 
426
461
  ### Why 4 Passes?
@@ -429,9 +464,17 @@ npx claudeos-core init
429
464
 
430
465
  **Pass 2** merges all Pass 1 results into a unified analysis: common patterns (100% shared), majority patterns (50%+ shared), domain-specific patterns, anti-patterns by severity, and cross-cutting concerns (naming, security, DB, testing, logging, performance). Backend and frontend results are merged together.
431
466
 
432
- **Pass 3** takes the merged analysis and generates the entire file ecosystem (CLAUDE.md, rules, standards, skills, guides). It never reads source code only the analysis JSON. In multi-stack mode, the generation prompt combines backend and frontend targets so both sets of standards are generated in a single pass.
467
+ **Pass 3** (split mode, v2.1.0) takes the merged analysis and generates the entire file ecosystem (CLAUDE.md, rules, standards, skills, guides) across multiple sequential `claude -p` calls. The key insight is that output-accumulation overflow is not predictable from input size: single-call Pass 3 worked fine on 2-domain projects and reliably failed at ~5 domains, and the failure boundary shifted depending on how verbose each file happened to be. Split mode sidesteps this entirely — each stage starts with a fresh context window and writes a bounded subset of files. Cross-stage consistency (which was the main advantage of the single-call approach) is preserved by `pass3a-facts.md`, a 5–10 KB distilled fact sheet that every subsequent stage references.
468
+
469
+ The Pass 3 prompt template also includes a **Phase 1 "Read Once, Extract Facts" block** with five rules that further constrain output volume:
470
+
471
+ - **Rule A** — Reference the fact table; don't re-read `pass2-merged.json`.
472
+ - **Rule B** — Idempotent file writing (skip if target exists with real content), making Pass 3 safely re-runnable after interruption.
473
+ - **Rule C** — Cross-file consistency enforced via the fact table as single source of truth.
474
+ - **Rule D** — Output conciseness: one line (`[WRITE]`/`[SKIP]`) between file writes, no restating the fact table, no echoing file content.
475
+ - **Rule E** — Batch idempotent check: one `Glob` at PHASE 2 start instead of per-target `Read` calls.
433
476
 
434
- **Pass 4** scaffolds the L4 Memory layer: persistent team knowledge files (decision-log, failure-patterns, compaction policy, auto-rule-update) plus the `60.memory/` rules that tell future sessions when and how to read/write those files. The memory layer is what lets Claude Code accumulate lessons across sessions instead of re-discovering them each time. When `--lang` is non-English, the fallback static content is translated via Claude before being written.
477
+ **Pass 4** scaffolds the L4 Memory layer: persistent team knowledge files (decision-log, failure-patterns, compaction policy, auto-rule-update) plus the `60.memory/` rules that tell future sessions when and how to read/write those files. The memory layer is what lets Claude Code accumulate lessons across sessions instead of re-discovering them each time. When `--lang` is non-English, the fallback static content is translated via Claude before being written. v2.1.0 adds a gap-fill for `skills/00.shared/MANIFEST.md` in case Pass 3c omitted it.
435
478
 
436
479
  ---
437
480
 
@@ -459,23 +502,30 @@ your-project/
459
502
  │ │ ├── pass1-backend-prompt.md ← Backend analysis prompt
460
503
  │ │ ├── pass1-frontend-prompt.md ← Frontend analysis prompt (if detected)
461
504
  │ │ ├── pass2-prompt.md ← Merge prompt
462
- │ │ ├── pass3-prompt.md Generation prompt (combined)
505
+ │ │ ├── pass2-merged.json Pass 2 output (consumed by Pass 3a only)
506
+ │ │ ├── pass3-context.json ← Slim summary (< 5 KB) for Pass 3 (v2.1.0)
507
+ │ │ ├── pass3-prompt.md ← Pass 3 prompt template (Phase 1 block prepended)
508
+ │ │ ├── pass3a-facts.md ← Fact sheet written by Pass 3a, read by 3b/3c/3d (v2.1.0)
463
509
  │ │ ├── pass4-prompt.md ← Memory scaffolding prompt (v2.0.0)
464
- │ │ ├── pass3-complete.json ← Pass 3 completion marker (skip on resume)
510
+ │ │ ├── pass3-complete.json ← Pass 3 completion marker (split mode: includes groupsCompleted, v2.1.0)
465
511
  │ │ ├── pass4-memory.json ← Pass 4 completion marker (skip on resume)
512
+ │ │ ├── rule-manifest.json ← File index for verification tools
513
+ │ │ ├── sync-map.json ← Plan ↔ disk mapping (empty in v2.1.0; kept for sync-checker compat)
514
+ │ │ ├── stale-report.json ← Consolidated verification results
466
515
  │ │ ├── .i18n-cache-<lang>.json ← Translation cache (non-English `--lang`)
467
516
  │ │ └── .staged-rules/ ← Transient staging dir for `.claude/rules/` writes (auto-moved + cleaned)
468
- │ ├── standard/ ← Coding standards (15-19 files)
517
+ │ ├── standard/ ← Coding standards (15-19 files + per-domain in 60.domains/)
469
518
  │ │ ├── 00.core/ ← Overview, architecture, naming
470
519
  │ │ ├── 10.backend-api/ ← API patterns (stack-specific)
471
520
  │ │ ├── 20.frontend-ui/ ← Frontend patterns (if detected)
472
521
  │ │ ├── 30.security-db/ ← Security, DB schema, utilities
473
522
  │ │ ├── 40.infra/ ← Config, logging, CI/CD
474
523
  │ │ ├── 50.verification/ ← Build verification, testing
524
+ │ │ ├── 60.domains/ ← Per-domain standards (written by Pass 3b-N, v2.1.0)
475
525
  │ │ └── 90.optional/ ← Optional conventions (stack-specific extras)
476
- │ ├── skills/ ← CRUD scaffolding skills
526
+ │ ├── skills/ ← CRUD/page scaffolding skills
527
+ │ │ └── 00.shared/MANIFEST.md ← Single source of truth for registered skills
477
528
  │ ├── guide/ ← Onboarding, FAQ, troubleshooting (9 files)
478
- │ ├── plan/ ← Master plans (backup/restore)
479
529
  │ ├── database/ ← DB schema, migration guide
480
530
  │ ├── mcp-guide/ ← MCP server integration guide
481
531
  │ └── memory/ ← L4: team knowledge (4 files) — commit these
@@ -489,6 +539,8 @@ your-project/
489
539
 
490
540
  Every standard file includes ✅ correct examples, ❌ incorrect examples, and a rules summary table — all derived from your actual code patterns, not generic templates.
491
541
 
542
+ > **v2.1.0 note:** `claudeos-core/plan/` is no longer generated. Master plans were an internal backup that Claude Code didn't consume at runtime, and aggregating them in Pass 3 was a primary cause of output-accumulation overflow. Use `git` for backup/restore instead. Projects upgrading from v2.0.x can safely delete any existing `claudeos-core/plan/` directory.
543
+
492
544
  ### Gitignore recommendations
493
545
 
494
546
  **Do commit** (team knowledge — meant to be shared):
@@ -510,14 +562,20 @@ The `generated/` directory contains analysis JSON (`pass1-*.json`, `pass2-merged
510
562
 
511
563
  ## Auto-scaling by Project Size
512
564
 
513
- | Size | Domains | Pass 1 Runs | Total `claude -p` | Est. Time |
565
+ Pass 3's split mode scales stage count with domain count. The batch sub-division kicks in at 16 domains to keep each stage under ~50 files of output, which is the empirical safe range for `claude -p` before output-accumulation overflow starts.
566
+
567
+ | Project Size | Domains | Pass 3 Stages | Total `claude -p` | Est. Time |
514
568
  |---|---|---|---|---|
515
- | Small | 1–4 | 1 | 4 (Pass 1 + 2 + 3 + 4) | ~56min |
516
- | Medium | 5–8 | 2 | 5 | ~89min |
517
- | Large | 916 | 3–4 | 67 | ~1213min |
518
- | X-Large | 17+ | 5+ | 8+ | ~18min+ |
569
+ | Small | 1–4 | 4 (`3a`, `3b-core`, `3c-core`, `3d-aux`) | 7 (Pass 1 + 2 + 4 stages of Pass 3 + Pass 4) | ~1015 min |
570
+ | Medium | 5–15 | 4 | 8–9 | ~2545 min |
571
+ | Large | 1630 | **8** (3b, 3c each split into 2 batches) | 1112 | **~60105 min** |
572
+ | X-Large | 31–45 | 10 | 13–14 | ~100–150 min |
573
+ | XX-Large | 46–60 | 12 | 15–16 | ~150–200 min |
574
+ | XXX-Large | 61+ | 14+ | 17+ | 200 min+ |
575
+
576
+ Stage count formula (when batched): `1 (3a) + 1 (3b-core) + N (3b-1..N) + 1 (3c-core) + N (3c-1..N) + 1 (3d-aux) = 2N + 4`, where `N = ceil(totalDomains / 15)`.
519
577
 
520
- Pass 4 (memory scaffolding) adds ~30s on top of the analysis passes. For multi-stack projects (e.g., Java + React), backend and frontend domains are counted together. A project with 6 backend + 4 frontend domains = 10 total, scaling as "Large".
578
+ Pass 4 (memory scaffolding) adds ~30 seconds to 5 minutes on top depending on whether Claude-driven generation or static fallback runs. For multi-stack projects (e.g., Java + React), backend and frontend domains are counted together. A project with 6 backend + 4 frontend domains = 10 total = Medium tier.
521
579
 
522
580
  ---
523
581
 
@@ -543,11 +601,11 @@ node claudeos-core-tools/sync-checker/index.js
543
601
 
544
602
  | Tool | What It Does |
545
603
  |---|---|
546
- | **manifest-generator** | Builds metadata JSON (rule-manifest, sync-map, plan-manifest); indexes 7 directories including `memory/` (`totalMemory` in summary) |
547
- | **plan-validator** | Compares Master Plan `<file>` blocks against disk 3 modes: check, refresh, restore |
548
- | **sync-checker** | Detects unregistered files (on disk but not in plan) and orphaned entries — covers 7 directories (added `memory/` in v2.0.0) |
604
+ | **manifest-generator** | Builds metadata JSON (`rule-manifest.json`, `sync-map.json`, initializes `stale-report.json`); indexes 7 directories including `memory/` (`totalMemory` in summary). v2.1.0: `plan-manifest.json` is no longer generated since master plans were removed. |
605
+ | **plan-validator** | Validates master plan `<file>` blocks against disk for projects that still have `claudeos-core/plan/` (legacy upgrade case). v2.1.0: skips `plan-sync-status.json` emission when `plan/` is absent or empty — `stale-report.json` still records a passing no-op. |
606
+ | **sync-checker** | Detects unregistered files (on disk but not in plan) and orphaned entries — covers 7 directories (added `memory/` in v2.0.0). Exits cleanly when `sync-map.json` has no mappings (v2.1.0 default state). |
549
607
  | **content-validator** | 9-section quality check — empty files, missing ✅/❌ examples, required sections, plus L4 memory scaffold integrity (decision-log heading dates, failure-pattern required fields, fence-aware parsing) |
550
- | **pass-json-validator** | Validates Pass 1–4 JSON structure plus the `pass3-complete.json` and `pass4-memory.json` completion markers |
608
+ | **pass-json-validator** | Validates Pass 1–4 JSON structure plus the `pass3-complete.json` (split-mode shape, v2.1.0) and `pass4-memory.json` completion markers |
551
609
 
552
610
  ---
553
611
 
@@ -584,7 +642,7 @@ These folders are explicitly excluded via the `DO NOT Read` section in the stand
584
642
 
585
643
  | Folder | Why excluded |
586
644
  |---|---|
587
- | `claudeos-core/plan/` | Master Plan backups (~340KB). Use `npx claudeos-core refresh` to sync. |
645
+ | `claudeos-core/plan/` | Master plan backups from legacy projects (v2.0.x and earlier). Not generated in v2.1.0. If present, Claude Code won't load it automatically — read-on-demand only. |
588
646
  | `claudeos-core/generated/` | Build metadata JSON, prompts, Pass markers, translation cache, `.staged-rules/`. Not for coding. |
589
647
  | `claudeos-core/guide/` | Onboarding guides for humans. |
590
648
  | `claudeos-core/mcp-guide/` | MCP server docs. Not for coding. |
@@ -616,7 +674,12 @@ npx claudeos-core health
616
674
  ### When Docs Get Corrupted
617
675
 
618
676
  ```bash
619
- # Restore everything from Master Plan
677
+ # v2.1.0 recommendation: use git to restore (since master plans are no
678
+ # longer generated). Commit your generated docs regularly so you can roll
679
+ # back specific files without regenerating:
680
+ git checkout HEAD -- .claude/rules/ claudeos-core/
681
+
682
+ # Legacy (v2.0.x projects with claudeos-core/plan/ still present):
620
683
  npx claudeos-core restore
621
684
  ```
622
685
 
@@ -643,8 +706,13 @@ npx claudeos-core memory propose-rules
643
706
  # Computes confidence (sigmoid on weighted evidence × anchor multiplier)
644
707
  # Writes proposals to memory/auto-rule-update.md (NOT auto-applied)
645
708
  # Confidence ≥ 0.70 deserves serious review; accept → edit rule + log decision
709
+
710
+ # v2.1.0: `memory --help` now routes to subcommand help (was showing top-level)
711
+ npx claudeos-core memory --help
646
712
  ```
647
713
 
714
+ > **v2.1.0 fixes:** `memory score` no longer leaves duplicate `importance` lines after the first run (previously the auto-scored line was added on top while the original plain line was left below). `memory compact`'s Stage 1 summary marker is now a proper markdown list item (`- _Summarized on ..._`) so it renders cleanly and is correctly re-parsed on subsequent compactions.
715
+
648
716
  When to write to memory (Claude does this on-demand, but you can edit manually too):
649
717
  - **`decision-log.md`** — append a new entry whenever you choose between competing patterns, select a library, define a team convention, or decide NOT to do something. Append-only; never edit historical entries.
650
718
  - **`failure-patterns.md`** — append on the **second occurrence** of a recurring error or non-obvious root cause. First-time errors don't need an entry.
@@ -707,19 +775,21 @@ You can use ClaudeOS-Core to generate your project's rules, then use ECC or Harn
707
775
  No. It only creates `CLAUDE.md`, `.claude/rules/`, and `claudeos-core/`. Your existing code is never modified.
708
776
 
709
777
  **Q: How much does it cost?**
710
- It calls `claude -p` 4–8 times (Pass 1 × N + Pass 2 + Pass 3 + Pass 4). This is within normal Claude Code usage. When `--lang` is non-English, the static fallback path may invoke a few additional `claude -p` calls for translation; results are cached in `claudeos-core/generated/.i18n-cache-<lang>.json` so subsequent runs reuse them.
778
+ It calls `claude -p` several times across 4 passes. In v2.1.0 split mode, Pass 3 alone expands into 4–14+ stages depending on project size (see [Auto-scaling](#auto-scaling-by-project-size)). A typical small project (1–15 domains) uses 8–9 `claude -p` calls total; an 18-domain project uses 11; a 60-domain project uses 15–17. Each stage runs with a fresh context window — the per-call token cost is actually lower than single-call Pass 3 was, because no stage has to hold the entire file tree in one context. When `--lang` is non-English, the static fallback path may invoke a few additional `claude -p` calls for translation; results are cached in `claudeos-core/generated/.i18n-cache-<lang>.json` so subsequent runs reuse them. This is within normal Claude Code usage.
711
779
 
780
+ **Q: What is Pass 3 split mode and why was it added in v2.1.0?**
781
+ Before v2.1.0, Pass 3 made a single `claude -p` call that had to emit the entire generated file tree (`CLAUDE.md`, standards, rules, skills, guides — typically 30–60 files) in one response. This worked on small projects but reliably hit `Prompt is too long` output-accumulation failures at ~5 domains. The failure was not predictable from input size — it depended on how verbose each generated file happened to be, and could strike the same project intermittently. Split mode sidesteps the problem structurally: Pass 3 is broken into sequential stages (`3a` → `3b-core` → `3b-N` → `3c-core` → `3c-N` → `3d-aux`), each a separate `claude -p` call with a fresh context window. Cross-stage consistency is preserved by `pass3a-facts.md`, a 5–10 KB distilled fact sheet that every later stage references instead of re-reading `pass2-merged.json`. The `pass3-complete.json` marker carries a `groupsCompleted` array so a crash during `3c-2` resumes from `3c-2` (not from `3a`), avoiding double token cost.
712
782
  **Q: Should I commit the generated files to Git?**
713
783
  Yes, recommended. Your team can share the same Claude Code standards. Consider adding `claudeos-core/generated/` to `.gitignore` (analysis JSON is regeneratable).
714
784
 
715
785
  **Q: What about mixed-stack projects (e.g., Java backend + React frontend)?**
716
- Fully supported. ClaudeOS-Core auto-detects both stacks, tags domains as `backend` or `frontend`, and uses stack-specific analysis prompts for each. Pass 2 merges everything, and Pass 3 generates both backend and frontend standards in one pass.
786
+ Fully supported. ClaudeOS-Core auto-detects both stacks, tags domains as `backend` or `frontend`, and uses stack-specific analysis prompts for each. Pass 2 merges everything, and Pass 3 generates both backend and frontend standards across its split stages — backend domains go into some 3b/3c batches, frontend domains into others, all referencing the same `pass3a-facts.md` for consistency.
717
787
 
718
788
  **Q: Does it work with Turborepo / pnpm workspaces / Lerna monorepos?**
719
789
  Yes. ClaudeOS-Core detects `turbo.json`, `pnpm-workspace.yaml`, `lerna.json`, or `package.json#workspaces` and automatically scans sub-package `package.json` files for framework/ORM/DB dependencies. Domain scanning covers `apps/*/src/` and `packages/*/src/` patterns. Run from the monorepo root.
720
790
 
721
791
  **Q: What happens on re-run?**
722
- If previous Pass 1/2 results exist, an interactive prompt lets you choose: **Continue** (resume from where it stopped) or **Fresh** (delete all and start over). Use `--force` to skip the prompt and always start fresh. Pass 3 always re-runs. Previous versions can be restored from Master Plans.
792
+ If previous Pass 1/2 results exist, an interactive prompt lets you choose: **Continue** (resume from where it stopped) or **Fresh** (delete all and start over). Use `--force` to skip the prompt and always start fresh. In v2.1.0 split mode, Pass 3 resume works at stage granularity — if the run crashed during `3c-2`, the next `init` resumes from `3c-2` rather than restarting from `3a` (which would double the token cost). The `pass3-complete.json` marker records `mode: "split"` plus a `groupsCompleted` array to drive this logic.
723
793
 
724
794
  **Q: Does NestJS get its own template or use the Express one?**
725
795
  NestJS uses a dedicated `node-nestjs` template with NestJS-specific analysis categories: `@Module`, `@Injectable`, `@Controller` decorators, Guards, Pipes, Interceptors, DI container, CQRS patterns, and `Test.createTestingModule`. Express projects use the separate `node-express` template.
@@ -746,10 +816,16 @@ The automated pipeline (`npx claudeos-core init`) has a static fallback: if `cla
746
816
  See the [Memory Layer Maintenance](#memory-layer-maintenance-v200) section above. Short version: `compact` runs the 4-stage policy (summarize aged, merge duplicates, drop low-importance aged, enforce 400-line cap); `score` re-ranks `failure-patterns.md` by importance (frequency × recency); `propose-rules` surfaces candidate rule additions from recurring failures into `auto-rule-update.md` (not auto-applied — review and accept/reject manually).
747
817
 
748
818
  **Q: Why does `--force` (or "fresh" resume mode) delete `.claude/rules/`?**
749
- v2.0.0 added three Pass 3 silent-failure guards (Guard 3 covers two incomplete-output variants: H2 for `guide/` and H1 for `standard/skills/plan`). Guard 1 ("partial staged-rules move") and Guard 3 ("incomplete output — missing/empty guide files or missing standard sentinel / empty skills / empty plan") don't depend on existing rules, but Guard 2 ("zero rules detected") does — it fires when Claude ignored the `staging-override.md` directive and tried to write directly to `.claude/` (where Claude Code's sensitive-path policy blocks it). Stale rules from a prior run would let Guard 2 false-negative — so `--force`/`fresh` wipes `.claude/rules/` to ensure a clean detection. **Manual edits to rule files will be lost** under `--force`/`fresh`; back them up first if needed.
819
+ v2.0.0 added three Pass 3 silent-failure guards (Guard 3 covers two incomplete-output variants: H2 for `guide/` and H1 for `standard/skills`). Guard 1 ("partial staged-rules move") and Guard 3 ("incomplete output — missing/empty guide files or missing standard sentinel / empty skills") don't depend on existing rules, but Guard 2 ("zero rules detected") does — it fires when Claude ignored the `staging-override.md` directive and tried to write directly to `.claude/` (where Claude Code's sensitive-path policy blocks it). Stale rules from a prior run would let Guard 2 false-negative — so `--force`/`fresh` wipes `.claude/rules/` to ensure a clean detection. **Manual edits to rule files will be lost** under `--force`/`fresh`; back them up first if needed. (v2.1.0 note: Guard 3 H1 no longer checks `plan/` since master plans are no longer generated.)
750
820
 
751
821
  **Q: What is `claudeos-core/generated/.staged-rules/` and why does it exist?**
752
- Claude Code's sensitive-path policy refuses direct writes to `.claude/` from the `claude -p` subprocess (even with `--dangerously-skip-permissions`). v2.0.0 works around this by having Pass 3/4 prompts redirect all `.claude/rules/` writes to the staging directory; the Node.js orchestrator (not subject to that policy) then moves the staged tree into `.claude/rules/` after each pass. This is transparent to the user — the directory is auto-created, auto-cleaned, and auto-moved. If a prior run crashed mid-move, the next run wipes the staging dir before retrying.
822
+ Claude Code's sensitive-path policy refuses direct writes to `.claude/` from the `claude -p` subprocess (even with `--dangerously-skip-permissions`). v2.0.0 works around this by having Pass 3/4 prompts redirect all `.claude/rules/` writes to the staging directory; the Node.js orchestrator (not subject to that policy) then moves the staged tree into `.claude/rules/` after each pass. This is transparent to the user — the directory is auto-created, auto-cleaned, and auto-moved. If a prior run crashed mid-move, the next run wipes the staging dir before retrying. In v2.1.0 split mode, the stage runner moves staged rules to `.claude/rules/` after every stage (not just at the end), so a crash mid-Pass-3 still leaves previously completed stages' rules in place.
823
+
824
+ **Q: Can I run Pass 3 manually instead of `npx claudeos-core init`?**
825
+ Yes for small projects (≤5 domains) — the single-call manual instructions in [Step 6](#step-6-pass-3--generate-all-documentation-split-into-multiple-stages) still work. For larger projects you should use `npx claudeos-core init` because the split runner is what orchestrates stage-by-stage execution with fresh contexts, handles batch sub-division at ≥16 domains, writes the correct `pass3-complete.json` marker shape (`mode: "split"` + `groupsCompleted`), and moves staged rules between stages. Reproducing that orchestration by hand is possible but tedious. If you have a reason to run stages manually (e.g., debugging a specific stage), you can template `pass3-prompt.md` with the appropriate `STAGE:` directive and feed it to `claude -p` directly — but remember to move `.staged-rules/` after each stage and update the marker yourself.
826
+
827
+ **Q: My project is an upgrade from v2.0.x and has an existing `claudeos-core/plan/` directory. What do I do?**
828
+ Nothing required — v2.1.0 tools ignore `plan/` when it's absent or empty, and `plan-validator` still handles legacy projects with populated `plan/` directories for backward compatibility. You can safely delete `claudeos-core/plan/` if you don't need the master plan backups (git history is a better backup anyway). If you keep `plan/`, running `npx claudeos-core init` won't update it — new content is not aggregated into master plans in v2.1.0. Verification tools handle both cases cleanly.
753
829
 
754
830
  ---
755
831
 
@@ -772,7 +848,7 @@ pass-prompts/templates/
772
848
  └── python-flask/ # Python / Flask (Blueprint, app factory, Jinja2)
773
849
  ```
774
850
 
775
- `plan-installer` auto-detects your stack(s), then assembles type-specific prompts. NestJS, Vue/Nuxt, Vite SPA, and Flask each use dedicated templates with framework-specific analysis categories (e.g., `@Module`/`@Injectable`/Guards for NestJS; `<script setup>`/Pinia/useFetch for Vue; client-side routing/`VITE_` env for Vite; Blueprint/`app.factory`/Flask-SQLAlchemy for Flask). For multi-stack projects, separate `pass1-backend-prompt.md` and `pass1-frontend-prompt.md` are generated, while `pass3-prompt.md` combines both stacks' generation targets. Pass 4 uses the shared `common/pass4.md` template (memory scaffolding) regardless of stack.
851
+ `plan-installer` auto-detects your stack(s), then assembles type-specific prompts. NestJS, Vue/Nuxt, Vite SPA, and Flask each use dedicated templates with framework-specific analysis categories (e.g., `@Module`/`@Injectable`/Guards for NestJS; `<script setup>`/Pinia/useFetch for Vue; client-side routing/`VITE_` env for Vite; Blueprint/`app.factory`/Flask-SQLAlchemy for Flask). For multi-stack projects, separate `pass1-backend-prompt.md` and `pass1-frontend-prompt.md` are generated, while `pass3-prompt.md` combines both stacks' generation targets. In v2.1.0, the Pass 3 template is prepended with `common/pass3-phase1.md` (the "Read Once, Extract Facts" block with Rules A–E) before being sliced per split-mode stage. Pass 4 uses the shared `common/pass4.md` template (memory scaffolding) regardless of stack.
776
852
 
777
853
  ---
778
854
 
@@ -842,7 +918,11 @@ my-monorepo/ ← Run here: npx claudeos-core init
842
918
 
843
919
  **"Pass 3 produced CLAUDE.md and rules but N/9 guide files are missing or empty" (v2.0.0)** — Guard 3 (H2) fired: Claude truncated mid-response after writing CLAUDE.md + rules but before finishing (or starting) the `claudeos-core/guide/` section (9 files expected). Also fires on a BOM-only or whitespace-only file (heading was written but the body was truncated). Without this guard the completion marker would still be written, leaving `guide/` permanently empty on subsequent runs. The marker is NOT written here, so the next `init` run retries Pass 3 from the same Pass 2 results. If it keeps repeating, re-run with `npx claudeos-core init --force` to regenerate from scratch.
844
920
 
845
- **"Pass 3 finished but the following required output(s) are missing or empty" (v2.0.0)** — Guard 3 (H1) fired: Claude truncated AFTER `claudeos-core/guide/` but before (or during) `claudeos-core/standard/`, `claudeos-core/skills/`, or `claudeos-core/plan/`. Requirements: (a) `standard/00.core/01.project-overview.md` exists and is non-empty (sentinel written by every stack's Pass 3 prompt), (b) `skills/` has ≥1 non-empty `.md`, (c) `plan/` has ≥1 non-empty `.md`. `database/` and `mcp-guide/` are intentionally excluded (some stacks legitimately produce zero files). Same recovery path as Guard 3 (H2): re-run `init`, or `--force` if it persists.
921
+ **"Pass 3 finished but the following required output(s) are missing or empty" (v2.0.0, updated v2.1.0)** — Guard 3 (H1) fired: Claude truncated AFTER `claudeos-core/guide/` but before (or during) `claudeos-core/standard/` or `claudeos-core/skills/`. Requirements: (a) `standard/00.core/01.project-overview.md` exists and is non-empty (sentinel written by every stack's Pass 3 prompt), (b) `skills/` has ≥1 non-empty `.md`. `database/` and `mcp-guide/` are intentionally excluded (some stacks legitimately produce zero files). `plan/` is no longer checked as of v2.1.0 (master plans were removed). Same recovery path as Guard 3 (H2): re-run `init`, or `--force` if it persists.
922
+
923
+ **"Pass 3 split stage crashed partway through (v2.1.0)"** — When one of the split stages (e.g., `3b-1`, `3c-2`) fails mid-run, the stage-level marker is NOT written, but completed stages ARE recorded in `pass3-complete.json.groupsCompleted`. The next `init` run reads this array and resumes from the first uncompleted stage, skipping all earlier completed work. You don't need to do anything manually — just re-run `npx claudeos-core init`. If resume keeps failing at the same stage, inspect `claudeos-core/generated/pass3-prompt.md` for malformed content, then try `--force` for a full restart. The `pass3-complete.json` shape (`mode: "split"`, `groupsCompleted: [...]`) is stable; a missing or malformed marker causes the full Pass 3 to re-run from `3a`.
924
+
925
+ **"Pass 3 stale marker (shape mismatch) — treating as incomplete" (v2.1.0)** — A `pass3-complete.json` from a pre-v2.1.0 single-call run is being interpreted under the new split-mode rules. The shape check looks for `mode: "split"` and a `groupsCompleted` array; if either is missing, the marker is treated as partial and Pass 3 re-runs in split mode. If you upgraded from v2.0.x, this is expected once — the next run will write the correct marker shape. No action needed.
846
926
 
847
927
  **"pass2-merged.json exists but is malformed or incomplete (<5 top-level keys), re-running" (v2.0.0)** — Info log, not an error. On resume, `init` now parses and validates `pass2-merged.json` (≥5 top-level keys required, mirroring `pass-json-validator`'s `INSUFFICIENT_KEYS` threshold). Skeleton `{}` or malformed JSON from a prior crashed run is automatically deleted and Pass 2 re-runs. No manual action needed — the pipeline self-heals. If it keeps recurring, inspect `claudeos-core/generated/pass2-prompt.md` and retry with `--force`.
848
928
 
@@ -865,7 +945,7 @@ Contributions are welcome! Areas where help is most needed:
865
945
  - **New stack templates** — Ruby/Rails, Go (Gin/Fiber/Echo), PHP (Laravel/Symfony), Rust (Axum/Actix), Svelte/SvelteKit, Remix
866
946
  - **IDE integration** — VS Code extension, IntelliJ plugin
867
947
  - **CI/CD templates** — GitLab CI, CircleCI, Jenkins examples (GitHub Actions already shipped — see `.github/workflows/test.yml`)
868
- - **Test coverage** — Expanding test suite (currently 489 tests across 24 test files covering scanners, stack detection, domain grouping, plan parsing, prompt generation, CLI selectors, monorepo detection, Vite SPA detection, verification tools, L4 memory scaffold, Pass 2 resume validation, Pass 3 Guards 1/2/3 (H1 sentinel + H2 BOM-aware empty-file + strict stale-marker unlink), Pass 4 marker content validation + stale-marker unlink strictness, translation env-skip guard + early fail-fast + CI workflow, staged-rules move, lang-aware translation fallback, and AI Work Rules template structure)
948
+ - **Test coverage** — Expanding test suite (currently 563 tests across 29 test files covering scanners, stack detection, domain grouping, plan parsing, prompt generation, CLI selectors, monorepo detection, Vite SPA detection, verification tools, L4 memory scaffold, Pass 2 resume validation, Pass 3 Guards 1/2/3 (H1 sentinel + H2 BOM-aware empty-file + strict stale-marker unlink), Pass 3 split-mode batch subdivision, Pass 3 partial-marker resume (v2.1.0), Pass 4 marker content validation + stale-marker unlink strictness + scaffoldSkillsManifest gap-fill (v2.1.0), translation env-skip guard + early fail-fast + CI workflow, staged-rules move, lang-aware translation fallback, master plan removal regression suite (v2.1.0), memory score/compact formatting regression (v2.1.0), and AI Work Rules template structure)
869
949
 
870
950
  See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for the full list of areas, code style, commit convention, and the step-by-step guide for adding a new stack template.
871
951