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
package/README.md CHANGED
@@ -1,960 +1,1020 @@
1
- # ClaudeOS-Core
2
-
3
- **The only tool that reads your source code first, confirms your stack and patterns with deterministic analysis, then generates Claude Code rules tailored to your exact project.**
4
-
5
- ```bash
6
- npx claudeos-core init
7
- ```
8
-
9
- ClaudeOS-Core reads your codebase, extracts every pattern it finds, and generates a complete set of Standards, Rules, Skills, and Guides tailored to _your_ project. After that, when you tell Claude Code "Create a CRUD for orders", it produces code that matches your existing patterns exactly.
10
-
11
- [๐Ÿ‡ฐ๐Ÿ‡ท ํ•œ๊ตญ์–ด](./README.ko.md) ยท [๐Ÿ‡จ๐Ÿ‡ณ ไธญๆ–‡](./README.zh-CN.md) ยท [๐Ÿ‡ฏ๐Ÿ‡ต ๆ—ฅๆœฌ่ชž](./README.ja.md) ยท [๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol](./README.es.md) ยท [๐Ÿ‡ป๐Ÿ‡ณ Tiแบฟng Viแป‡t](./README.vi.md) ยท [๐Ÿ‡ฎ๐Ÿ‡ณ เคนเคฟเคจเฅเคฆเฅ€](./README.hi.md) ยท [๐Ÿ‡ท๐Ÿ‡บ ะ ัƒััะบะธะน](./README.ru.md) ยท [๐Ÿ‡ซ๐Ÿ‡ท Franรงais](./README.fr.md) ยท [๐Ÿ‡ฉ๐Ÿ‡ช Deutsch](./README.de.md)
12
-
13
- ---
14
-
15
- ## Why ClaudeOS-Core?
16
-
17
- Every other Claude Code tool works like this:
18
-
19
- > **Human describes the project โ†’ LLM generates documentation**
20
-
21
- ClaudeOS-Core works like this:
22
-
23
- > **Code analyzes your source โ†’ Code builds a tailored prompt โ†’ LLM generates documentation โ†’ Code verifies the output**
24
-
25
- This is not a small difference. Here's why it matters:
26
-
27
- ### The core problem: LLMs guess. Code doesn't.
28
-
29
- When you ask Claude to "analyze this project," it **guesses** your stack, your ORM, your domain structure.
30
- It might see `spring-boot` in your `build.gradle` but miss that you use MyBatis (not JPA).
31
- It might detect a `user/` directory but not realize your project uses layer-first packaging (Pattern A), not domain-first (Pattern B).
32
-
33
- **ClaudeOS-Core doesn't guess.** Before Claude ever sees your project, Node.js code has already:
34
-
35
- - Parsed `build.gradle` / `package.json` / `pyproject.toml` and **confirmed** your stack, ORM, DB, and package manager
36
- - Scanned your directory structure and **confirmed** your domain list with file counts
37
- - Classified your project structure into one of 5 Java patterns, Kotlin CQRS/BFF, or Next.js App Router/FSD
38
- - Split domains into optimally-sized groups that fit Claude's context window
39
- - Assembled a stack-specific prompt with all confirmed facts injected
40
-
41
- By the time Claude receives the prompt, there's nothing left to guess. The stack is confirmed. The domains are confirmed. The structure pattern is confirmed. Claude's only job is to generate documentation that matches these **confirmed facts**.
42
-
43
- ### The result
44
-
45
- Other tools produce "generally good" documentation.
46
- ClaudeOS-Core produces documentation that knows your project uses `ApiResponse.ok()` (not `ResponseEntity.success()`), that your MyBatis XML mappers live in `src/main/resources/mybatis/mappers/`, and that your package structure is `com.company.module.{domain}.controller` โ€” because it read your actual code.
47
-
48
- ### Before & After
49
-
50
- **Without ClaudeOS-Core** โ€” you ask Claude Code to create an Order CRUD:
51
- ```
52
- โŒ Uses JPA-style repository (your project uses MyBatis)
53
- โŒ Creates ResponseEntity.success() (your wrapper is ApiResponse.ok())
54
- โŒ Places files in order/controller/ (your project uses controller/order/)
55
- โŒ Generates English comments (your team writes Korean comments)
56
- โ†’ You spend 20 minutes fixing every generated file
57
- ```
58
-
59
- **With ClaudeOS-Core** โ€” `.claude/rules/` already contains your confirmed patterns:
60
- ```
61
- โœ… Generates MyBatis mapper + XML (detected from build.gradle)
62
- โœ… Uses ApiResponse.ok() (extracted from your actual source)
63
- โœ… Places files in controller/order/ (Pattern A confirmed by structure scan)
64
- โœ… Korean comments (--lang ko applied)
65
- โ†’ Generated code matches your project conventions immediately
66
- ```
67
-
68
- This difference compounds. 10 tasks/day ร— 20 minutes saved = **3+ hours/day**.
69
-
70
- ---
71
-
72
- ## Supported Stacks
73
-
74
- | Stack | Detection | Analysis Depth |
75
- |---|---|---|
76
- | **Java / Spring Boot** | `build.gradle`, `pom.xml`, 5 package patterns | 10 categories, 59 sub-items |
77
- | **Kotlin / Spring Boot** | `build.gradle.kts`, kotlin plugin, `settings.gradle.kts`, CQRS/BFF auto-detect | 12 categories, 95 sub-items |
78
- | **Node.js / Express** | `package.json` | 9 categories, 57 sub-items |
79
- | **Node.js / NestJS** | `package.json` (`@nestjs/core`) | 10 categories, 68 sub-items |
80
- | **Next.js / React** | `package.json`, `next.config.*`, FSD support | 9 categories, 55 sub-items |
81
- | **Vue / Nuxt** | `package.json`, `nuxt.config.*`, Composition API | 9 categories, 58 sub-items |
82
- | **Python / Django** | `requirements.txt`, `pyproject.toml` | 10 categories, 55 sub-items |
83
- | **Python / FastAPI** | `requirements.txt`, `pyproject.toml` | 10 categories, 58 sub-items |
84
- | **Node.js / Fastify** | `package.json` | 10 categories, 62 sub-items |
85
- | **Vite / React SPA** | `package.json`, `vite.config.*` | 9 categories, 55 sub-items |
86
- | **Angular** | `package.json`, `angular.json` | 12 categories, 78 sub-items |
87
-
88
- Auto-detected: language & version, framework & version (including Vite as SPA framework), ORM (MyBatis, JPA, Exposed, Prisma, TypeORM, SQLAlchemy, etc.), database (PostgreSQL, MySQL, Oracle, MongoDB, SQLite), package manager (Gradle, Maven, npm, yarn, pnpm, pip, poetry), architecture (CQRS, BFF โ€” from module names), multi-module structure (from settings.gradle), monorepo (Turborepo, pnpm-workspace, Lerna, npm/yarn workspaces).
89
-
90
- **You don't specify anything. It's all detected automatically.**
91
-
92
- ### Java Domain Detection (5 patterns with fallback)
93
-
94
- | Priority | Pattern | Structure | Example |
95
- |---|---|---|---|
96
- | A | Layer-first | `controller/{domain}/` | `controller/user/UserController.java` |
97
- | B | Domain-first | `{domain}/controller/` | `user/controller/UserController.java` |
98
- | D | Module prefix | `{module}/{domain}/controller/` | `front/member/controller/MemberController.java` |
99
- | E | DDD/Hexagonal | `{domain}/adapter/in/web/` | `user/adapter/in/web/UserController.java` |
100
- | C | Flat | `controller/*.java` | `controller/UserController.java` โ†’ extracts `user` from class name |
101
-
102
- Service-only domains (without controllers) are also detected via `service/`, `dao/`, `aggregator/`, `facade/`, `usecase/`, `orchestrator/`, `mapper/`, `repository/` directories. Skips: `common`, `config`, `util`, `core`, `front`, `admin`, `v1`, `v2`, etc.
103
-
104
- ### Kotlin Multi-Module Domain Detection
105
-
106
- For Kotlin projects with Gradle multi-module structure (e.g., CQRS monorepo):
107
-
108
- | Step | What It Does | Example |
109
- |---|---|---|
110
- | 1 | Scan `settings.gradle.kts` for `include()` | Finds 14 modules |
111
- | 2 | Detect module type from name | `reservation-command-server` โ†’ type: `command` |
112
- | 3 | Extract domain from module name | `reservation-command-server` โ†’ domain: `reservation` |
113
- | 4 | Group same domain across modules | `reservation-command-server` + `common-query-server` โ†’ 1 domain |
114
- | 5 | Detect architecture | Has `command` + `query` modules โ†’ CQRS |
115
-
116
- Supported module types: `command`, `query`, `bff`, `integration`, `standalone`, `library`. Shared libraries (`shared-lib`, `integration-lib`) are detected as special domains.
117
-
118
- ### Frontend Domain Detection
119
-
120
- - **App Router**: `app/{domain}/page.tsx` (Next.js)
121
- - **Pages Router**: `pages/{domain}/index.tsx`
122
- - **FSD (Feature-Sliced Design)**: `features/*/`, `widgets/*/`, `entities/*/`
123
- - **RSC/Client split**: Detects `client.tsx` pattern, tracks Server/Client component separation
124
- - **Non-standard nested paths**: Detects pages, components, and FSD layers under `src/*/` paths (e.g., `src/admin/pages/dashboard/`, `src/admin/components/form/`, `src/admin/features/billing/`)
125
- - **Platform/tier-split detection (v2.0.0)**: Recognizes `src/{platform}/{subapp}/` layouts โ€” `{platform}` can be a device/target keyword (`desktop`, `pc`, `web`, `mobile`, `mc`, `mo`, `sp`, `tablet`, `tab`, `pwa`, `tv`, `ctv`, `ott`, `watch`, `wear`) or an access-tier keyword (`admin`, `cms`, `backoffice`, `back-office`, `portal`). Emits one domain per `(platform, subapp)` pair named `{platform}-{subapp}` with per-domain counts for routes/components/layouts/hooks. Runs across Angular, Next.js, React, and Vue simultaneously (multi-extension glob `{tsx,jsx,ts,js,vue}`). Requires โ‰ฅ2 source files per subapp to avoid noisy 1-file domains.
126
- - **Monorepo platform split (v2.0.0)**: The platform scan also matches `{apps,packages}/*/src/{platform}/{subapp}/` (Turborepo/pnpm workspace with `src/`) and `{apps,packages}/{platform}/{subapp}/` (workspaces without `src/` wrapper).
127
- - **Fallback E โ€” routes-file (v2.0.0)**: When primary scanners + Fallbacks Aโ€“D all return 0, globs `**/routes/*.{tsx,jsx,ts,js,vue}` and groups by the parent-of-`routes` directory name. Catches React Router file-routing projects (CRA/Vite + `react-router`) that don't match Next.js `page.tsx` or FSD layouts. Generic parent names (`src`, `app`, `pages`) are filtered out.
128
- - **Config fallback**: Detects Next.js/Vite/Nuxt from config files when not in `package.json` (monorepo support)
129
- - **Deep directory fallback**: For React/CRA/Vite/Vue/RN projects, scans `**/components/*/`, `**/views/*/`, `**/screens/*/`, `**/containers/*/`, `**/pages/*/`, `**/routes/*/`, `**/modules/*/`, `**/domains/*/` at any depth
130
- - **Shared ignore lists (v2.0.0)**: All scanners share `BUILD_IGNORE_DIRS` (`node_modules`, `build`, `dist`, `out`, `.next`, `.nuxt`, `.svelte-kit`, `.angular`, `.turbo`, `.cache`, `.parcel-cache`, `coverage`, `storybook-static`, `.vercel`, `.netlify`) and `TEST_FILE_IGNORE` (spec/test/stories/e2e/cy + `__snapshots__`/`__tests__`) so build outputs and test fixtures don't inflate per-domain file counts.
131
-
132
- ### Scanner Overrides (v2.0.0)
133
-
134
- Drop an optional `.claudeos-scan.json` at your project root to extend scanner defaults without editing the toolkit. All fields are **additive** โ€” user entries extend defaults, never replace:
135
-
136
- ```json
137
- {
138
- "frontendScan": {
139
- "platformKeywords": ["kiosk"],
140
- "skipSubappNames": ["legacy"],
141
- "minSubappFiles": 3
142
- }
143
- }
144
- ```
145
-
146
- | Field | Default | Purpose |
147
- |---|---|---|
148
- | `platformKeywords` | built-in list above | Additional `{platform}` keywords for the platform scan (e.g., `kiosk`, `vr`, `embedded`) |
149
- | `skipSubappNames` | structural dirs only | Additional subapp names to exclude from platform-scan domain emission |
150
- | `minSubappFiles` | `2` | Override the minimum file count required before a subapp becomes a domain |
151
-
152
- Missing file or malformed JSON โ†’ silently falls back to defaults (no crash). Typical use: opt-in a short abbreviation (`adm`, `bo`) that the built-in list excludes as too ambiguous, or raise `minSubappFiles` for noisy monorepos.
153
-
154
- ---
155
-
156
- ## Quick Start
157
-
158
- ### Prerequisites
159
-
160
- - **Node.js** v18+
161
- - **Claude Code CLI** (installed & authenticated)
162
-
163
- ### Installation
164
-
165
- ```bash
166
- cd /your/project/root
167
-
168
- # Option A: npx (recommended โ€” no install needed)
169
- npx claudeos-core init
170
-
171
- # Option B: global install
172
- npm install -g claudeos-core
173
- claudeos-core init
174
-
175
- # Option C: project devDependency
176
- npm install --save-dev claudeos-core
177
- npx claudeos-core init
178
-
179
- # Option D: git clone (for development/contribution)
180
- git clone https://github.com/claudeos-core/claudeos-core.git claudeos-core-tools
181
-
182
- # Cross-platform (PowerShell, CMD, Bash, Zsh โ€” any terminal)
183
- node claudeos-core-tools/bin/cli.js init
184
-
185
- # Linux/macOS (Bash only)
186
- bash claudeos-core-tools/bootstrap.sh
187
- ```
188
-
189
- ### Output Language (10 languages)
190
-
191
- When you run `init` without `--lang`, an interactive selector appears โ€” use arrow keys or number keys to choose:
192
-
193
- ```
194
- โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
195
- โ•‘ Select generated document language (required) โ•‘
196
- โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
197
-
198
- Generated files (CLAUDE.md, Standards, Rules,
199
- Skills, Guides) will be written in English.
200
-
201
- โฏ 1. en โ€” English
202
- 2. ko โ€” ํ•œ๊ตญ์–ด (Korean)
203
- 3. zh-CN โ€” ็ฎ€ไฝ“ไธญๆ–‡ (Chinese Simplified)
204
- 4. ja โ€” ๆ—ฅๆœฌ่ชž (Japanese)
205
- 5. es โ€” Espaรฑol (Spanish)
206
- 6. vi โ€” Tiแบฟng Viแป‡t (Vietnamese)
207
- 7. hi โ€” เคนเคฟเคจเฅเคฆเฅ€ (Hindi)
208
- 8. ru โ€” ะ ัƒััะบะธะน (Russian)
209
- 9. fr โ€” Franรงais (French)
210
- 10. de โ€” Deutsch (German)
211
-
212
- โ†‘โ†“ Move 1-0 Jump Enter Select ESC Cancel
213
- ```
214
-
215
- The description changes to the selected language as you navigate. To skip the selector, pass `--lang` directly:
216
-
217
- ```bash
218
- npx claudeos-core init --lang ko # Korean
219
- npx claudeos-core init --lang ja # Japanese
220
- npx claudeos-core init --lang en # English (default)
221
- ```
222
-
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
-
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
-
227
- ### Manual Step-by-Step Installation
228
-
229
- If you want full control over each phase โ€” or if the automated pipeline fails at any step โ€” you can run each stage manually. This is also useful for understanding how ClaudeOS-Core works internally.
230
-
231
- #### Step 1: Clone and install dependencies
232
-
233
- ```bash
234
- cd /your/project/root
235
-
236
- git clone https://github.com/claudeos-core/claudeos-core.git claudeos-core-tools
237
- cd claudeos-core-tools && npm install && cd ..
238
- ```
239
-
240
- #### Step 2: Create directory structure
241
-
242
- ```bash
243
- # Rules (v2.0.0: added 60.memory)
244
- mkdir -p .claude/rules/{00.core,10.backend,20.frontend,30.security-db,40.infra,50.sync,60.memory}
245
-
246
- # Standards
247
- mkdir -p claudeos-core/standard/{00.core,10.backend-api,20.frontend-ui,30.security-db,40.infra,50.verification,90.optional}
248
-
249
- # Skills
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
-
252
- # Guide, Database, MCP, Generated, Memory (v2.0.0: added memory; v2.1.0: removed plan)
253
- mkdir -p claudeos-core/guide/{01.onboarding,02.usage,03.troubleshooting,04.architecture}
254
- mkdir -p claudeos-core/{database,mcp-guide,generated,memory}
255
- ```
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
-
259
- #### Step 3: Run plan-installer (project analysis)
260
-
261
- This scans your project, detects the stack, finds domains, splits them into groups, and generates prompts.
262
-
263
- ```bash
264
- node claudeos-core-tools/plan-installer/index.js
265
- ```
266
-
267
- **Output (in `claudeos-core/generated/`):**
268
- - `project-analysis.json` โ€” detected stack, domains, frontend info
269
- - `domain-groups.json` โ€” domain groups for Pass 1
270
- - `pass1-backend-prompt.md` / `pass1-frontend-prompt.md` โ€” analysis prompts
271
- - `pass2-prompt.md` โ€” merge prompt
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)
274
- - `pass4-prompt.md` โ€” L4 memory scaffolding prompt (v2.0.0; uses the same `staging-override.md` for `60.memory/` rule writes)
275
-
276
- You can inspect these files to verify detection accuracy before proceeding.
277
-
278
- #### Step 4: Pass 1 โ€” Deep code analysis (per domain group)
279
-
280
- Run Pass 1 for each domain group. Check `domain-groups.json` for the number of groups.
281
-
282
- ```bash
283
- # Check how many groups
284
- cat claudeos-core/generated/domain-groups.json | node -e "
285
- const g = JSON.parse(require('fs').readFileSync('/dev/stdin','utf-8'));
286
- g.groups.forEach((g,i) => console.log('Group '+(i+1)+': ['+g.domains.join(', ')+'] ('+g.type+', ~'+g.estimatedFiles+' files)'));
287
- "
288
-
289
- # Run Pass 1 for each group (replace domains and group number)
290
- # Note: v1.6.1+ uses Node.js String.replace() instead of perl โ€” perl is no
291
- # longer required, and replacement-function semantics prevent regex injection
292
- # from $/&/$1 characters that may appear in domain names.
293
- #
294
- # For group 1:
295
- DOMAIN_LIST="user, order, product" PASS_NUM=1 node -e "
296
- const fs = require('fs');
297
- const tpl = fs.readFileSync('claudeos-core/generated/pass1-backend-prompt.md','utf-8');
298
- const out = tpl
299
- .replace(/\{\{DOMAIN_GROUP\}\}/g, () => process.env.DOMAIN_LIST)
300
- .replace(/\{\{PASS_NUM\}\}/g, () => process.env.PASS_NUM);
301
- process.stdout.write(out);
302
- " | claude -p --dangerously-skip-permissions
303
-
304
- # For group 2 (if exists):
305
- DOMAIN_LIST="payment, system, delivery" PASS_NUM=2 node -e "
306
- const fs = require('fs');
307
- const tpl = fs.readFileSync('claudeos-core/generated/pass1-backend-prompt.md','utf-8');
308
- const out = tpl
309
- .replace(/\{\{DOMAIN_GROUP\}\}/g, () => process.env.DOMAIN_LIST)
310
- .replace(/\{\{PASS_NUM\}\}/g, () => process.env.PASS_NUM);
311
- process.stdout.write(out);
312
- " | claude -p --dangerously-skip-permissions
313
-
314
- # For frontend groups, swap pass1-backend-prompt.md โ†’ pass1-frontend-prompt.md
315
- ```
316
-
317
- **Verify:** `ls claudeos-core/generated/pass1-*.json` should show one JSON per group.
318
-
319
- #### Step 5: Pass 2 โ€” Merge analysis results
320
-
321
- ```bash
322
- cat claudeos-core/generated/pass2-prompt.md \
323
- | claude -p --dangerously-skip-permissions
324
- ```
325
-
326
- **Verify:** `claudeos-core/generated/pass2-merged.json` should exist with 9+ top-level keys.
327
-
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):**
333
-
334
- ```bash
335
- cat claudeos-core/generated/pass3-prompt.md \
336
- | claude -p --dangerously-skip-permissions
337
- ```
338
-
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 |
351
-
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).
357
-
358
- #### Step 7: Pass 4 โ€” Memory scaffolding
359
-
360
- ```bash
361
- cat claudeos-core/generated/pass4-prompt.md \
362
- | claude -p --dangerously-skip-permissions
363
- ```
364
-
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).
368
-
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.
370
-
371
- #### Step 8: Run verification tools
372
-
373
- ```bash
374
- # Generate metadata (required before other checks)
375
- node claudeos-core-tools/manifest-generator/index.js
376
-
377
- # Run all checks
378
- node claudeos-core-tools/health-checker/index.js
379
-
380
- # Or run individual checks:
381
- node claudeos-core-tools/plan-validator/index.js --check # Plan โ†” disk consistency
382
- node claudeos-core-tools/sync-checker/index.js # Unregistered/orphaned files
383
- node claudeos-core-tools/content-validator/index.js # File quality checks (incl. memory/ section [9/9])
384
- node claudeos-core-tools/pass-json-validator/index.js # Pass 1โ€“4 JSON + completion marker checks
385
- ```
386
-
387
- #### Step 9: Verify the results
388
-
389
- ```bash
390
- # Count generated files
391
- find .claude claudeos-core -type f | grep -v node_modules | grep -v '/generated/' | wc -l
392
-
393
- # Check CLAUDE.md
394
- head -30 CLAUDE.md
395
-
396
- # Check a standard file
397
- cat claudeos-core/standard/00.core/01.project-overview.md | head -20
398
-
399
- # Check rules
400
- ls .claude/rules/*/
401
- ```
402
-
403
- > **Tip:** If any step fails, you can fix the issue and re-run just that step. Pass 1/2 results are cached โ€” if `pass1-N.json` or `pass2-merged.json` already exists, the automated pipeline skips them. Use `npx claudeos-core init --force` to delete previous results and start fresh.
404
-
405
- ### Start Using
406
-
407
- ```
408
- # In Claude Code โ€” just ask naturally:
409
- "Create a CRUD for the order domain"
410
- "Add user authentication API"
411
- "Refactor this code to match project patterns"
412
-
413
- # Claude Code automatically references your generated Standards, Rules, and Skills.
414
- ```
415
-
416
- ---
417
-
418
- ## How It Works โ€” 4-Pass Pipeline
419
-
420
- ```
421
- npx claudeos-core init
422
- โ”‚
423
- โ”œโ”€โ”€ [1] npm install โ† Dependencies (~10s)
424
- โ”œโ”€โ”€ [2] Directory structure โ† Create folders (~1s)
425
- โ”œโ”€โ”€ [3] plan-installer (Node.js) โ† Project scan (~5s)
426
- โ”‚ โ”œโ”€โ”€ Auto-detect stack (multi-stack aware)
427
- โ”‚ โ”œโ”€โ”€ Extract domain list (tagged: backend/frontend)
428
- โ”‚ โ”œโ”€โ”€ Split into domain groups (per type)
429
- โ”‚ โ”œโ”€โ”€ Build pass3-context.json (slim summary, v2.1.0)
430
- โ”‚ โ””โ”€โ”€ Select stack-specific prompts (per type)
431
- โ”‚
432
- โ”œโ”€โ”€ [4] Pass 1 ร— N (claude -p) โ† Deep code analysis (~2-8min)
433
- โ”‚ โ”œโ”€โ”€ โš™๏ธ Backend groups โ†’ backend-specific prompt
434
- โ”‚ โ””โ”€โ”€ ๐ŸŽจ Frontend groups โ†’ frontend-specific prompt
435
- โ”‚
436
- โ”œโ”€โ”€ [5] Pass 2 ร— 1 (claude -p) โ† Merge analysis (~1min)
437
- โ”‚ โ””โ”€โ”€ Consolidate ALL Pass 1 results into pass2-merged.json
438
- โ”‚
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
451
- โ”‚
452
- โ”œโ”€โ”€ [7] Pass 4 ร— 1 (claude -p) โ† Memory scaffolding (~30s-5min)
453
- โ”‚ โ”œโ”€โ”€ Seed memory/ (decision-log, failure-patterns, โ€ฆ)
454
- โ”‚ โ”œโ”€โ”€ Generate 60.memory/ rules
455
- โ”‚ โ”œโ”€โ”€ Append "Memory (L4)" section to CLAUDE.md
456
- โ”‚ โ””โ”€โ”€ Gap-fill: ensure skills/00.shared/MANIFEST.md exists (v2.1.0)
457
- โ”‚
458
- โ””โ”€โ”€ [8] Verification โ† Auto-run health checker
459
- ```
460
-
461
- ### Why 4 Passes?
462
-
463
- **Pass 1** is the only pass that reads your source code. It selects representative files per domain and extracts patterns across 55โ€“95 analysis categories (per stack). For large projects, Pass 1 runs multiple times โ€” one per domain group. In multi-stack projects (e.g., Java backend + React frontend), backend and frontend domains use **different analysis prompts** tailored to each stack.
464
-
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.
466
-
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.
476
-
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.
478
-
479
- ---
480
-
481
- ## Generated File Structure
482
-
483
- ```
484
- your-project/
485
- โ”‚
486
- โ”œโ”€โ”€ CLAUDE.md โ† Claude Code entry point
487
- โ”‚
488
- โ”œโ”€โ”€ .claude/
489
- โ”‚ โ””โ”€โ”€ rules/ โ† Glob-triggered rules
490
- โ”‚ โ”œโ”€โ”€ 00.core/
491
- โ”‚ โ”œโ”€โ”€ 10.backend/
492
- โ”‚ โ”œโ”€โ”€ 20.frontend/
493
- โ”‚ โ”œโ”€โ”€ 30.security-db/
494
- โ”‚ โ”œโ”€โ”€ 40.infra/
495
- โ”‚ โ”œโ”€โ”€ 50.sync/ โ† Sync reminder rules
496
- โ”‚ โ””โ”€โ”€ 60.memory/ โ† L4 memory on-demand scope rules (v2.0.0)
497
- โ”‚
498
- โ”œโ”€โ”€ claudeos-core/ โ† Main output directory
499
- โ”‚ โ”œโ”€โ”€ generated/ โ† Analysis JSON + dynamic prompts + Pass markers (gitignore this)
500
- โ”‚ โ”‚ โ”œโ”€โ”€ project-analysis.json โ† Stack info (multi-stack aware)
501
- โ”‚ โ”‚ โ”œโ”€โ”€ domain-groups.json โ† Groups with type: backend/frontend
502
- โ”‚ โ”‚ โ”œโ”€โ”€ pass1-backend-prompt.md โ† Backend analysis prompt
503
- โ”‚ โ”‚ โ”œโ”€โ”€ pass1-frontend-prompt.md โ† Frontend analysis prompt (if detected)
504
- โ”‚ โ”‚ โ”œโ”€โ”€ pass2-prompt.md โ† Merge prompt
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)
509
- โ”‚ โ”‚ โ”œโ”€โ”€ pass4-prompt.md โ† Memory scaffolding prompt (v2.0.0)
510
- โ”‚ โ”‚ โ”œโ”€โ”€ pass3-complete.json โ† Pass 3 completion marker (split mode: includes groupsCompleted, v2.1.0)
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
515
- โ”‚ โ”‚ โ”œโ”€โ”€ .i18n-cache-<lang>.json โ† Translation cache (non-English `--lang`)
516
- โ”‚ โ”‚ โ””โ”€โ”€ .staged-rules/ โ† Transient staging dir for `.claude/rules/` writes (auto-moved + cleaned)
517
- โ”‚ โ”œโ”€โ”€ standard/ โ† Coding standards (15-19 files + per-domain in 60.domains/)
518
- โ”‚ โ”‚ โ”œโ”€โ”€ 00.core/ โ† Overview, architecture, naming
519
- โ”‚ โ”‚ โ”œโ”€โ”€ 10.backend-api/ โ† API patterns (stack-specific)
520
- โ”‚ โ”‚ โ”œโ”€โ”€ 20.frontend-ui/ โ† Frontend patterns (if detected)
521
- โ”‚ โ”‚ โ”œโ”€โ”€ 30.security-db/ โ† Security, DB schema, utilities
522
- โ”‚ โ”‚ โ”œโ”€โ”€ 40.infra/ โ† Config, logging, CI/CD
523
- โ”‚ โ”‚ โ”œโ”€โ”€ 50.verification/ โ† Build verification, testing
524
- โ”‚ โ”‚ โ”œโ”€โ”€ 60.domains/ โ† Per-domain standards (written by Pass 3b-N, v2.1.0)
525
- โ”‚ โ”‚ โ””โ”€โ”€ 90.optional/ โ† Optional conventions (stack-specific extras)
526
- โ”‚ โ”œโ”€โ”€ skills/ โ† CRUD/page scaffolding skills
527
- โ”‚ โ”‚ โ””โ”€โ”€ 00.shared/MANIFEST.md โ† Single source of truth for registered skills
528
- โ”‚ โ”œโ”€โ”€ guide/ โ† Onboarding, FAQ, troubleshooting (9 files)
529
- โ”‚ โ”œโ”€โ”€ database/ โ† DB schema, migration guide
530
- โ”‚ โ”œโ”€โ”€ mcp-guide/ โ† MCP server integration guide
531
- โ”‚ โ””โ”€โ”€ memory/ โ† L4: team knowledge (4 files) โ€” commit these
532
- โ”‚ โ”œโ”€โ”€ decision-log.md โ† "Why" behind design decisions
533
- โ”‚ โ”œโ”€โ”€ failure-patterns.md โ† Recurring errors & fixes (auto-scored โ€” `npx claudeos-core memory score`)
534
- โ”‚ โ”œโ”€โ”€ compaction.md โ† 4-stage compaction strategy (run `npx claudeos-core memory compact`)
535
- โ”‚ โ””โ”€โ”€ auto-rule-update.md โ† Rule improvement proposals (`npx claudeos-core memory propose-rules`)
536
- โ”‚
537
- โ””โ”€โ”€ claudeos-core-tools/ โ† This toolkit (don't modify)
538
- ```
539
-
540
- Every standard file includes โœ… correct examples, โŒ incorrect examples, and a rules summary table โ€” all derived from your actual code patterns, not generic templates.
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
-
544
- ### Gitignore recommendations
545
-
546
- **Do commit** (team knowledge โ€” meant to be shared):
547
- - `CLAUDE.md` โ€” Claude Code entry point
548
- - `.claude/rules/**` โ€” auto-loaded rules
549
- - `claudeos-core/standard/**`, `skills/**`, `guide/**`, `database/**`, `mcp-guide/**`, `plan/**` โ€” generated documentation
550
- - `claudeos-core/memory/**` โ€” decision history, failure patterns, rule proposals
551
-
552
- **Do NOT commit** (regeneratable build artifacts):
553
-
554
- ```gitignore
555
- # ClaudeOS-Core โ€” generated analysis & translation cache
556
- claudeos-core/generated/
557
- ```
558
-
559
- The `generated/` directory contains analysis JSON (`pass1-*.json`, `pass2-merged.json`), prompts (`pass1/2/3/4-prompt.md`), Pass completion markers (`pass3-complete.json`, `pass4-memory.json`), translation cache (`.i18n-cache-<lang>.json`), and the transient staging directory (`.staged-rules/`) โ€” all rebuildable by re-running `npx claudeos-core init`.
560
-
561
- ---
562
-
563
- ## Auto-scaling by Project Size
564
-
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 |
568
- |---|---|---|---|---|
569
- | Small | 1โ€“4 | 4 (`3a`, `3b-core`, `3c-core`, `3d-aux`) | 7 (Pass 1 + 2 + 4 stages of Pass 3 + Pass 4) | ~10โ€“15 min |
570
- | Medium | 5โ€“15 | 4 | 8โ€“9 | ~25โ€“45 min |
571
- | Large | 16โ€“30 | **8** (3b, 3c each split into 2 batches) | 11โ€“12 | **~60โ€“105 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)`.
577
-
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.
579
-
580
- ---
581
-
582
- ## Verification Tools
583
-
584
- ClaudeOS-Core includes 5 built-in verification tools that run automatically after generation:
585
-
586
- ```bash
587
- # Run all checks at once (recommended)
588
- npx claudeos-core health
589
-
590
- # Individual commands
591
- npx claudeos-core validate # Plan โ†” disk comparison
592
- npx claudeos-core refresh # Disk โ†’ Plan sync
593
- npx claudeos-core restore # Plan โ†’ Disk restore
594
-
595
- # Or use node directly (git clone users)
596
- node claudeos-core-tools/health-checker/index.js
597
- node claudeos-core-tools/manifest-generator/index.js
598
- node claudeos-core-tools/plan-validator/index.js --check
599
- node claudeos-core-tools/sync-checker/index.js
600
- ```
601
-
602
- | Tool | What It Does |
603
- |---|---|
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). |
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) |
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 |
609
-
610
- ---
611
-
612
- ## How Claude Code Uses Your Documentation
613
-
614
- ClaudeOS-Core generates documentation that Claude Code actually reads โ€” here's how:
615
-
616
- ### What Claude Code reads automatically
617
-
618
- | File | When | Guaranteed |
619
- |---|---|---|
620
- | `CLAUDE.md` | Every conversation start | Always |
621
- | `.claude/rules/00.core/*` | When any file is edited (`paths: ["**/*"]`) | Always |
622
- | `.claude/rules/10.backend/*` | When any file is edited (`paths: ["**/*"]`) | Always |
623
- | `.claude/rules/20.frontend/*` | When any frontend file is edited (scoped to component/page/style paths) | Conditional |
624
- | `.claude/rules/30.security-db/*` | When any file is edited (`paths: ["**/*"]`) | Always |
625
- | `.claude/rules/40.infra/*` | Only when editing config/infra files (scoped paths) | Conditional |
626
- | `.claude/rules/50.sync/*` | Only when editing claudeos-core files (scoped paths) | Conditional |
627
- | `.claude/rules/60.memory/*` | When `claudeos-core/memory/*` is edited (scoped to memory paths) โ€” instructs **how** to read/write the on-demand memory layer | Conditional (v2.0.0) |
628
-
629
- ### What Claude Code reads on-demand via rule references
630
-
631
- Each rule file links to its corresponding standard via a `## Reference` section. Claude reads only the relevant standard for the current task:
632
-
633
- - `claudeos-core/standard/**` โ€” coding patterns, โœ…/โŒ examples, naming conventions
634
- - `claudeos-core/database/**` โ€” DB schema (for queries, mappers, migrations)
635
- - `claudeos-core/memory/**` (v2.0.0) โ€” L4 team knowledge layer; **not** auto-loaded (would be too noisy on every conversation). Instead, the `60.memory/*` rules tell Claude *when* to Read these files: at session start (skim recent `decision-log.md` + high-importance `failure-patterns.md`), and append-on-demand when making decisions or hitting recurring errors.
636
-
637
- The `00.standard-reference.md` serves as a directory of all standard files for discovering standards that have no corresponding rule.
638
-
639
- ### What Claude Code does NOT read (saves context)
640
-
641
- These folders are explicitly excluded via the `DO NOT Read` section in the standard-reference rule:
642
-
643
- | Folder | Why excluded |
644
- |---|---|
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. |
646
- | `claudeos-core/generated/` | Build metadata JSON, prompts, Pass markers, translation cache, `.staged-rules/`. Not for coding. |
647
- | `claudeos-core/guide/` | Onboarding guides for humans. |
648
- | `claudeos-core/mcp-guide/` | MCP server docs. Not for coding. |
649
- | `claudeos-core/memory/` (auto-load) | **Auto-load disabled** by design โ€” would balloon context on every conversation. Read on-demand via the `60.memory/*` rules instead (e.g. session-start scan of `failure-patterns.md`). Always commit these files. |
650
-
651
- ---
652
-
653
- ## Daily Workflow
654
-
655
- ### After Installation
656
-
657
- ```
658
- # Just use Claude Code as normal โ€” it references your standards automatically:
659
- "Create a CRUD for the order domain"
660
- "Add user profile update API"
661
- "Refactor this code to match project patterns"
662
- ```
663
-
664
- ### After Manually Editing Standards
665
-
666
- ```bash
667
- # After editing standards or rules files:
668
- npx claudeos-core refresh
669
-
670
- # Verify everything is consistent
671
- npx claudeos-core health
672
- ```
673
-
674
- ### When Docs Get Corrupted
675
-
676
- ```bash
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):
683
- npx claudeos-core restore
684
- ```
685
-
686
- ### Memory Layer Maintenance (v2.0.0)
687
-
688
- The L4 Memory layer (`claudeos-core/memory/`) accumulates team knowledge across sessions. Three CLI subcommands keep it healthy:
689
-
690
- ```bash
691
- # Compact: enforce 4-stage compaction policy (run periodically โ€” e.g. monthly)
692
- npx claudeos-core memory compact
693
- # Stage 1: summarize aged entries (>30 days, body โ†’ one-line)
694
- # Stage 2: merge duplicate headings (frequency summed, latest fix kept)
695
- # Stage 3: drop low-importance + aged (importance <3 AND lastSeen >60 days)
696
- # Stage 4: enforce 400-line cap per file (oldest low-importance dropped first)
697
-
698
- # Score: re-rank failure-patterns.md entries by importance
699
- npx claudeos-core memory score
700
- # importance = round(frequency ร— 1.5 + recency ร— 5), capped at 10
701
- # Run after appending several new failure patterns
702
-
703
- # Propose-rules: surface candidate rule additions from recurring failures
704
- npx claudeos-core memory propose-rules
705
- # Reads failure-patterns.md entries with frequency โ‰ฅ 3
706
- # Computes confidence (sigmoid on weighted evidence ร— anchor multiplier)
707
- # Writes proposals to memory/auto-rule-update.md (NOT auto-applied)
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
712
- ```
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
-
716
- When to write to memory (Claude does this on-demand, but you can edit manually too):
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.
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.
719
- - `compaction.md` and `auto-rule-update.md` โ€” generated/managed by the CLI subcommands above; don't edit by hand.
720
-
721
- ### CI/CD Integration
722
-
723
- ```yaml
724
- # GitHub Actions example
725
- - run: npx claudeos-core validate
726
- # Exit code 1 blocks the PR
727
-
728
- # Optional: monthly memory housekeeping (separate cron workflow)
729
- - run: npx claudeos-core memory compact
730
- - run: npx claudeos-core memory score
731
- ```
732
-
733
- ---
734
-
735
- ## How Is This Different?
736
-
737
- ### vs Other Claude Code Tools
738
-
739
- | | ClaudeOS-Core | Everything Claude Code (50K+ โญ) | Harness | specs-generator | Claude `/init` |
740
- |---|---|---|---|---|---|
741
- | **Approach** | Code analyzes first, then LLM generates | Pre-built config presets | LLM designs agent teams | LLM generates spec docs | LLM writes CLAUDE.md |
742
- | **Reads your source code** | โœ… Deterministic static analysis | โŒ | โŒ | โŒ (LLM reads) | โŒ (LLM reads) |
743
- | **Stack detection** | Code confirms (ORM, DB, build tool, pkg manager) | N/A (stack-agnostic) | LLM guesses | LLM guesses | LLM guesses |
744
- | **Domain detection** | Code confirms (Java 5 patterns, Kotlin CQRS, Next.js FSD) | N/A | LLM guesses | N/A | N/A |
745
- | **Same project โ†’ Same result** | โœ… Deterministic analysis | โœ… (static files) | โŒ (LLM varies) | โŒ (LLM varies) | โŒ (LLM varies) |
746
- | **Large project handling** | Domain group splitting (4 domains / 40 files per group) | N/A | No splitting | No splitting | Context window limit |
747
- | **Output** | CLAUDE.md + Rules + Standards + Skills + Guides + Plans (40-50+ files) | Agents + Skills + Commands + Hooks | Agents + Skills | 6 spec documents | CLAUDE.md (1 file) |
748
- | **Output location** | `.claude/rules/` (auto-loaded by Claude Code) | `.claude/` various | `.claude/agents/` + `.claude/skills/` | `.claude/steering/` + `specs/` | `CLAUDE.md` |
749
- | **Post-generation verification** | โœ… 5 automated validators | โŒ | โŒ | โŒ | โŒ |
750
- | **Multi-language output** | โœ… 10 languages | โŒ | โŒ | โŒ | โŒ |
751
- | **Multi-stack** | โœ… Backend + Frontend simultaneous | โŒ Stack-agnostic | โŒ | โŒ | Partial |
752
- | **Persistent memory layer** | โœ… L4 โ€” decision log + failure patterns + auto-scored rule proposals (v2.0.0) | โŒ | โŒ | โŒ | โŒ |
753
- | **Agent orchestration** | โŒ | โœ… 28 agents | โœ… 6 patterns | โŒ | โŒ |
754
-
755
- ### The key difference in one sentence
756
-
757
- **Other tools give Claude "generally good instructions." ClaudeOS-Core gives Claude "instructions extracted from your actual code."**
758
-
759
- That's why Claude Code stops generating JPA code in your MyBatis project,
760
- stops using `success()` when your codebase uses `ok()`,
761
- and stops creating `user/controller/` directories when your project uses `controller/user/`.
762
-
763
- ### Complementary, not competing
764
-
765
- ClaudeOS-Core focuses on **project-specific rules and standards**.
766
- Other tools focus on **agent orchestration and workflows**.
767
-
768
- You can use ClaudeOS-Core to generate your project's rules, then use ECC or Harness on top for agent teams and workflow automation. They solve different problems.
769
-
770
- ---
771
-
772
- ## FAQ
773
-
774
- **Q: Does it modify my source code?**
775
- No. It only creates `CLAUDE.md`, `.claude/rules/`, and `claudeos-core/`. Your existing code is never modified.
776
-
777
- **Q: How much does it cost?**
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.
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.
782
- **Q: Should I commit the generated files to Git?**
783
- Yes, recommended. Your team can share the same Claude Code standards. Consider adding `claudeos-core/generated/` to `.gitignore` (analysis JSON is regeneratable).
784
-
785
- **Q: What about mixed-stack projects (e.g., Java backend + React frontend)?**
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.
787
-
788
- **Q: Does it work with Turborepo / pnpm workspaces / Lerna monorepos?**
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.
790
-
791
- **Q: What happens on re-run?**
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.
793
-
794
- **Q: Does NestJS get its own template or use the Express one?**
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.
796
-
797
- **Q: What about Vue / Nuxt projects?**
798
- Vue/Nuxt uses a dedicated `vue-nuxt` template covering Composition API, `<script setup>`, defineProps/defineEmits, Pinia stores, `useFetch`/`useAsyncData`, Nitro server routes, and `@nuxt/test-utils`. Next.js/React projects use the `node-nextjs` template.
799
-
800
- **Q: Does it support Kotlin?**
801
- Yes. ClaudeOS-Core auto-detects Kotlin from `build.gradle.kts` or the kotlin plugin in `build.gradle`. It uses a dedicated `kotlin-spring` template with Kotlin-specific analysis (data classes, sealed classes, coroutines, extension functions, MockK, etc.).
802
-
803
- **Q: What about CQRS / BFF architecture?**
804
- Fully supported for Kotlin multi-module projects. ClaudeOS-Core reads `settings.gradle.kts`, detects module types (command, query, bff, integration) from module names, and groups the same domain across Command/Query modules. The generated standards include separate rules for command controllers vs query controllers, BFF/Feign patterns, and inter-module communication conventions.
805
-
806
- **Q: What about Gradle multi-module monorepos?**
807
- ClaudeOS-Core scans all submodules (`**/src/main/kotlin/**/*.kt`) regardless of nesting depth. Module types are inferred from naming conventions (e.g., `reservation-command-server` โ†’ domain: `reservation`, type: `command`). Shared libraries (`shared-lib`, `integration-lib`) are also detected.
808
-
809
- **Q: What is the L4 Memory layer (v2.0.0)? Should I commit `claudeos-core/memory/`?**
810
- Yes โ€” **always commit** `claudeos-core/memory/`. It's persistent team knowledge: `decision-log.md` records the *why* behind architectural choices (append-only), `failure-patterns.md` registers recurring errors with importance scores so future sessions avoid them, `compaction.md` defines the 4-stage compaction policy, and `auto-rule-update.md` collects machine-generated rule improvement proposals. Unlike rules (auto-loaded by path), memory files are **on-demand** โ€” Claude reads them only when the `60.memory/*` rules direct it to (e.g. session-start scan of high-importance failures). This keeps context cost low while preserving long-term knowledge.
811
-
812
- **Q: What if Pass 4 fails?**
813
- The automated pipeline (`npx claudeos-core init`) has a static fallback: if `claude -p` fails or `pass4-prompt.md` is missing, it scaffolds the memory layer directly via `lib/memory-scaffold.js`. When `--lang` is non-English, the static fallback **must** translate via the `claude` CLI โ€” if that fails too, the run aborts with `InitError` (no silent English fallback). Re-run when `claude` is authenticated, or use `--lang en` to skip translation. Translation results are cached in `claudeos-core/generated/.i18n-cache-<lang>.json` so subsequent runs reuse them.
814
-
815
- **Q: What do `memory compact` / `memory score` / `memory propose-rules` do?**
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).
817
-
818
- **Q: Why does `--force` (or "fresh" resume mode) delete `.claude/rules/`?**
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.)
820
-
821
- **Q: What is `claudeos-core/generated/.staged-rules/` and why does it exist?**
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.
829
-
830
- ---
831
-
832
- ## Template Structure
833
-
834
- ```
835
- pass-prompts/templates/
836
- โ”œโ”€โ”€ common/ # Shared header/footer + pass4 + staging-override
837
- โ”œโ”€โ”€ java-spring/ # Java / Spring Boot
838
- โ”œโ”€โ”€ kotlin-spring/ # Kotlin / Spring Boot (CQRS, BFF, multi-module)
839
- โ”œโ”€โ”€ node-express/ # Node.js / Express
840
- โ”œโ”€โ”€ node-nestjs/ # Node.js / NestJS (Module, DI, Guard, Pipe, Interceptor)
841
- โ”œโ”€โ”€ node-fastify/ # Node.js / Fastify
842
- โ”œโ”€โ”€ node-nextjs/ # Next.js / React (App Router, RSC)
843
- โ”œโ”€โ”€ node-vite/ # Vite SPA (React, client-side routing, VITE_ env, Vitest)
844
- โ”œโ”€โ”€ vue-nuxt/ # Vue / Nuxt (Composition API, Pinia, Nitro)
845
- โ”œโ”€โ”€ angular/ # Angular
846
- โ”œโ”€โ”€ python-django/ # Python / Django (DRF)
847
- โ”œโ”€โ”€ python-fastapi/ # Python / FastAPI
848
- โ””โ”€โ”€ python-flask/ # Python / Flask (Blueprint, app factory, Jinja2)
849
- ```
850
-
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.
852
-
853
- ---
854
-
855
- ## Monorepo Support
856
-
857
- ClaudeOS-Core automatically detects JS/TS monorepo setups and scans sub-packages for dependencies.
858
-
859
- **Supported monorepo markers** (auto-detected):
860
- - `turbo.json` (Turborepo)
861
- - `pnpm-workspace.yaml` (pnpm workspaces)
862
- - `lerna.json` (Lerna)
863
- - `package.json#workspaces` (npm/yarn workspaces)
864
-
865
- **Run from the monorepo root** โ€” ClaudeOS-Core reads `apps/*/package.json` and `packages/*/package.json` to discover framework/ORM/DB dependencies across sub-packages:
866
-
867
- ```bash
868
- cd my-monorepo
869
- npx claudeos-core init
870
- ```
871
-
872
- **What gets detected:**
873
- - Dependencies from `apps/web/package.json` (e.g., `next`, `react`) โ†’ frontend stack
874
- - Dependencies from `apps/api/package.json` (e.g., `express`, `prisma`) โ†’ backend stack
875
- - Dependencies from `packages/db/package.json` (e.g., `drizzle-orm`) โ†’ ORM/DB
876
- - Custom workspace paths from `pnpm-workspace.yaml` (e.g., `services/*`)
877
-
878
- **Domain scanning also covers monorepo layouts:**
879
- - `apps/api/src/modules/*/` and `apps/api/src/*/` for backend domains
880
- - `apps/web/app/*/`, `apps/web/src/app/*/`, `apps/web/pages/*/` for frontend domains
881
- - `packages/*/src/*/` for shared package domains
882
-
883
- ```
884
- my-monorepo/ โ† Run here: npx claudeos-core init
885
- โ”œโ”€โ”€ turbo.json โ† Auto-detected as Turborepo
886
- โ”œโ”€โ”€ apps/
887
- โ”‚ โ”œโ”€โ”€ web/ โ† Next.js detected from apps/web/package.json
888
- โ”‚ โ”‚ โ”œโ”€โ”€ app/dashboard/ โ† Frontend domain detected
889
- โ”‚ โ”‚ โ””โ”€โ”€ package.json โ† { "dependencies": { "next": "^14" } }
890
- โ”‚ โ””โ”€โ”€ api/ โ† Express detected from apps/api/package.json
891
- โ”‚ โ”œโ”€โ”€ src/modules/users/ โ† Backend domain detected
892
- โ”‚ โ””โ”€โ”€ package.json โ† { "dependencies": { "express": "^4" } }
893
- โ”œโ”€โ”€ packages/
894
- โ”‚ โ”œโ”€โ”€ db/ โ† Drizzle detected from packages/db/package.json
895
- โ”‚ โ””โ”€โ”€ ui/
896
- โ””โ”€โ”€ package.json โ† { "workspaces": ["apps/*", "packages/*"] }
897
- ```
898
-
899
- > **Note:** For Kotlin/Java monorepos, multi-module detection uses `settings.gradle.kts` (see [Kotlin Multi-Module Detection](#kotlin-multi-module-domain-detection) above) and does not require JS monorepo markers.
900
-
901
- ## Troubleshooting
902
-
903
- **"claude: command not found"** โ€” Claude Code CLI is not installed or not in PATH. See [Claude Code docs](https://code.claude.com/docs/en/overview).
904
-
905
- **"npm install failed"** โ€” Node.js version may be too low. Requires v18+.
906
-
907
- **"0 domains detected"** โ€” Your project structure may be non-standard. See the detection patterns above for your stack.
908
-
909
- **"0 domains detected" on Kotlin project** โ€” Ensure your project has `build.gradle.kts` (or `build.gradle` with kotlin plugin) at the root, and source files are under `**/src/main/kotlin/`. For multi-module projects, ensure `settings.gradle.kts` contains `include()` statements. Single-module Kotlin projects (without `settings.gradle`) are also supported โ€” domains are extracted from package/class structure under `src/main/kotlin/`.
910
-
911
- **"Language detected as java instead of kotlin"** โ€” ClaudeOS-Core checks the root `build.gradle(.kts)` first, then submodule build files. If the root build file uses `java` plugin without `kotlin`, but submodules use Kotlin, the tool checks up to 5 submodule build files as fallback. If still not detected, ensure at least one `build.gradle.kts` contains `kotlin("jvm")` or `org.jetbrains.kotlin`.
912
-
913
- **"CQRS not detected"** โ€” Architecture detection relies on module names containing `command` and `query` keywords. If your modules use different naming (e.g., `write-server`, `read-server`), the CQRS architecture won't be auto-detected. You can manually adjust the generated prompts after plan-installer runs.
914
-
915
- **"Pass 3 produced 0 rule files under .claude/rules/" (v2.0.0)** โ€” Guard 2 fired: Claude ignored the `staging-override.md` directive and tried to write directly to `.claude/`, where Claude Code's sensitive-path policy blocks writes. Re-run with `npx claudeos-core init --force`. If the error persists, inspect `claudeos-core/generated/pass3-prompt.md` to verify the `staging-override.md` block is at the top.
916
-
917
- **"Pass 3 finished but N rule file(s) could not be moved from staging" (v2.0.0)** โ€” Guard 1 fired: the staging move hit a transient file lock (typically Windows antivirus or file-watcher). The marker is NOT written, so the next `init` run automatically retries Pass 3. Just re-run `npx claudeos-core init`.
918
-
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.
920
-
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.
926
-
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`.
928
-
929
- **"Static fallback failed while translating to lang='ko'" (v2.0.0)** โ€” When `--lang` is non-English, Pass 4 / static fallback / gap-fill all require `claude` CLI to translate. If translation fails (CLI not authenticated, network timeout, or strict validation rejected the output: <40% length, broken code fences, lost frontmatter, etc.), the run aborts rather than silently writing English. Fix: ensure `claude` is authenticated, or re-run with `--lang en` to skip translation.
930
-
931
- **"pass4-memory.json exists but memory/ is empty" (v2.0.0)** โ€” A previous run wrote the marker but the user (or a cleanup script) deleted `claudeos-core/memory/`. The CLI auto-detects this stale marker and re-runs Pass 4 on the next `init`. No manual action needed.
932
-
933
- **"pass4-memory.json exists but is malformed (missing passNum/memoryFiles) โ€” re-running Pass 4" (v2.0.0)** โ€” Info log, not an error. The Pass 4 marker content is now validated (`passNum === 4` + non-empty `memoryFiles` array), not just its existence. A partial Claude failure that emitted something like `{"error":"timeout"}` as the marker body would previously be accepted as success forever; now the marker is deleted and Pass 4 re-runs automatically.
934
-
935
- **"Could not delete stale pass3-complete.json / pass4-memory.json" InitError (v2.0.0)** โ€” `init` detected a stale marker (Pass 3: CLAUDE.md was externally deleted; Pass 4: memory/ empty or marker body malformed) and tried to remove it, but the `unlinkSync` call failed โ€” typically because Windows antivirus or a file-watcher (editor, IDE indexer) is holding the file handle. Previously this was silently ignored, causing the pipeline to skip the pass and re-use the stale marker. Now it fails loudly. Fix: close any editor/AV scanner that might have the file open, then re-run `npx claudeos-core init`.
936
-
937
- **"CLAUDEOS_SKIP_TRANSLATION=1 is set but --lang='ko' requires translation" InitError (v2.0.0)** โ€” You have the test-only env var `CLAUDEOS_SKIP_TRANSLATION=1` set in your shell (likely a leftover from CI/test setup) AND picked a non-English `--lang`. This env var short-circuits the translation path that Pass 4's static-fallback and gap-fill depend on for non-English output. `init` detects the conflict at language-selection time and aborts immediately (rather than crashing mid-Pass-4 with a confusing nested error). Fix: either `unset CLAUDEOS_SKIP_TRANSLATION` before running, or use `npx claudeos-core init --lang en`.
938
-
939
- ---
940
-
941
- ## Contributing
942
-
943
- Contributions are welcome! Areas where help is most needed:
944
-
945
- - **New stack templates** โ€” Ruby/Rails, Go (Gin/Fiber/Echo), PHP (Laravel/Symfony), Rust (Axum/Actix), Svelte/SvelteKit, Remix
946
- - **IDE integration** โ€” VS Code extension, IntelliJ plugin
947
- - **CI/CD templates** โ€” GitLab CI, CircleCI, Jenkins examples (GitHub Actions already shipped โ€” see `.github/workflows/test.yml`)
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)
949
-
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.
951
-
952
- ---
953
-
954
- ## Author
955
-
956
- Created by **claudeos-core** โ€” [GitHub](https://github.com/claudeos-core) ยท [Email](mailto:claudeoscore@gmail.com)
957
-
958
- ## License
959
-
960
- ISC
1
+ # ClaudeOS-Core
2
+
3
+ **The only tool that reads your source code first, confirms your stack and patterns with deterministic analysis, then generates Claude Code rules tailored to your exact project.**
4
+
5
+ ```bash
6
+ npx claudeos-core init
7
+ ```
8
+
9
+ ClaudeOS-Core reads your codebase, extracts every pattern it finds, and generates a complete set of Standards, Rules, Skills, and Guides tailored to _your_ project. After that, when you tell Claude Code "Create a CRUD for orders", it produces code that matches your existing patterns exactly.
10
+
11
+ [๐Ÿ‡ฐ๐Ÿ‡ท ํ•œ๊ตญ์–ด](./README.ko.md) ยท [๐Ÿ‡จ๐Ÿ‡ณ ไธญๆ–‡](./README.zh-CN.md) ยท [๐Ÿ‡ฏ๐Ÿ‡ต ๆ—ฅๆœฌ่ชž](./README.ja.md) ยท [๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol](./README.es.md) ยท [๐Ÿ‡ป๐Ÿ‡ณ Tiแบฟng Viแป‡t](./README.vi.md) ยท [๐Ÿ‡ฎ๐Ÿ‡ณ เคนเคฟเคจเฅเคฆเฅ€](./README.hi.md) ยท [๐Ÿ‡ท๐Ÿ‡บ ะ ัƒััะบะธะน](./README.ru.md) ยท [๐Ÿ‡ซ๐Ÿ‡ท Franรงais](./README.fr.md) ยท [๐Ÿ‡ฉ๐Ÿ‡ช Deutsch](./README.de.md)
12
+
13
+ ---
14
+
15
+ ## Why ClaudeOS-Core?
16
+
17
+ Every other Claude Code tool works like this:
18
+
19
+ > **Human describes the project โ†’ LLM generates documentation**
20
+
21
+ ClaudeOS-Core works like this:
22
+
23
+ > **Code analyzes your source โ†’ Code builds a tailored prompt โ†’ LLM generates documentation โ†’ Code verifies the output**
24
+
25
+ This is not a small difference. Here's why it matters:
26
+
27
+ ### The core problem: LLMs guess. Code doesn't.
28
+
29
+ When you ask Claude to "analyze this project," it **guesses** your stack, your ORM, your domain structure.
30
+ It might see `spring-boot` in your `build.gradle` but miss that you use MyBatis (not JPA).
31
+ It might detect a `user/` directory but not realize your project uses layer-first packaging (Pattern A), not domain-first (Pattern B).
32
+
33
+ **ClaudeOS-Core doesn't guess.** Before Claude ever sees your project, Node.js code has already:
34
+
35
+ - Parsed `build.gradle` / `package.json` / `pyproject.toml` and **confirmed** your stack, ORM, DB, and package manager
36
+ - Scanned your directory structure and **confirmed** your domain list with file counts
37
+ - Classified your project structure into one of 5 Java patterns, Kotlin CQRS/BFF, or Next.js App Router/FSD
38
+ - Split domains into optimally-sized groups that fit Claude's context window
39
+ - Assembled a stack-specific prompt with all confirmed facts injected
40
+
41
+ By the time Claude receives the prompt, there's nothing left to guess. The stack is confirmed. The domains are confirmed. The structure pattern is confirmed. Claude's only job is to generate documentation that matches these **confirmed facts**.
42
+
43
+ ### The result
44
+
45
+ Other tools produce "generally good" documentation.
46
+ ClaudeOS-Core produces documentation that knows your project uses `ApiResponse.ok()` (not `ResponseEntity.success()`), that your MyBatis XML mappers live in `src/main/resources/mybatis/mappers/`, and that your package structure is `com.company.module.{domain}.controller` โ€” because it read your actual code.
47
+
48
+ ### Before & After
49
+
50
+ **Without ClaudeOS-Core** โ€” you ask Claude Code to create an Order CRUD:
51
+ ```
52
+ โŒ Uses JPA-style repository (your project uses MyBatis)
53
+ โŒ Creates ResponseEntity.success() (your wrapper is ApiResponse.ok())
54
+ โŒ Places files in order/controller/ (your project uses controller/order/)
55
+ โŒ Generates English comments (your team writes Korean comments)
56
+ โ†’ You spend 20 minutes fixing every generated file
57
+ ```
58
+
59
+ **With ClaudeOS-Core** โ€” `.claude/rules/` already contains your confirmed patterns:
60
+ ```
61
+ โœ… Generates MyBatis mapper + XML (detected from build.gradle)
62
+ โœ… Uses ApiResponse.ok() (extracted from your actual source)
63
+ โœ… Places files in controller/order/ (Pattern A confirmed by structure scan)
64
+ โœ… Korean comments (--lang ko applied)
65
+ โ†’ Generated code matches your project conventions immediately
66
+ ```
67
+
68
+ This difference compounds. 10 tasks/day ร— 20 minutes saved = **3+ hours/day**.
69
+
70
+ ---
71
+
72
+ ## Post-Generation Quality Assurance (v2.3.0)
73
+
74
+ Generation is only half the problem. The other half is **knowing the output is correct** โ€” across 10 output languages, across 11 stack templates, across projects of any size. v2.3.0 adds two deterministic validators that run after generation and do not depend on LLM self-checks:
75
+
76
+ ### `claude-md-validator` โ€” structural invariants
77
+
78
+ Every generated `CLAUDE.md` is checked against 25 structural invariants that use only language-invariant signals: markdown syntax (`^## `, `^### `), literal file names (`decision-log.md`, `failure-patterns.md` โ€” never translated), section counts, sub-section counts per section, and table-row counts. The same validator, byte-for-byte, produces identical verdicts on a `CLAUDE.md` generated in English, Korean, Japanese, Vietnamese, Hindi, Russian, Spanish, Chinese, French, or German.
79
+
80
+ The cross-language guarantee is verified by test fixtures in all 10 languages, including bad-case fixtures in 6 of those languages that produce identical error signatures. When an invariant fails on a Vietnamese project, the fix is the same as when it fails on a German project.
81
+
82
+ ### `content-validator [10/10]` โ€” path-claim verification and MANIFEST consistency
83
+
84
+ Reads every backticked path reference (`src/...`, `.claude/rules/...`, `claudeos-core/skills/...`) from all generated `.md` files and verifies them against the actual file system. Catches two classes of LLM failure that no tool detected before:
85
+
86
+ - **`STALE_PATH`** โ€” when Pass 3 or Pass 4 fabricates a plausible-but-nonexistent path. Typical cases: inferring `featureRoutePath.ts` from a TypeScript constant named `FEATURE_ROUTE_PATH` when the actual file is `routePath.ts`; assuming `src/main.tsx` from Vite convention in a multi-entry project; assuming `src/__mocks__/handlers.ts` from MSW documentation even when the project has no tests.
87
+ - **`MANIFEST_DRIFT`** โ€” when `claudeos-core/skills/00.shared/MANIFEST.md` registers a skill that `CLAUDE.md ยง6` doesn't mention (or vice versa). Recognizes the common orchestrator + sub-skills layout where `CLAUDE.md ยง6` is an entry point and `MANIFEST.md` is the full registry โ€” sub-skills are considered covered via their parent orchestrator.
88
+
89
+ The validator is paired with prompt-time prevention in `pass3-footer.md` and `pass4.md`: anti-pattern blocks documenting the specific hallucination classes (parent-directory prefix, Vite/MSW/Vitest/Jest/RTL library conventions), and explicit positive guidance to scope rules by directory when a concrete filename isn't in `pass3a-facts.md`.
90
+
91
+ ### Run validation on any project
92
+
93
+ ```bash
94
+ npx claudeos-core health # all validators โ€” single go/no-go verdict
95
+ npx claudeos-core lint # CLAUDE.md structural invariants only (any language)
96
+ ```
97
+
98
+ ### Real-world verification
99
+
100
+ v2.3.0 was validated end-to-end on two real-world Korean sibling projects before release: a single-SPA Vite + React 19 frontend with 14 domains and an 8-sub-skill `scaffold-page-feature` orchestrator, and a Spring Boot + MyBatis backend with 8 domains and an 8-sub-skill `scaffold-crud-feature` orchestrator undergoing a PostgreSQL โ†’ MariaDB migration. Both settled at **0 errors, 0 warnings** on the full health check โ€” `STALE_PATH` 0, `MANIFEST_DRIFT` 0, 25/25 structural invariants passing โ€” without any manual edits to the generated output.
101
+
102
+ ---
103
+
104
+ ## Supported Stacks
105
+
106
+ | Stack | Detection | Analysis Depth |
107
+ |---|---|---|
108
+ | **Java / Spring Boot** | `build.gradle`, `pom.xml`, 5 package patterns | 10 categories, 59 sub-items |
109
+ | **Kotlin / Spring Boot** | `build.gradle.kts`, kotlin plugin, `settings.gradle.kts`, CQRS/BFF auto-detect | 12 categories, 95 sub-items |
110
+ | **Node.js / Express** | `package.json` | 9 categories, 57 sub-items |
111
+ | **Node.js / NestJS** | `package.json` (`@nestjs/core`) | 10 categories, 68 sub-items |
112
+ | **Next.js / React** | `package.json`, `next.config.*`, FSD support | 9 categories, 55 sub-items |
113
+ | **Vue / Nuxt** | `package.json`, `nuxt.config.*`, Composition API | 9 categories, 58 sub-items |
114
+ | **Python / Django** | `requirements.txt`, `pyproject.toml` | 10 categories, 55 sub-items |
115
+ | **Python / FastAPI** | `requirements.txt`, `pyproject.toml` | 10 categories, 58 sub-items |
116
+ | **Node.js / Fastify** | `package.json` | 10 categories, 62 sub-items |
117
+ | **Vite / React SPA** | `package.json`, `vite.config.*` | 9 categories, 55 sub-items |
118
+ | **Angular** | `package.json`, `angular.json` | 12 categories, 78 sub-items |
119
+
120
+ Auto-detected: language & version, framework & version (including Vite as SPA framework), ORM (MyBatis, JPA, Exposed, Prisma, TypeORM, SQLAlchemy, etc.), database (PostgreSQL, MySQL, Oracle, MongoDB, SQLite), package manager (Gradle, Maven, npm, yarn, pnpm, pip, poetry), architecture (CQRS, BFF โ€” from module names), multi-module structure (from settings.gradle), monorepo (Turborepo, pnpm-workspace, Lerna, npm/yarn workspaces), **runtime configuration from `.env.example`** (v2.2.0 โ€” port/host/API-target across 16+ convention variable names for Vite, Next.js, Nuxt, Angular, Node, Python frameworks).
121
+
122
+ **You don't specify anything. It's all detected automatically.**
123
+
124
+ ### `.env`-driven runtime configuration (v2.2.0)
125
+
126
+ v2.2.0 adds `lib/env-parser.js` so generated `CLAUDE.md` reflects what the project actually declares rather than framework defaults.
127
+
128
+ - **Search order**: `.env.example` (canonical, committed) โ†’ `.env.local.example` โ†’ `.env.sample` โ†’ `.env.template` โ†’ `.env` โ†’ `.env.local` โ†’ `.env.development`. The `.example` variant wins because it is the developer-neutral shape-of-truth, not one contributor's local overrides.
129
+ - **Port variable conventions recognised**: `VITE_PORT` / `VITE_DEV_PORT` / `VITE_DESKTOP_PORT` / `NEXT_PUBLIC_PORT` / `NUXT_PORT` / `NG_PORT` / `APP_PORT` / `SERVER_PORT` / `HTTP_PORT` / `DEV_PORT` / `FLASK_RUN_PORT` / `UVICORN_PORT` / `DJANGO_PORT` / generic `PORT`. Framework-specific names win over the generic `PORT` when both are present.
130
+ - **Host & API target**: `VITE_DEV_HOST` / `VITE_API_TARGET` / `NEXT_PUBLIC_API_URL` / `NUXT_PUBLIC_API_BASE` / `BACKEND_URL` / `PROXY_TARGET` etc.
131
+ - **Precedence**: Spring Boot `application.yml` `server.port` still wins (framework-native config), then `.env`-declared port, then framework default (Vite 5173, Next.js 3000, Django 8000, etc.) as last resort.
132
+ - **Sensitive-variable redaction**: values of variables matching `PASSWORD` / `SECRET` / `TOKEN` / `API_KEY` / `ACCESS_KEY` / `PRIVATE_KEY` / `CREDENTIAL` / `JWT_SECRET` / `CLIENT_SECRET` / `SESSION_SECRET` / `BEARER` / `SALT` patterns are replaced with `***REDACTED***` before reaching any downstream generator. Defense-in-depth against accidentally committed secrets in `.env.example`. `DATABASE_URL` is explicitly whitelisted for stack-detector DB-identification back-compat.
133
+
134
+ ### Java Domain Detection (5 patterns with fallback)
135
+
136
+ | Priority | Pattern | Structure | Example |
137
+ |---|---|---|---|
138
+ | A | Layer-first | `controller/{domain}/` | `controller/user/UserController.java` |
139
+ | B | Domain-first | `{domain}/controller/` | `user/controller/UserController.java` |
140
+ | D | Module prefix | `{module}/{domain}/controller/` | `front/member/controller/MemberController.java` |
141
+ | E | DDD/Hexagonal | `{domain}/adapter/in/web/` | `user/adapter/in/web/UserController.java` |
142
+ | C | Flat | `controller/*.java` | `controller/UserController.java` โ†’ extracts `user` from class name |
143
+
144
+ Service-only domains (without controllers) are also detected via `service/`, `dao/`, `aggregator/`, `facade/`, `usecase/`, `orchestrator/`, `mapper/`, `repository/` directories. Skips: `common`, `config`, `util`, `core`, `front`, `admin`, `v1`, `v2`, etc.
145
+
146
+ ### Kotlin Multi-Module Domain Detection
147
+
148
+ For Kotlin projects with Gradle multi-module structure (e.g., CQRS monorepo):
149
+
150
+ | Step | What It Does | Example |
151
+ |---|---|---|
152
+ | 1 | Scan `settings.gradle.kts` for `include()` | Finds 14 modules |
153
+ | 2 | Detect module type from name | `reservation-command-server` โ†’ type: `command` |
154
+ | 3 | Extract domain from module name | `reservation-command-server` โ†’ domain: `reservation` |
155
+ | 4 | Group same domain across modules | `reservation-command-server` + `common-query-server` โ†’ 1 domain |
156
+ | 5 | Detect architecture | Has `command` + `query` modules โ†’ CQRS |
157
+
158
+ Supported module types: `command`, `query`, `bff`, `integration`, `standalone`, `library`. Shared libraries (`shared-lib`, `integration-lib`) are detected as special domains.
159
+
160
+ ### Frontend Domain Detection
161
+
162
+ - **App Router**: `app/{domain}/page.tsx` (Next.js)
163
+ - **Pages Router**: `pages/{domain}/index.tsx`
164
+ - **FSD (Feature-Sliced Design)**: `features/*/`, `widgets/*/`, `entities/*/`
165
+ - **RSC/Client split**: Detects `client.tsx` pattern, tracks Server/Client component separation
166
+ - **Non-standard nested paths**: Detects pages, components, and FSD layers under `src/*/` paths (e.g., `src/admin/pages/dashboard/`, `src/admin/components/form/`, `src/admin/features/billing/`)
167
+ - **Platform/tier-split detection (v2.0.0)**: Recognizes `src/{platform}/{subapp}/` layouts โ€” `{platform}` can be a device/target keyword (`desktop`, `pc`, `web`, `mobile`, `mc`, `mo`, `sp`, `tablet`, `tab`, `pwa`, `tv`, `ctv`, `ott`, `watch`, `wear`) or an access-tier keyword (`admin`, `cms`, `backoffice`, `back-office`, `portal`). Emits one domain per `(platform, subapp)` pair named `{platform}-{subapp}` with per-domain counts for routes/components/layouts/hooks. Runs across Angular, Next.js, React, and Vue simultaneously (multi-extension glob `{tsx,jsx,ts,js,vue}`). Requires โ‰ฅ2 source files per subapp to avoid noisy 1-file domains.
168
+ - **Monorepo platform split (v2.0.0)**: The platform scan also matches `{apps,packages}/*/src/{platform}/{subapp}/` (Turborepo/pnpm workspace with `src/`) and `{apps,packages}/{platform}/{subapp}/` (workspaces without `src/` wrapper).
169
+ - **Fallback E โ€” routes-file (v2.0.0)**: When primary scanners + Fallbacks Aโ€“D all return 0, globs `**/routes/*.{tsx,jsx,ts,js,vue}` and groups by the parent-of-`routes` directory name. Catches React Router file-routing projects (CRA/Vite + `react-router`) that don't match Next.js `page.tsx` or FSD layouts. Generic parent names (`src`, `app`, `pages`) are filtered out.
170
+ - **Config fallback**: Detects Next.js/Vite/Nuxt from config files when not in `package.json` (monorepo support)
171
+ - **Deep directory fallback**: For React/CRA/Vite/Vue/RN projects, scans `**/components/*/`, `**/views/*/`, `**/screens/*/`, `**/containers/*/`, `**/pages/*/`, `**/routes/*/`, `**/modules/*/`, `**/domains/*/` at any depth
172
+ - **Shared ignore lists (v2.0.0)**: All scanners share `BUILD_IGNORE_DIRS` (`node_modules`, `build`, `dist`, `out`, `.next`, `.nuxt`, `.svelte-kit`, `.angular`, `.turbo`, `.cache`, `.parcel-cache`, `coverage`, `storybook-static`, `.vercel`, `.netlify`) and `TEST_FILE_IGNORE` (spec/test/stories/e2e/cy + `__snapshots__`/`__tests__`) so build outputs and test fixtures don't inflate per-domain file counts.
173
+
174
+ ### Scanner Overrides (v2.0.0)
175
+
176
+ Drop an optional `.claudeos-scan.json` at your project root to extend scanner defaults without editing the toolkit. All fields are **additive** โ€” user entries extend defaults, never replace:
177
+
178
+ ```json
179
+ {
180
+ "frontendScan": {
181
+ "platformKeywords": ["kiosk"],
182
+ "skipSubappNames": ["legacy"],
183
+ "minSubappFiles": 3
184
+ }
185
+ }
186
+ ```
187
+
188
+ | Field | Default | Purpose |
189
+ |---|---|---|
190
+ | `platformKeywords` | built-in list above | Additional `{platform}` keywords for the platform scan (e.g., `kiosk`, `vr`, `embedded`) |
191
+ | `skipSubappNames` | structural dirs only | Additional subapp names to exclude from platform-scan domain emission |
192
+ | `minSubappFiles` | `2` | Override the minimum file count required before a subapp becomes a domain |
193
+
194
+ Missing file or malformed JSON โ†’ silently falls back to defaults (no crash). Typical use: opt-in a short abbreviation (`adm`, `bo`) that the built-in list excludes as too ambiguous, or raise `minSubappFiles` for noisy monorepos.
195
+
196
+ ---
197
+
198
+ ## Quick Start
199
+
200
+ ### Prerequisites
201
+
202
+ - **Node.js** v18+
203
+ - **Claude Code CLI** (installed & authenticated)
204
+
205
+ ### Installation
206
+
207
+ ```bash
208
+ cd /your/project/root
209
+
210
+ # Option A: npx (recommended โ€” no install needed)
211
+ npx claudeos-core init
212
+
213
+ # Option B: global install
214
+ npm install -g claudeos-core
215
+ claudeos-core init
216
+
217
+ # Option C: project devDependency
218
+ npm install --save-dev claudeos-core
219
+ npx claudeos-core init
220
+
221
+ # Option D: git clone (for development/contribution)
222
+ git clone https://github.com/claudeos-core/claudeos-core.git claudeos-core-tools
223
+
224
+ # Cross-platform (PowerShell, CMD, Bash, Zsh โ€” any terminal)
225
+ node claudeos-core-tools/bin/cli.js init
226
+
227
+ # Linux/macOS (Bash only)
228
+ bash claudeos-core-tools/bootstrap.sh
229
+ ```
230
+
231
+ ### Output Language (10 languages)
232
+
233
+ When you run `init` without `--lang`, an interactive selector appears โ€” use arrow keys or number keys to choose:
234
+
235
+ ```
236
+ โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
237
+ โ•‘ Select generated document language (required) โ•‘
238
+ โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
239
+
240
+ Generated files (CLAUDE.md, Standards, Rules,
241
+ Skills, Guides) will be written in English.
242
+
243
+ โฏ 1. en โ€” English
244
+ 2. ko โ€” ํ•œ๊ตญ์–ด (Korean)
245
+ 3. zh-CN โ€” ็ฎ€ไฝ“ไธญๆ–‡ (Chinese Simplified)
246
+ 4. ja โ€” ๆ—ฅๆœฌ่ชž (Japanese)
247
+ 5. es โ€” Espaรฑol (Spanish)
248
+ 6. vi โ€” Tiแบฟng Viแป‡t (Vietnamese)
249
+ 7. hi โ€” เคนเคฟเคจเฅเคฆเฅ€ (Hindi)
250
+ 8. ru โ€” ะ ัƒััะบะธะน (Russian)
251
+ 9. fr โ€” Franรงais (French)
252
+ 10. de โ€” Deutsch (German)
253
+
254
+ โ†‘โ†“ Move 1-0 Jump Enter Select ESC Cancel
255
+ ```
256
+
257
+ The description changes to the selected language as you navigate. To skip the selector, pass `--lang` directly:
258
+
259
+ ```bash
260
+ npx claudeos-core init --lang ko # Korean
261
+ npx claudeos-core init --lang ja # Japanese
262
+ npx claudeos-core init --lang en # English (default)
263
+ ```
264
+
265
+ > **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.
266
+
267
+ 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.
268
+
269
+ ### Manual Step-by-Step Installation
270
+
271
+ If you want full control over each phase โ€” or if the automated pipeline fails at any step โ€” you can run each stage manually. This is also useful for understanding how ClaudeOS-Core works internally.
272
+
273
+ #### Step 1: Clone and install dependencies
274
+
275
+ ```bash
276
+ cd /your/project/root
277
+
278
+ git clone https://github.com/claudeos-core/claudeos-core.git claudeos-core-tools
279
+ cd claudeos-core-tools && npm install && cd ..
280
+ ```
281
+
282
+ #### Step 2: Create directory structure
283
+
284
+ ```bash
285
+ # Rules (v2.0.0: added 60.memory)
286
+ mkdir -p .claude/rules/{00.core,10.backend,20.frontend,30.security-db,40.infra,50.sync,60.memory}
287
+
288
+ # Standards
289
+ mkdir -p claudeos-core/standard/{00.core,10.backend-api,20.frontend-ui,30.security-db,40.infra,50.verification,90.optional}
290
+
291
+ # Skills
292
+ mkdir -p claudeos-core/skills/{00.shared,10.backend-crud/scaffold-crud-feature,20.frontend-page/scaffold-page-feature,50.testing,90.experimental}
293
+
294
+ # Guide, Database, MCP, Generated, Memory (v2.0.0: added memory; v2.1.0: removed plan)
295
+ mkdir -p claudeos-core/guide/{01.onboarding,02.usage,03.troubleshooting,04.architecture}
296
+ mkdir -p claudeos-core/{database,mcp-guide,generated,memory}
297
+ ```
298
+
299
+ > **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.
300
+
301
+ #### Step 3: Run plan-installer (project analysis)
302
+
303
+ This scans your project, detects the stack, finds domains, splits them into groups, and generates prompts.
304
+
305
+ ```bash
306
+ node claudeos-core-tools/plan-installer/index.js
307
+ ```
308
+
309
+ **Output (in `claudeos-core/generated/`):**
310
+ - `project-analysis.json` โ€” detected stack, domains, frontend info
311
+ - `domain-groups.json` โ€” domain groups for Pass 1
312
+ - `pass1-backend-prompt.md` / `pass1-frontend-prompt.md` โ€” analysis prompts
313
+ - `pass2-prompt.md` โ€” merge prompt
314
+ - `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.
315
+ - `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)
316
+ - `pass4-prompt.md` โ€” L4 memory scaffolding prompt (v2.0.0; uses the same `staging-override.md` for `60.memory/` rule writes)
317
+
318
+ You can inspect these files to verify detection accuracy before proceeding.
319
+
320
+ #### Step 4: Pass 1 โ€” Deep code analysis (per domain group)
321
+
322
+ Run Pass 1 for each domain group. Check `domain-groups.json` for the number of groups.
323
+
324
+ ```bash
325
+ # Check how many groups
326
+ cat claudeos-core/generated/domain-groups.json | node -e "
327
+ const g = JSON.parse(require('fs').readFileSync('/dev/stdin','utf-8'));
328
+ g.groups.forEach((g,i) => console.log('Group '+(i+1)+': ['+g.domains.join(', ')+'] ('+g.type+', ~'+g.estimatedFiles+' files)'));
329
+ "
330
+
331
+ # Run Pass 1 for each group (replace domains and group number)
332
+ # Note: v1.6.1+ uses Node.js String.replace() instead of perl โ€” perl is no
333
+ # longer required, and replacement-function semantics prevent regex injection
334
+ # from $/&/$1 characters that may appear in domain names.
335
+ #
336
+ # For group 1:
337
+ DOMAIN_LIST="user, order, product" PASS_NUM=1 node -e "
338
+ const fs = require('fs');
339
+ const tpl = fs.readFileSync('claudeos-core/generated/pass1-backend-prompt.md','utf-8');
340
+ const out = tpl
341
+ .replace(/\{\{DOMAIN_GROUP\}\}/g, () => process.env.DOMAIN_LIST)
342
+ .replace(/\{\{PASS_NUM\}\}/g, () => process.env.PASS_NUM);
343
+ process.stdout.write(out);
344
+ " | claude -p --dangerously-skip-permissions
345
+
346
+ # For group 2 (if exists):
347
+ DOMAIN_LIST="payment, system, delivery" PASS_NUM=2 node -e "
348
+ const fs = require('fs');
349
+ const tpl = fs.readFileSync('claudeos-core/generated/pass1-backend-prompt.md','utf-8');
350
+ const out = tpl
351
+ .replace(/\{\{DOMAIN_GROUP\}\}/g, () => process.env.DOMAIN_LIST)
352
+ .replace(/\{\{PASS_NUM\}\}/g, () => process.env.PASS_NUM);
353
+ process.stdout.write(out);
354
+ " | claude -p --dangerously-skip-permissions
355
+
356
+ # For frontend groups, swap pass1-backend-prompt.md โ†’ pass1-frontend-prompt.md
357
+ ```
358
+
359
+ **Verify:** `ls claudeos-core/generated/pass1-*.json` should show one JSON per group.
360
+
361
+ #### Step 5: Pass 2 โ€” Merge analysis results
362
+
363
+ ```bash
364
+ cat claudeos-core/generated/pass2-prompt.md \
365
+ | claude -p --dangerously-skip-permissions
366
+ ```
367
+
368
+ **Verify:** `claudeos-core/generated/pass2-merged.json` should exist with 9+ top-level keys.
369
+
370
+ #### Step 6: Pass 3 โ€” Generate all documentation (split into multiple stages)
371
+
372
+ **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.
373
+
374
+ **Single-call mode (small projects only, โ‰ค5 domains):**
375
+
376
+ ```bash
377
+ cat claudeos-core/generated/pass3-prompt.md \
378
+ | claude -p --dangerously-skip-permissions
379
+ ```
380
+
381
+ **Stage-by-stage mode (recommended for all project sizes):**
382
+
383
+ The automated pipeline runs these stages. The stage list is:
384
+
385
+ | Stage | Writes | Notes |
386
+ |---|---|---|
387
+ | `3a` | `pass3a-facts.md` (5โ€“10 KB distilled fact sheet) | Reads `pass2-merged.json` once; later stages reference this file |
388
+ | `3b-core` | `CLAUDE.md`, common `standard/`, common `.claude/rules/` | Cross-project files; no domain-specific output |
389
+ | `3b-1..N` | Domain-specific `standard/60.domains/*.md` + domain rules | Batch of โ‰ค15 domains per stage (auto-divided at โ‰ฅ16 domains) |
390
+ | `3c-core` | `guide/` (9 files), `skills/00.shared/MANIFEST.md`, `skills/*/` orchestrators | Shared skills and all user-facing guides |
391
+ | `3c-1..N` | Domain sub-skills under `skills/20.frontend-page/scaffold-page-feature/` | Batch of โ‰ค15 domains per stage |
392
+ | `3d-aux` | `database/`, `mcp-guide/` | Fixed-size, independent of domain count |
393
+
394
+ 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.
395
+
396
+ **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).
397
+
398
+ > **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).
399
+
400
+ #### Step 7: Pass 4 โ€” Memory scaffolding
401
+
402
+ ```bash
403
+ cat claudeos-core/generated/pass4-prompt.md \
404
+ | claude -p --dangerously-skip-permissions
405
+ ```
406
+
407
+ **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`.
408
+
409
+ > **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/02.skills-sync.md` (v2.2.0 path โ€” the sync rule count was reduced from 3 to 2, so what was `03` is now `02`) always has a valid reference target. Idempotent: skips if the file already has real content (>20 chars).
410
+
411
+ > **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.
412
+
413
+ #### Step 8: Run verification tools
414
+
415
+ ```bash
416
+ # Generate metadata (required before other checks)
417
+ node claudeos-core-tools/manifest-generator/index.js
418
+
419
+ # Run all checks
420
+ node claudeos-core-tools/health-checker/index.js
421
+
422
+ # Or run individual checks:
423
+ node claudeos-core-tools/plan-validator/index.js --check # Plan โ†” disk consistency
424
+ node claudeos-core-tools/sync-checker/index.js # Unregistered/orphaned files
425
+ node claudeos-core-tools/content-validator/index.js # File quality checks (incl. memory/ section [9/9])
426
+ node claudeos-core-tools/pass-json-validator/index.js # Pass 1โ€“4 JSON + completion marker checks
427
+ ```
428
+
429
+ #### Step 9: Verify the results
430
+
431
+ ```bash
432
+ # Count generated files
433
+ find .claude claudeos-core -type f | grep -v node_modules | grep -v '/generated/' | wc -l
434
+
435
+ # Check CLAUDE.md
436
+ head -30 CLAUDE.md
437
+
438
+ # Check a standard file
439
+ cat claudeos-core/standard/00.core/01.project-overview.md | head -20
440
+
441
+ # Check rules
442
+ ls .claude/rules/*/
443
+ ```
444
+
445
+ > **Tip:** If any step fails, you can fix the issue and re-run just that step. Pass 1/2 results are cached โ€” if `pass1-N.json` or `pass2-merged.json` already exists, the automated pipeline skips them. Use `npx claudeos-core init --force` to delete previous results and start fresh.
446
+
447
+ ### Start Using
448
+
449
+ ```
450
+ # In Claude Code โ€” just ask naturally:
451
+ "Create a CRUD for the order domain"
452
+ "Add user authentication API"
453
+ "Refactor this code to match project patterns"
454
+
455
+ # Claude Code automatically references your generated Standards, Rules, and Skills.
456
+ ```
457
+
458
+ ---
459
+
460
+ ## How It Works โ€” 4-Pass Pipeline
461
+
462
+ ```
463
+ npx claudeos-core init
464
+ โ”‚
465
+ โ”œโ”€โ”€ [1] npm install โ† Dependencies (~10s)
466
+ โ”œโ”€โ”€ [2] Directory structure โ† Create folders (~1s)
467
+ โ”œโ”€โ”€ [3] plan-installer (Node.js) โ† Project scan (~5s)
468
+ โ”‚ โ”œโ”€โ”€ Auto-detect stack (multi-stack aware)
469
+ โ”‚ โ”œโ”€โ”€ Extract domain list (tagged: backend/frontend)
470
+ โ”‚ โ”œโ”€โ”€ Split into domain groups (per type)
471
+ โ”‚ โ”œโ”€โ”€ Build pass3-context.json (slim summary, v2.1.0)
472
+ โ”‚ โ””โ”€โ”€ Select stack-specific prompts (per type)
473
+ โ”‚
474
+ โ”œโ”€โ”€ [4] Pass 1 ร— N (claude -p) โ† Deep code analysis (~2-8min)
475
+ โ”‚ โ”œโ”€โ”€ โš™๏ธ Backend groups โ†’ backend-specific prompt
476
+ โ”‚ โ””โ”€โ”€ ๐ŸŽจ Frontend groups โ†’ frontend-specific prompt
477
+ โ”‚
478
+ โ”œโ”€โ”€ [5] Pass 2 ร— 1 (claude -p) โ† Merge analysis (~1min)
479
+ โ”‚ โ””โ”€โ”€ Consolidate ALL Pass 1 results into pass2-merged.json
480
+ โ”‚
481
+ โ”œโ”€โ”€ [6] Pass 3 (split mode, v2.1.0) โ† Generate everything
482
+ โ”‚ โ”‚
483
+ โ”‚ โ”œโ”€โ”€ 3a ร— 1 (claude -p) โ† Fact extraction (~5-10min)
484
+ โ”‚ โ”‚ โ””โ”€โ”€ Read pass2-merged.json once โ†’ pass3a-facts.md
485
+ โ”‚ โ”‚
486
+ โ”‚ โ”œโ”€โ”€ 3b-core ร— 1 (claude -p) โ† CLAUDE.md + common standard/rules
487
+ โ”‚ โ”œโ”€โ”€ 3b-1..N ร— N (claude -p) โ† Domain standards/rules (โ‰ค15 domains/batch)
488
+ โ”‚ โ”‚
489
+ โ”‚ โ”œโ”€โ”€ 3c-core ร— 1 (claude -p) โ† Guides + shared skills + MANIFEST.md
490
+ โ”‚ โ”œโ”€โ”€ 3c-1..N ร— N (claude -p) โ† Domain sub-skills (โ‰ค15 domains/batch)
491
+ โ”‚ โ”‚
492
+ โ”‚ โ””โ”€โ”€ 3d-aux ร— 1 (claude -p) โ† database/ + mcp-guide/ stubs
493
+ โ”‚
494
+ โ”œโ”€โ”€ [7] Pass 4 ร— 1 (claude -p) โ† Memory scaffolding (~30s-5min)
495
+ โ”‚ โ”œโ”€โ”€ Seed memory/ (decision-log, failure-patterns, โ€ฆ)
496
+ โ”‚ โ”œโ”€โ”€ Generate 60.memory/ rules
497
+ โ”‚ โ”œโ”€โ”€ Append "Memory (L4)" section to CLAUDE.md
498
+ โ”‚ โ””โ”€โ”€ Gap-fill: ensure skills/00.shared/MANIFEST.md exists (v2.1.0)
499
+ โ”‚
500
+ โ””โ”€โ”€ [8] Verification โ† Auto-run health checker
501
+ ```
502
+
503
+ ### Why 4 Passes?
504
+
505
+ **Pass 1** is the only pass that reads your source code. It selects representative files per domain and extracts patterns across 55โ€“95 analysis categories (per stack). For large projects, Pass 1 runs multiple times โ€” one per domain group. In multi-stack projects (e.g., Java backend + React frontend), backend and frontend domains use **different analysis prompts** tailored to each stack.
506
+
507
+ **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.
508
+
509
+ **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.
510
+
511
+ The Pass 3 prompt template also includes a **Phase 1 "Read Once, Extract Facts" block** with five rules that further constrain output volume:
512
+
513
+ - **Rule A** โ€” Reference the fact table; don't re-read `pass2-merged.json`.
514
+ - **Rule B** โ€” Idempotent file writing (skip if target exists with real content), making Pass 3 safely re-runnable after interruption.
515
+ - **Rule C** โ€” Cross-file consistency enforced via the fact table as single source of truth.
516
+ - **Rule D** โ€” Output conciseness: one line (`[WRITE]`/`[SKIP]`) between file writes, no restating the fact table, no echoing file content.
517
+ - **Rule E** โ€” Batch idempotent check: one `Glob` at PHASE 2 start instead of per-target `Read` calls.
518
+
519
+ In **v2.2.0**, Pass 3 also inlines a deterministic CLAUDE.md scaffold (`pass-prompts/templates/common/claude-md-scaffold.md`) into the prompt. This fixes the 8 top-level section titles and order so the generated `CLAUDE.md` no longer drifts across projects, while still letting per-section content adapt to each project. The stack-detector's new `.env`-parser (`lib/env-parser.js`) supplies `stack.envInfo` to the prompt so port/host/API-target rows match what the project actually declares rather than framework defaults.
520
+
521
+ **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.
522
+
523
+ ---
524
+
525
+ ## Generated File Structure
526
+
527
+ ```
528
+ your-project/
529
+ โ”‚
530
+ โ”œโ”€โ”€ CLAUDE.md โ† Claude Code entry point (deterministic 8-section structure, v2.2.0)
531
+ โ”‚
532
+ โ”œโ”€โ”€ .claude/
533
+ โ”‚ โ””โ”€โ”€ rules/ โ† Glob-triggered rules
534
+ โ”‚ โ”œโ”€โ”€ 00.core/
535
+ โ”‚ โ”œโ”€โ”€ 10.backend/
536
+ โ”‚ โ”œโ”€โ”€ 20.frontend/
537
+ โ”‚ โ”œโ”€โ”€ 30.security-db/
538
+ โ”‚ โ”œโ”€โ”€ 40.infra/
539
+ โ”‚ โ”œโ”€โ”€ 50.sync/ โ† Sync reminder rules
540
+ โ”‚ โ””โ”€โ”€ 60.memory/ โ† L4 memory on-demand scope rules (v2.0.0)
541
+ โ”‚
542
+ โ”œโ”€โ”€ claudeos-core/ โ† Main output directory
543
+ โ”‚ โ”œโ”€โ”€ generated/ โ† Analysis JSON + dynamic prompts + Pass markers (gitignore this)
544
+ โ”‚ โ”‚ โ”œโ”€โ”€ project-analysis.json โ† Stack info (multi-stack aware)
545
+ โ”‚ โ”‚ โ”œโ”€โ”€ domain-groups.json โ† Groups with type: backend/frontend
546
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass1-backend-prompt.md โ† Backend analysis prompt
547
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass1-frontend-prompt.md โ† Frontend analysis prompt (if detected)
548
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass2-prompt.md โ† Merge prompt
549
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass2-merged.json โ† Pass 2 output (consumed by Pass 3a only)
550
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass3-context.json โ† Slim summary (< 5 KB) for Pass 3 (v2.1.0)
551
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass3-prompt.md โ† Pass 3 prompt template (Phase 1 block prepended)
552
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass3a-facts.md โ† Fact sheet written by Pass 3a, read by 3b/3c/3d (v2.1.0)
553
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass4-prompt.md โ† Memory scaffolding prompt (v2.0.0)
554
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass3-complete.json โ† Pass 3 completion marker (split mode: includes groupsCompleted, v2.1.0)
555
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass4-memory.json โ† Pass 4 completion marker (skip on resume)
556
+ โ”‚ โ”‚ โ”œโ”€โ”€ rule-manifest.json โ† File index for verification tools
557
+ โ”‚ โ”‚ โ”œโ”€โ”€ sync-map.json โ† Plan โ†” disk mapping (empty in v2.1.0; kept for sync-checker compat)
558
+ โ”‚ โ”‚ โ”œโ”€โ”€ stale-report.json โ† Consolidated verification results
559
+ โ”‚ โ”‚ โ”œโ”€โ”€ .i18n-cache-<lang>.json โ† Translation cache (non-English `--lang`)
560
+ โ”‚ โ”‚ โ””โ”€โ”€ .staged-rules/ โ† Transient staging dir for `.claude/rules/` writes (auto-moved + cleaned)
561
+ โ”‚ โ”œโ”€โ”€ standard/ โ† Coding standards (15-19 files + per-domain in 60.domains/)
562
+ โ”‚ โ”‚ โ”œโ”€โ”€ 00.core/ โ† Overview, architecture, naming
563
+ โ”‚ โ”‚ โ”œโ”€โ”€ 10.backend-api/ โ† API patterns (stack-specific)
564
+ โ”‚ โ”‚ โ”œโ”€โ”€ 20.frontend-ui/ โ† Frontend patterns (if detected)
565
+ โ”‚ โ”‚ โ”œโ”€โ”€ 30.security-db/ โ† Security, DB schema, utilities
566
+ โ”‚ โ”‚ โ”œโ”€โ”€ 40.infra/ โ† Config, logging, CI/CD
567
+ โ”‚ โ”‚ โ”œโ”€โ”€ 50.verification/ โ† Build verification, testing
568
+ โ”‚ โ”‚ โ”œโ”€โ”€ 60.domains/ โ† Per-domain standards (written by Pass 3b-N, v2.1.0)
569
+ โ”‚ โ”‚ โ””โ”€โ”€ 90.optional/ โ† Optional conventions (stack-specific extras)
570
+ โ”‚ โ”œโ”€โ”€ skills/ โ† CRUD/page scaffolding skills
571
+ โ”‚ โ”‚ โ””โ”€โ”€ 00.shared/MANIFEST.md โ† Single source of truth for registered skills
572
+ โ”‚ โ”œโ”€โ”€ guide/ โ† Onboarding, FAQ, troubleshooting (9 files)
573
+ โ”‚ โ”œโ”€โ”€ database/ โ† DB schema, migration guide
574
+ โ”‚ โ”œโ”€โ”€ mcp-guide/ โ† MCP server integration guide
575
+ โ”‚ โ””โ”€โ”€ memory/ โ† L4: team knowledge (4 files) โ€” commit these
576
+ โ”‚ โ”œโ”€โ”€ decision-log.md โ† "Why" behind design decisions
577
+ โ”‚ โ”œโ”€โ”€ failure-patterns.md โ† Recurring errors & fixes (auto-scored โ€” `npx claudeos-core memory score`)
578
+ โ”‚ โ”œโ”€โ”€ compaction.md โ† 4-stage compaction strategy (run `npx claudeos-core memory compact`)
579
+ โ”‚ โ””โ”€โ”€ auto-rule-update.md โ† Rule improvement proposals (`npx claudeos-core memory propose-rules`)
580
+ โ”‚
581
+ โ””โ”€โ”€ claudeos-core-tools/ โ† This toolkit (don't modify)
582
+ ```
583
+
584
+ Every standard file includes โœ… correct examples, โŒ incorrect examples, and a rules summary table โ€” all derived from your actual code patterns, not generic templates.
585
+
586
+ > **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.
587
+
588
+ ### Gitignore recommendations
589
+
590
+ **Do commit** (team knowledge โ€” meant to be shared):
591
+ - `CLAUDE.md` โ€” Claude Code entry point
592
+ - `.claude/rules/**` โ€” auto-loaded rules
593
+ - `claudeos-core/standard/**`, `skills/**`, `guide/**`, `database/**`, `mcp-guide/**`, `plan/**` โ€” generated documentation
594
+ - `claudeos-core/memory/**` โ€” decision history, failure patterns, rule proposals
595
+
596
+ **Do NOT commit** (regeneratable build artifacts):
597
+
598
+ ```gitignore
599
+ # ClaudeOS-Core โ€” generated analysis & translation cache
600
+ claudeos-core/generated/
601
+ ```
602
+
603
+ The `generated/` directory contains analysis JSON (`pass1-*.json`, `pass2-merged.json`), prompts (`pass1/2/3/4-prompt.md`), Pass completion markers (`pass3-complete.json`, `pass4-memory.json`), translation cache (`.i18n-cache-<lang>.json`), and the transient staging directory (`.staged-rules/`) โ€” all rebuildable by re-running `npx claudeos-core init`.
604
+
605
+ ---
606
+
607
+ ## Auto-scaling by Project Size
608
+
609
+ 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.
610
+
611
+ | Project Size | Domains | Pass 3 Stages | Total `claude -p` | Est. Time |
612
+ |---|---|---|---|---|
613
+ | Small | 1โ€“4 | 4 (`3a`, `3b-core`, `3c-core`, `3d-aux`) | 7 (Pass 1 + 2 + 4 stages of Pass 3 + Pass 4) | ~10โ€“15 min |
614
+ | Medium | 5โ€“15 | 4 | 8โ€“9 | ~25โ€“45 min |
615
+ | Large | 16โ€“30 | **8** (3b, 3c each split into 2 batches) | 11โ€“12 | **~60โ€“105 min** |
616
+ | X-Large | 31โ€“45 | 10 | 13โ€“14 | ~100โ€“150 min |
617
+ | XX-Large | 46โ€“60 | 12 | 15โ€“16 | ~150โ€“200 min |
618
+ | XXX-Large | 61+ | 14+ | 17+ | 200 min+ |
619
+
620
+ 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)`.
621
+
622
+ 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.
623
+
624
+ ---
625
+
626
+ ## Verification Tools
627
+
628
+ ClaudeOS-Core includes 5 built-in verification tools that run automatically after generation:
629
+
630
+ ```bash
631
+ # Run all checks at once (recommended)
632
+ npx claudeos-core health
633
+
634
+ # Individual commands
635
+ npx claudeos-core validate # Plan โ†” disk comparison
636
+ npx claudeos-core refresh # Disk โ†’ Plan sync
637
+ npx claudeos-core restore # Plan โ†’ Disk restore
638
+
639
+ # Or use node directly (git clone users)
640
+ node claudeos-core-tools/health-checker/index.js
641
+ node claudeos-core-tools/manifest-generator/index.js
642
+ node claudeos-core-tools/plan-validator/index.js --check
643
+ node claudeos-core-tools/sync-checker/index.js
644
+ ```
645
+
646
+ | Tool | What It Does |
647
+ |---|---|
648
+ | **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. |
649
+ | **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. |
650
+ | **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). |
651
+ | **content-validator** | 10-check quality gate. Checks 1โ€“9 cover empty files, missing โœ…/โŒ examples, required sections, and L4 memory scaffold integrity (decision-log heading dates, failure-pattern required fields, fence-aware parsing). **Check 10 (v2.3.0)** adds path-claim verification across all generated `.md` files and MANIFEST โ†” CLAUDE.md ยง6 cross-reference โ€” catches `STALE_PATH` (fabricated paths like `featureRoutePath.ts`, `src/__mocks__/handlers.ts`) and `MANIFEST_DRIFT` (registered skills not mentioned in CLAUDE.md or vice versa), with an orchestrator/sub-skill exception that recognizes the canonical "ยง6 entry point + MANIFEST registry" split. |
652
+ | **claude-md-validator (v2.3.0)** | Structural invariant check on `CLAUDE.md` using only language-invariant signals (markdown syntax, literal file names, section/sub-section/table-row counts). 25 checks, language-agnostic โ€” identical verdicts across all 10 output languages. Invoked via `npx claudeos-core lint`. |
653
+ | **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 |
654
+
655
+ ---
656
+
657
+ ## How Claude Code Uses Your Documentation
658
+
659
+ ClaudeOS-Core generates documentation that Claude Code actually reads โ€” here's how:
660
+
661
+ ### What Claude Code reads automatically
662
+
663
+ | File | When | Guaranteed |
664
+ |---|---|---|
665
+ | `CLAUDE.md` | Every conversation start | Always |
666
+ | `.claude/rules/00.core/*` | When any file is edited (`paths: ["**/*"]`) | Always |
667
+ | `.claude/rules/10.backend/*` | When any file is edited (`paths: ["**/*"]`) | Always |
668
+ | `.claude/rules/20.frontend/*` | When any frontend file is edited (scoped to component/page/style paths) | Conditional |
669
+ | `.claude/rules/30.security-db/*` | When any file is edited (`paths: ["**/*"]`) | Always |
670
+ | `.claude/rules/40.infra/*` | Only when editing config/infra files (scoped paths) | Conditional |
671
+ | `.claude/rules/50.sync/*` | Only when editing claudeos-core files (scoped paths) | Conditional |
672
+ | `.claude/rules/60.memory/*` | When `claudeos-core/memory/*` is edited (scoped to memory paths) โ€” instructs **how** to read/write the on-demand memory layer | Conditional (v2.0.0) |
673
+
674
+ ### What Claude Code reads on-demand via rule references
675
+
676
+ Each rule file links to its corresponding standard via a `## Reference` section. Claude reads only the relevant standard for the current task:
677
+
678
+ - `claudeos-core/standard/**` โ€” coding patterns, โœ…/โŒ examples, naming conventions
679
+ - `claudeos-core/database/**` โ€” DB schema (for queries, mappers, migrations)
680
+ - `claudeos-core/memory/**` (v2.0.0) โ€” L4 team knowledge layer; **not** auto-loaded (would be too noisy on every conversation). Instead, the `60.memory/*` rules tell Claude *when* to Read these files: at session start (skim recent `decision-log.md` + high-importance `failure-patterns.md`), and append-on-demand when making decisions or hitting recurring errors.
681
+
682
+ The `00.standard-reference.md` serves as a directory of all standard files for discovering standards that have no corresponding rule.
683
+
684
+ ### What Claude Code does NOT read (saves context)
685
+
686
+ These folders are explicitly excluded via the `DO NOT Read` section in the standard-reference rule:
687
+
688
+ | Folder | Why excluded |
689
+ |---|---|
690
+ | `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. |
691
+ | `claudeos-core/generated/` | Build metadata JSON, prompts, Pass markers, translation cache, `.staged-rules/`. Not for coding. |
692
+ | `claudeos-core/guide/` | Onboarding guides for humans. |
693
+ | `claudeos-core/mcp-guide/` | MCP server docs. Not for coding. |
694
+ | `claudeos-core/memory/` (auto-load) | **Auto-load disabled** by design โ€” would balloon context on every conversation. Read on-demand via the `60.memory/*` rules instead (e.g. session-start scan of `failure-patterns.md`). Always commit these files. |
695
+
696
+ ---
697
+
698
+ ## Daily Workflow
699
+
700
+ ### After Installation
701
+
702
+ ```
703
+ # Just use Claude Code as normal โ€” it references your standards automatically:
704
+ "Create a CRUD for the order domain"
705
+ "Add user profile update API"
706
+ "Refactor this code to match project patterns"
707
+ ```
708
+
709
+ ### After Manually Editing Standards
710
+
711
+ ```bash
712
+ # After editing standards or rules files:
713
+ npx claudeos-core refresh
714
+
715
+ # Verify everything is consistent
716
+ npx claudeos-core health
717
+ ```
718
+
719
+ ### When Docs Get Corrupted
720
+
721
+ ```bash
722
+ # v2.1.0 recommendation: use git to restore (since master plans are no
723
+ # longer generated). Commit your generated docs regularly so you can roll
724
+ # back specific files without regenerating:
725
+ git checkout HEAD -- .claude/rules/ claudeos-core/
726
+
727
+ # Legacy (v2.0.x projects with claudeos-core/plan/ still present):
728
+ npx claudeos-core restore
729
+ ```
730
+
731
+ ### Memory Layer Maintenance (v2.0.0)
732
+
733
+ The L4 Memory layer (`claudeos-core/memory/`) accumulates team knowledge across sessions. Three CLI subcommands keep it healthy:
734
+
735
+ ```bash
736
+ # Compact: enforce 4-stage compaction policy (run periodically โ€” e.g. monthly)
737
+ npx claudeos-core memory compact
738
+ # Stage 1: summarize aged entries (>30 days, body โ†’ one-line)
739
+ # Stage 2: merge duplicate headings (frequency summed, latest fix kept)
740
+ # Stage 3: drop low-importance + aged (importance <3 AND lastSeen >60 days)
741
+ # Stage 4: enforce 400-line cap per file (oldest low-importance dropped first)
742
+
743
+ # Score: re-rank failure-patterns.md entries by importance
744
+ npx claudeos-core memory score
745
+ # importance = round(frequency ร— 1.5 + recency ร— 5), capped at 10
746
+ # Run after appending several new failure patterns
747
+
748
+ # Propose-rules: surface candidate rule additions from recurring failures
749
+ npx claudeos-core memory propose-rules
750
+ # Reads failure-patterns.md entries with frequency โ‰ฅ 3
751
+ # Computes confidence (sigmoid on weighted evidence ร— anchor multiplier)
752
+ # Writes proposals to memory/auto-rule-update.md (NOT auto-applied)
753
+ # Confidence โ‰ฅ 0.70 deserves serious review; accept โ†’ edit rule + log decision
754
+
755
+ # v2.1.0: `memory --help` now routes to subcommand help (was showing top-level)
756
+ npx claudeos-core memory --help
757
+ ```
758
+
759
+ > **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.
760
+
761
+ When to write to memory (Claude does this on-demand, but you can edit manually too):
762
+ - **`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.
763
+ - **`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.
764
+ - `compaction.md` and `auto-rule-update.md` โ€” generated/managed by the CLI subcommands above; don't edit by hand.
765
+
766
+ ### CI/CD Integration
767
+
768
+ ```yaml
769
+ # GitHub Actions example
770
+ - run: npx claudeos-core validate
771
+ # Exit code 1 blocks the PR
772
+
773
+ # Optional: monthly memory housekeeping (separate cron workflow)
774
+ - run: npx claudeos-core memory compact
775
+ - run: npx claudeos-core memory score
776
+ ```
777
+
778
+ ---
779
+
780
+ ## How Is This Different?
781
+
782
+ ### vs Other Claude Code Tools
783
+
784
+ | | ClaudeOS-Core | Everything Claude Code (50K+ โญ) | Harness | specs-generator | Claude `/init` |
785
+ |---|---|---|---|---|---|
786
+ | **Approach** | Code analyzes first, then LLM generates | Pre-built config presets | LLM designs agent teams | LLM generates spec docs | LLM writes CLAUDE.md |
787
+ | **Reads your source code** | โœ… Deterministic static analysis | โŒ | โŒ | โŒ (LLM reads) | โŒ (LLM reads) |
788
+ | **Stack detection** | Code confirms (ORM, DB, build tool, pkg manager) | N/A (stack-agnostic) | LLM guesses | LLM guesses | LLM guesses |
789
+ | **Domain detection** | Code confirms (Java 5 patterns, Kotlin CQRS, Next.js FSD) | N/A | LLM guesses | N/A | N/A |
790
+ | **Same project โ†’ Same result** | โœ… Deterministic analysis | โœ… (static files) | โŒ (LLM varies) | โŒ (LLM varies) | โŒ (LLM varies) |
791
+ | **Large project handling** | Domain group splitting (4 domains / 40 files per group) | N/A | No splitting | No splitting | Context window limit |
792
+ | **Output** | CLAUDE.md + Rules + Standards + Skills + Guides + Plans (40-50+ files) | Agents + Skills + Commands + Hooks | Agents + Skills | 6 spec documents | CLAUDE.md (1 file) |
793
+ | **Output location** | `.claude/rules/` (auto-loaded by Claude Code) | `.claude/` various | `.claude/agents/` + `.claude/skills/` | `.claude/steering/` + `specs/` | `CLAUDE.md` |
794
+ | **Post-generation verification** | โœ… 5 automated validators | โŒ | โŒ | โŒ | โŒ |
795
+ | **Multi-language output** | โœ… 10 languages | โŒ | โŒ | โŒ | โŒ |
796
+ | **Multi-stack** | โœ… Backend + Frontend simultaneous | โŒ Stack-agnostic | โŒ | โŒ | Partial |
797
+ | **Persistent memory layer** | โœ… L4 โ€” decision log + failure patterns + auto-scored rule proposals (v2.0.0) | โŒ | โŒ | โŒ | โŒ |
798
+ | **Agent orchestration** | โŒ | โœ… 28 agents | โœ… 6 patterns | โŒ | โŒ |
799
+
800
+ ### The key difference in one sentence
801
+
802
+ **Other tools give Claude "generally good instructions." ClaudeOS-Core gives Claude "instructions extracted from your actual code."**
803
+
804
+ That's why Claude Code stops generating JPA code in your MyBatis project,
805
+ stops using `success()` when your codebase uses `ok()`,
806
+ and stops creating `user/controller/` directories when your project uses `controller/user/`.
807
+
808
+ ### Complementary, not competing
809
+
810
+ ClaudeOS-Core focuses on **project-specific rules and standards**.
811
+ Other tools focus on **agent orchestration and workflows**.
812
+
813
+ You can use ClaudeOS-Core to generate your project's rules, then use ECC or Harness on top for agent teams and workflow automation. They solve different problems.
814
+
815
+ ---
816
+
817
+ ## FAQ
818
+
819
+ **Q: Does it modify my source code?**
820
+ No. It only creates `CLAUDE.md`, `.claude/rules/`, and `claudeos-core/`. Your existing code is never modified.
821
+
822
+ **Q: How much does it cost?**
823
+ 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.
824
+
825
+ **Q: What is Pass 3 split mode and why was it added in v2.1.0?**
826
+ 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.
827
+ **Q: Should I commit the generated files to Git?**
828
+ Yes, recommended. Your team can share the same Claude Code standards. Consider adding `claudeos-core/generated/` to `.gitignore` (analysis JSON is regeneratable).
829
+
830
+ **Q: What about mixed-stack projects (e.g., Java backend + React frontend)?**
831
+ 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.
832
+
833
+ **Q: Does it work with Turborepo / pnpm workspaces / Lerna monorepos?**
834
+ 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.
835
+
836
+ **Q: What happens on re-run?**
837
+ 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.
838
+
839
+ **Q: Does NestJS get its own template or use the Express one?**
840
+ 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.
841
+
842
+ **Q: What about Vue / Nuxt projects?**
843
+ Vue/Nuxt uses a dedicated `vue-nuxt` template covering Composition API, `<script setup>`, defineProps/defineEmits, Pinia stores, `useFetch`/`useAsyncData`, Nitro server routes, and `@nuxt/test-utils`. Next.js/React projects use the `node-nextjs` template.
844
+
845
+ **Q: Does it support Kotlin?**
846
+ Yes. ClaudeOS-Core auto-detects Kotlin from `build.gradle.kts` or the kotlin plugin in `build.gradle`. It uses a dedicated `kotlin-spring` template with Kotlin-specific analysis (data classes, sealed classes, coroutines, extension functions, MockK, etc.).
847
+
848
+ **Q: What about CQRS / BFF architecture?**
849
+ Fully supported for Kotlin multi-module projects. ClaudeOS-Core reads `settings.gradle.kts`, detects module types (command, query, bff, integration) from module names, and groups the same domain across Command/Query modules. The generated standards include separate rules for command controllers vs query controllers, BFF/Feign patterns, and inter-module communication conventions.
850
+
851
+ **Q: What about Gradle multi-module monorepos?**
852
+ ClaudeOS-Core scans all submodules (`**/src/main/kotlin/**/*.kt`) regardless of nesting depth. Module types are inferred from naming conventions (e.g., `reservation-command-server` โ†’ domain: `reservation`, type: `command`). Shared libraries (`shared-lib`, `integration-lib`) are also detected.
853
+
854
+ **Q: What is the L4 Memory layer (v2.0.0)? Should I commit `claudeos-core/memory/`?**
855
+ Yes โ€” **always commit** `claudeos-core/memory/`. It's persistent team knowledge: `decision-log.md` records the *why* behind architectural choices (append-only), `failure-patterns.md` registers recurring errors with importance scores so future sessions avoid them, `compaction.md` defines the 4-stage compaction policy, and `auto-rule-update.md` collects machine-generated rule improvement proposals. Unlike rules (auto-loaded by path), memory files are **on-demand** โ€” Claude reads them only when the `60.memory/*` rules direct it to (e.g. session-start scan of high-importance failures). This keeps context cost low while preserving long-term knowledge.
856
+
857
+ **Q: What if Pass 4 fails?**
858
+ The automated pipeline (`npx claudeos-core init`) has a static fallback: if `claude -p` fails or `pass4-prompt.md` is missing, it scaffolds the memory layer directly via `lib/memory-scaffold.js`. When `--lang` is non-English, the static fallback **must** translate via the `claude` CLI โ€” if that fails too, the run aborts with `InitError` (no silent English fallback). Re-run when `claude` is authenticated, or use `--lang en` to skip translation. Translation results are cached in `claudeos-core/generated/.i18n-cache-<lang>.json` so subsequent runs reuse them.
859
+
860
+ **Q: What do `memory compact` / `memory score` / `memory propose-rules` do?**
861
+ 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).
862
+
863
+ **Q: Why does `--force` (or "fresh" resume mode) delete `.claude/rules/`?**
864
+ 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.)
865
+
866
+ **Q: What is `claudeos-core/generated/.staged-rules/` and why does it exist?**
867
+ 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.
868
+
869
+ **Q: Can I run Pass 3 manually instead of `npx claudeos-core init`?**
870
+ 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.
871
+
872
+ **Q: My project is an upgrade from v2.0.x and has an existing `claudeos-core/plan/` directory. What do I do?**
873
+ 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.
874
+
875
+ ---
876
+
877
+ ## Template Structure
878
+
879
+ ```
880
+ pass-prompts/templates/
881
+ โ”œโ”€โ”€ common/ # Shared header/footer + pass4 + staging-override + CLAUDE.md scaffold (v2.2.0)
882
+ โ”‚ โ”œโ”€โ”€ header.md # Role + output-format directive (all passes)
883
+ โ”‚ โ”œโ”€โ”€ pass3-footer.md # Post-Pass-3 health-check instruction + 5 CRITICAL guardrail blocks (v2.2.0)
884
+ โ”‚ โ”œโ”€โ”€ pass3-phase1.md # "Read Once, Extract Facts" block with Rules A-E (v2.1.0)
885
+ โ”‚ โ”œโ”€โ”€ pass4.md # Memory scaffolding prompt (v2.0.0)
886
+ โ”‚ โ”œโ”€โ”€ staging-override.md # Redirects .claude/rules/** writes to .staged-rules/** (v2.0.0)
887
+ โ”‚ โ”œโ”€โ”€ claude-md-scaffold.md # Deterministic 8-section CLAUDE.md template (v2.2.0)
888
+ โ”‚ โ””โ”€โ”€ lang-instructions.json # Per-language output directives (10 languages)
889
+ โ”œโ”€โ”€ java-spring/ # Java / Spring Boot
890
+ โ”œโ”€โ”€ kotlin-spring/ # Kotlin / Spring Boot (CQRS, BFF, multi-module)
891
+ โ”œโ”€โ”€ node-express/ # Node.js / Express
892
+ โ”œโ”€โ”€ node-nestjs/ # Node.js / NestJS (Module, DI, Guard, Pipe, Interceptor)
893
+ โ”œโ”€โ”€ node-fastify/ # Node.js / Fastify
894
+ โ”œโ”€โ”€ node-nextjs/ # Next.js / React (App Router, RSC)
895
+ โ”œโ”€โ”€ node-vite/ # Vite SPA (React, client-side routing, VITE_ env, Vitest)
896
+ โ”œโ”€โ”€ vue-nuxt/ # Vue / Nuxt (Composition API, Pinia, Nitro)
897
+ โ”œโ”€โ”€ angular/ # Angular
898
+ โ”œโ”€โ”€ python-django/ # Python / Django (DRF)
899
+ โ”œโ”€โ”€ python-fastapi/ # Python / FastAPI
900
+ โ””โ”€โ”€ python-flask/ # Python / Flask (Blueprint, app factory, Jinja2)
901
+ ```
902
+
903
+ `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.
904
+
905
+ **In v2.2.0**, the Pass 3 prompt also inlines `common/claude-md-scaffold.md` (the deterministic 8-section CLAUDE.md template) between the phase1 block and the stack-specific body โ€” this fixes the section structure so generated CLAUDE.md files don't drift across projects while letting content adapt per-project. Templates are written **English-first**; the language injection from `lang-instructions.json` tells the LLM to translate section titles and prose at emit time into the target output language.
906
+
907
+ ---
908
+
909
+ ## Monorepo Support
910
+
911
+ ClaudeOS-Core automatically detects JS/TS monorepo setups and scans sub-packages for dependencies.
912
+
913
+ **Supported monorepo markers** (auto-detected):
914
+ - `turbo.json` (Turborepo)
915
+ - `pnpm-workspace.yaml` (pnpm workspaces)
916
+ - `lerna.json` (Lerna)
917
+ - `package.json#workspaces` (npm/yarn workspaces)
918
+
919
+ **Run from the monorepo root** โ€” ClaudeOS-Core reads `apps/*/package.json` and `packages/*/package.json` to discover framework/ORM/DB dependencies across sub-packages:
920
+
921
+ ```bash
922
+ cd my-monorepo
923
+ npx claudeos-core init
924
+ ```
925
+
926
+ **What gets detected:**
927
+ - Dependencies from `apps/web/package.json` (e.g., `next`, `react`) โ†’ frontend stack
928
+ - Dependencies from `apps/api/package.json` (e.g., `express`, `prisma`) โ†’ backend stack
929
+ - Dependencies from `packages/db/package.json` (e.g., `drizzle-orm`) โ†’ ORM/DB
930
+ - Custom workspace paths from `pnpm-workspace.yaml` (e.g., `services/*`)
931
+
932
+ **Domain scanning also covers monorepo layouts:**
933
+ - `apps/api/src/modules/*/` and `apps/api/src/*/` for backend domains
934
+ - `apps/web/app/*/`, `apps/web/src/app/*/`, `apps/web/pages/*/` for frontend domains
935
+ - `packages/*/src/*/` for shared package domains
936
+
937
+ ```
938
+ my-monorepo/ โ† Run here: npx claudeos-core init
939
+ โ”œโ”€โ”€ turbo.json โ† Auto-detected as Turborepo
940
+ โ”œโ”€โ”€ apps/
941
+ โ”‚ โ”œโ”€โ”€ web/ โ† Next.js detected from apps/web/package.json
942
+ โ”‚ โ”‚ โ”œโ”€โ”€ app/dashboard/ โ† Frontend domain detected
943
+ โ”‚ โ”‚ โ””โ”€โ”€ package.json โ† { "dependencies": { "next": "^14" } }
944
+ โ”‚ โ””โ”€โ”€ api/ โ† Express detected from apps/api/package.json
945
+ โ”‚ โ”œโ”€โ”€ src/modules/users/ โ† Backend domain detected
946
+ โ”‚ โ””โ”€โ”€ package.json โ† { "dependencies": { "express": "^4" } }
947
+ โ”œโ”€โ”€ packages/
948
+ โ”‚ โ”œโ”€โ”€ db/ โ† Drizzle detected from packages/db/package.json
949
+ โ”‚ โ””โ”€โ”€ ui/
950
+ โ””โ”€โ”€ package.json โ† { "workspaces": ["apps/*", "packages/*"] }
951
+ ```
952
+
953
+ > **Note:** For Kotlin/Java monorepos, multi-module detection uses `settings.gradle.kts` (see [Kotlin Multi-Module Detection](#kotlin-multi-module-domain-detection) above) and does not require JS monorepo markers.
954
+
955
+ ## Troubleshooting
956
+
957
+ **"claude: command not found"** โ€” Claude Code CLI is not installed or not in PATH. See [Claude Code docs](https://code.claude.com/docs/en/overview).
958
+
959
+ **"npm install failed"** โ€” Node.js version may be too low. Requires v18+.
960
+
961
+ **"0 domains detected"** โ€” Your project structure may be non-standard. See the detection patterns above for your stack.
962
+
963
+ **"0 domains detected" on Kotlin project** โ€” Ensure your project has `build.gradle.kts` (or `build.gradle` with kotlin plugin) at the root, and source files are under `**/src/main/kotlin/`. For multi-module projects, ensure `settings.gradle.kts` contains `include()` statements. Single-module Kotlin projects (without `settings.gradle`) are also supported โ€” domains are extracted from package/class structure under `src/main/kotlin/`.
964
+
965
+ **"Language detected as java instead of kotlin"** โ€” ClaudeOS-Core checks the root `build.gradle(.kts)` first, then submodule build files. If the root build file uses `java` plugin without `kotlin`, but submodules use Kotlin, the tool checks up to 5 submodule build files as fallback. If still not detected, ensure at least one `build.gradle.kts` contains `kotlin("jvm")` or `org.jetbrains.kotlin`.
966
+
967
+ **"CQRS not detected"** โ€” Architecture detection relies on module names containing `command` and `query` keywords. If your modules use different naming (e.g., `write-server`, `read-server`), the CQRS architecture won't be auto-detected. You can manually adjust the generated prompts after plan-installer runs.
968
+
969
+ **"Pass 3 produced 0 rule files under .claude/rules/" (v2.0.0)** โ€” Guard 2 fired: Claude ignored the `staging-override.md` directive and tried to write directly to `.claude/`, where Claude Code's sensitive-path policy blocks writes. Re-run with `npx claudeos-core init --force`. If the error persists, inspect `claudeos-core/generated/pass3-prompt.md` to verify the `staging-override.md` block is at the top.
970
+
971
+ **"Pass 3 finished but N rule file(s) could not be moved from staging" (v2.0.0)** โ€” Guard 1 fired: the staging move hit a transient file lock (typically Windows antivirus or file-watcher). The marker is NOT written, so the next `init` run automatically retries Pass 3. Just re-run `npx claudeos-core init`.
972
+
973
+ **"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.
974
+
975
+ **"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.
976
+
977
+ **"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`.
978
+
979
+ **"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.
980
+
981
+ **"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`.
982
+
983
+ **"Static fallback failed while translating to lang='ko'" (v2.0.0)** โ€” When `--lang` is non-English, Pass 4 / static fallback / gap-fill all require `claude` CLI to translate. If translation fails (CLI not authenticated, network timeout, or strict validation rejected the output: <40% length, broken code fences, lost frontmatter, etc.), the run aborts rather than silently writing English. Fix: ensure `claude` is authenticated, or re-run with `--lang en` to skip translation.
984
+
985
+ **"pass4-memory.json exists but memory/ is empty" (v2.0.0)** โ€” A previous run wrote the marker but the user (or a cleanup script) deleted `claudeos-core/memory/`. The CLI auto-detects this stale marker and re-runs Pass 4 on the next `init`. No manual action needed.
986
+
987
+ **"pass4-memory.json exists but is malformed (missing passNum/memoryFiles) โ€” re-running Pass 4" (v2.0.0)** โ€” Info log, not an error. The Pass 4 marker content is now validated (`passNum === 4` + non-empty `memoryFiles` array), not just its existence. A partial Claude failure that emitted something like `{"error":"timeout"}` as the marker body would previously be accepted as success forever; now the marker is deleted and Pass 4 re-runs automatically.
988
+
989
+ **"Could not delete stale pass3-complete.json / pass4-memory.json" InitError (v2.0.0)** โ€” `init` detected a stale marker (Pass 3: CLAUDE.md was externally deleted; Pass 4: memory/ empty or marker body malformed) and tried to remove it, but the `unlinkSync` call failed โ€” typically because Windows antivirus or a file-watcher (editor, IDE indexer) is holding the file handle. Previously this was silently ignored, causing the pipeline to skip the pass and re-use the stale marker. Now it fails loudly. Fix: close any editor/AV scanner that might have the file open, then re-run `npx claudeos-core init`.
990
+
991
+ **"CLAUDEOS_SKIP_TRANSLATION=1 is set but --lang='ko' requires translation" InitError (v2.0.0)** โ€” You have the test-only env var `CLAUDEOS_SKIP_TRANSLATION=1` set in your shell (likely a leftover from CI/test setup) AND picked a non-English `--lang`. This env var short-circuits the translation path that Pass 4's static-fallback and gap-fill depend on for non-English output. `init` detects the conflict at language-selection time and aborts immediately (rather than crashing mid-Pass-4 with a confusing nested error). Fix: either `unset CLAUDEOS_SKIP_TRANSLATION` before running, or use `npx claudeos-core init --lang en`.
992
+
993
+ **"โš ๏ธ v2.2.0 upgrade detected" warning (v2.2.0)** โ€” Your existing `CLAUDE.md` was generated with a pre-v2.2.0 version. The default resume-mode regeneration will skip existing files under Rule B idempotency, so v2.2.0's structural improvements (8-section CLAUDE.md scaffold, per-file `40.infra/*` paths, `.env.example`-based port accuracy, Section 8 redesign into `Common Rules & Memory (L4)` with two sub-sections, `60.memory/*` rule row, forward-referenced `04.doc-writing-guide.md`) would NOT be applied. Fix: re-run with `npx claudeos-core init --force` โ€” this overwrites generated files (`CLAUDE.md`, `.claude/rules/`, `claudeos-core/standard/`, `claudeos-core/skills/`, `claudeos-core/guide/`) while preserving `claudeos-core/memory/` content (decision-log, failure-patterns entries you've accumulated are append-only and kept intact). Commit your project first if you want to diff the overwrites before accepting them.
994
+
995
+ **Port in CLAUDE.md differs from `.env.example` (v2.2.0)** โ€” The stack-detector's new `.env`-parser (`lib/env-parser.js`) reads `.env.example` first (canonical, committed), then `.env` variants as fallback. Port variables it recognizes include `PORT`, `VITE_PORT`, `VITE_DESKTOP_PORT`, `NEXT_PUBLIC_PORT`, `NUXT_PORT`, `DJANGO_PORT`, etc. For Spring Boot, `application.yml`'s `server.port` still takes precedence over `.env` (framework-native config wins). If your project uses an unusual env var name, either rename it to a recognized convention or raise an issue for us to extend `PORT_VAR_KEYS`. Framework defaults (Vite 5173, Next.js 3000, Django 8000) are used only when both direct detection and `.env` are silent.
996
+
997
+ **Secret values redacted as `***REDACTED***` in generated docs (v2.2.0)** โ€” Expected behavior. The v2.2.0 `.env`-parser automatically redacts values of variables matching `PASSWORD`/`SECRET`/`TOKEN`/`API_KEY`/`CREDENTIAL`/`PRIVATE_KEY` patterns before they reach any generator. This is defense-in-depth against accidentally committed secrets in `.env.example`. `DATABASE_URL` is kept as-is for stack-detector DB identification back-compat. If you see `***REDACTED***` somewhere in the generated `CLAUDE.md`, that's a bug โ€” redacted values should never reach the table; please file an issue. Non-sensitive runtime config (port, host, API target, NODE_ENV, etc.) pass through unchanged.
998
+
999
+ ---
1000
+
1001
+ ## Contributing
1002
+
1003
+ Contributions are welcome! Areas where help is most needed:
1004
+
1005
+ - **New stack templates** โ€” Ruby/Rails, Go (Gin/Fiber/Echo), PHP (Laravel/Symfony), Rust (Axum/Actix), Svelte/SvelteKit, Remix
1006
+ - **IDE integration** โ€” VS Code extension, IntelliJ plugin
1007
+ - **CI/CD templates** โ€” GitLab CI, CircleCI, Jenkins examples (GitHub Actions already shipped โ€” see `.github/workflows/test.yml`)
1008
+ - **Test coverage** โ€” Expanding test suite (currently 602 tests across 30 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), AI Work Rules template structure, and `.env`-parser port/host/API-target extraction + sensitive-variable redaction (v2.2.0))
1009
+
1010
+ 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.
1011
+
1012
+ ---
1013
+
1014
+ ## Author
1015
+
1016
+ Created by **claudeos-core** โ€” [GitHub](https://github.com/claudeos-core) ยท [Email](mailto:claudeoscore@gmail.com)
1017
+
1018
+ ## License
1019
+
1020
+ ISC