claudeos-core 2.2.0 โ†’ 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +1664 -907
  2. package/CONTRIBUTING.md +92 -92
  3. package/README.de.md +28 -0
  4. package/README.es.md +28 -0
  5. package/README.fr.md +28 -0
  6. package/README.hi.md +28 -0
  7. package/README.ja.md +28 -0
  8. package/README.ko.md +1014 -986
  9. package/README.md +1016 -987
  10. package/README.ru.md +28 -0
  11. package/README.vi.md +1015 -987
  12. package/README.zh-CN.md +28 -0
  13. package/bin/cli.js +152 -148
  14. package/bin/commands/init.js +1673 -1554
  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 -441
  22. package/lib/expected-guides.js +23 -23
  23. package/lib/expected-outputs.js +90 -90
  24. package/lib/language-config.js +35 -35
  25. package/lib/memory-scaffold.js +1058 -1054
  26. package/lib/plan-parser.js +165 -165
  27. package/lib/staged-rules.js +118 -118
  28. package/manifest-generator/index.js +174 -174
  29. package/package.json +90 -87
  30. package/pass-json-validator/index.js +337 -337
  31. package/pass-prompts/templates/common/claude-md-scaffold.md +52 -10
  32. package/pass-prompts/templates/common/pass3-footer.md +402 -224
  33. package/pass-prompts/templates/common/pass3b-core-header.md +43 -0
  34. package/pass-prompts/templates/common/pass4.md +375 -305
  35. package/pass-prompts/templates/common/staging-override.md +26 -26
  36. package/pass-prompts/templates/node-vite/pass1.md +117 -117
  37. package/pass-prompts/templates/node-vite/pass2.md +78 -78
  38. package/pass-prompts/templates/python-flask/pass1.md +119 -119
  39. package/pass-prompts/templates/python-flask/pass2.md +85 -85
  40. package/plan-installer/domain-grouper.js +76 -76
  41. package/plan-installer/index.js +137 -137
  42. package/plan-installer/prompt-generator.js +188 -145
  43. package/plan-installer/scanners/scan-frontend.js +505 -473
  44. package/plan-installer/scanners/scan-java.js +226 -226
  45. package/plan-installer/scanners/scan-node.js +57 -57
  46. package/plan-installer/scanners/scan-python.js +85 -85
  47. package/plan-installer/stack-detector.js +482 -482
  48. package/plan-installer/structure-scanner.js +65 -65
  49. package/sync-checker/index.js +177 -177
package/README.md CHANGED
@@ -1,987 +1,1016 @@
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), **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).
89
-
90
- **You don't specify anything. It's all detected automatically.**
91
-
92
- ### `.env`-driven runtime configuration (v2.2.0)
93
-
94
- v2.2.0 adds `lib/env-parser.js` so generated `CLAUDE.md` reflects what the project actually declares rather than framework defaults.
95
-
96
- - **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.
97
- - **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.
98
- - **Host & API target**: `VITE_DEV_HOST` / `VITE_API_TARGET` / `NEXT_PUBLIC_API_URL` / `NUXT_PUBLIC_API_BASE` / `BACKEND_URL` / `PROXY_TARGET` etc.
99
- - **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.
100
- - **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.
101
-
102
- ### Java Domain Detection (5 patterns with fallback)
103
-
104
- | Priority | Pattern | Structure | Example |
105
- |---|---|---|---|
106
- | A | Layer-first | `controller/{domain}/` | `controller/user/UserController.java` |
107
- | B | Domain-first | `{domain}/controller/` | `user/controller/UserController.java` |
108
- | D | Module prefix | `{module}/{domain}/controller/` | `front/member/controller/MemberController.java` |
109
- | E | DDD/Hexagonal | `{domain}/adapter/in/web/` | `user/adapter/in/web/UserController.java` |
110
- | C | Flat | `controller/*.java` | `controller/UserController.java` โ†’ extracts `user` from class name |
111
-
112
- 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.
113
-
114
- ### Kotlin Multi-Module Domain Detection
115
-
116
- For Kotlin projects with Gradle multi-module structure (e.g., CQRS monorepo):
117
-
118
- | Step | What It Does | Example |
119
- |---|---|---|
120
- | 1 | Scan `settings.gradle.kts` for `include()` | Finds 14 modules |
121
- | 2 | Detect module type from name | `reservation-command-server` โ†’ type: `command` |
122
- | 3 | Extract domain from module name | `reservation-command-server` โ†’ domain: `reservation` |
123
- | 4 | Group same domain across modules | `reservation-command-server` + `common-query-server` โ†’ 1 domain |
124
- | 5 | Detect architecture | Has `command` + `query` modules โ†’ CQRS |
125
-
126
- Supported module types: `command`, `query`, `bff`, `integration`, `standalone`, `library`. Shared libraries (`shared-lib`, `integration-lib`) are detected as special domains.
127
-
128
- ### Frontend Domain Detection
129
-
130
- - **App Router**: `app/{domain}/page.tsx` (Next.js)
131
- - **Pages Router**: `pages/{domain}/index.tsx`
132
- - **FSD (Feature-Sliced Design)**: `features/*/`, `widgets/*/`, `entities/*/`
133
- - **RSC/Client split**: Detects `client.tsx` pattern, tracks Server/Client component separation
134
- - **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/`)
135
- - **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.
136
- - **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).
137
- - **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.
138
- - **Config fallback**: Detects Next.js/Vite/Nuxt from config files when not in `package.json` (monorepo support)
139
- - **Deep directory fallback**: For React/CRA/Vite/Vue/RN projects, scans `**/components/*/`, `**/views/*/`, `**/screens/*/`, `**/containers/*/`, `**/pages/*/`, `**/routes/*/`, `**/modules/*/`, `**/domains/*/` at any depth
140
- - **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.
141
-
142
- ### Scanner Overrides (v2.0.0)
143
-
144
- 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:
145
-
146
- ```json
147
- {
148
- "frontendScan": {
149
- "platformKeywords": ["kiosk"],
150
- "skipSubappNames": ["legacy"],
151
- "minSubappFiles": 3
152
- }
153
- }
154
- ```
155
-
156
- | Field | Default | Purpose |
157
- |---|---|---|
158
- | `platformKeywords` | built-in list above | Additional `{platform}` keywords for the platform scan (e.g., `kiosk`, `vr`, `embedded`) |
159
- | `skipSubappNames` | structural dirs only | Additional subapp names to exclude from platform-scan domain emission |
160
- | `minSubappFiles` | `2` | Override the minimum file count required before a subapp becomes a domain |
161
-
162
- 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.
163
-
164
- ---
165
-
166
- ## Quick Start
167
-
168
- ### Prerequisites
169
-
170
- - **Node.js** v18+
171
- - **Claude Code CLI** (installed & authenticated)
172
-
173
- ### Installation
174
-
175
- ```bash
176
- cd /your/project/root
177
-
178
- # Option A: npx (recommended โ€” no install needed)
179
- npx claudeos-core init
180
-
181
- # Option B: global install
182
- npm install -g claudeos-core
183
- claudeos-core init
184
-
185
- # Option C: project devDependency
186
- npm install --save-dev claudeos-core
187
- npx claudeos-core init
188
-
189
- # Option D: git clone (for development/contribution)
190
- git clone https://github.com/claudeos-core/claudeos-core.git claudeos-core-tools
191
-
192
- # Cross-platform (PowerShell, CMD, Bash, Zsh โ€” any terminal)
193
- node claudeos-core-tools/bin/cli.js init
194
-
195
- # Linux/macOS (Bash only)
196
- bash claudeos-core-tools/bootstrap.sh
197
- ```
198
-
199
- ### Output Language (10 languages)
200
-
201
- When you run `init` without `--lang`, an interactive selector appears โ€” use arrow keys or number keys to choose:
202
-
203
- ```
204
- โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
205
- โ•‘ Select generated document language (required) โ•‘
206
- โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
207
-
208
- Generated files (CLAUDE.md, Standards, Rules,
209
- Skills, Guides) will be written in English.
210
-
211
- โฏ 1. en โ€” English
212
- 2. ko โ€” ํ•œ๊ตญ์–ด (Korean)
213
- 3. zh-CN โ€” ็ฎ€ไฝ“ไธญๆ–‡ (Chinese Simplified)
214
- 4. ja โ€” ๆ—ฅๆœฌ่ชž (Japanese)
215
- 5. es โ€” Espaรฑol (Spanish)
216
- 6. vi โ€” Tiแบฟng Viแป‡t (Vietnamese)
217
- 7. hi โ€” เคนเคฟเคจเฅเคฆเฅ€ (Hindi)
218
- 8. ru โ€” ะ ัƒััะบะธะน (Russian)
219
- 9. fr โ€” Franรงais (French)
220
- 10. de โ€” Deutsch (German)
221
-
222
- โ†‘โ†“ Move 1-0 Jump Enter Select ESC Cancel
223
- ```
224
-
225
- The description changes to the selected language as you navigate. To skip the selector, pass `--lang` directly:
226
-
227
- ```bash
228
- npx claudeos-core init --lang ko # Korean
229
- npx claudeos-core init --lang ja # Japanese
230
- npx claudeos-core init --lang en # English (default)
231
- ```
232
-
233
- > **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.
234
-
235
- 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.
236
-
237
- ### Manual Step-by-Step Installation
238
-
239
- 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.
240
-
241
- #### Step 1: Clone and install dependencies
242
-
243
- ```bash
244
- cd /your/project/root
245
-
246
- git clone https://github.com/claudeos-core/claudeos-core.git claudeos-core-tools
247
- cd claudeos-core-tools && npm install && cd ..
248
- ```
249
-
250
- #### Step 2: Create directory structure
251
-
252
- ```bash
253
- # Rules (v2.0.0: added 60.memory)
254
- mkdir -p .claude/rules/{00.core,10.backend,20.frontend,30.security-db,40.infra,50.sync,60.memory}
255
-
256
- # Standards
257
- mkdir -p claudeos-core/standard/{00.core,10.backend-api,20.frontend-ui,30.security-db,40.infra,50.verification,90.optional}
258
-
259
- # Skills
260
- mkdir -p claudeos-core/skills/{00.shared,10.backend-crud/scaffold-crud-feature,20.frontend-page/scaffold-page-feature,50.testing,90.experimental}
261
-
262
- # Guide, Database, MCP, Generated, Memory (v2.0.0: added memory; v2.1.0: removed plan)
263
- mkdir -p claudeos-core/guide/{01.onboarding,02.usage,03.troubleshooting,04.architecture}
264
- mkdir -p claudeos-core/{database,mcp-guide,generated,memory}
265
- ```
266
-
267
- > **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.
268
-
269
- #### Step 3: Run plan-installer (project analysis)
270
-
271
- This scans your project, detects the stack, finds domains, splits them into groups, and generates prompts.
272
-
273
- ```bash
274
- node claudeos-core-tools/plan-installer/index.js
275
- ```
276
-
277
- **Output (in `claudeos-core/generated/`):**
278
- - `project-analysis.json` โ€” detected stack, domains, frontend info
279
- - `domain-groups.json` โ€” domain groups for Pass 1
280
- - `pass1-backend-prompt.md` / `pass1-frontend-prompt.md` โ€” analysis prompts
281
- - `pass2-prompt.md` โ€” merge prompt
282
- - `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.
283
- - `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)
284
- - `pass4-prompt.md` โ€” L4 memory scaffolding prompt (v2.0.0; uses the same `staging-override.md` for `60.memory/` rule writes)
285
-
286
- You can inspect these files to verify detection accuracy before proceeding.
287
-
288
- #### Step 4: Pass 1 โ€” Deep code analysis (per domain group)
289
-
290
- Run Pass 1 for each domain group. Check `domain-groups.json` for the number of groups.
291
-
292
- ```bash
293
- # Check how many groups
294
- cat claudeos-core/generated/domain-groups.json | node -e "
295
- const g = JSON.parse(require('fs').readFileSync('/dev/stdin','utf-8'));
296
- g.groups.forEach((g,i) => console.log('Group '+(i+1)+': ['+g.domains.join(', ')+'] ('+g.type+', ~'+g.estimatedFiles+' files)'));
297
- "
298
-
299
- # Run Pass 1 for each group (replace domains and group number)
300
- # Note: v1.6.1+ uses Node.js String.replace() instead of perl โ€” perl is no
301
- # longer required, and replacement-function semantics prevent regex injection
302
- # from $/&/$1 characters that may appear in domain names.
303
- #
304
- # For group 1:
305
- DOMAIN_LIST="user, order, product" PASS_NUM=1 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 group 2 (if exists):
315
- DOMAIN_LIST="payment, system, delivery" PASS_NUM=2 node -e "
316
- const fs = require('fs');
317
- const tpl = fs.readFileSync('claudeos-core/generated/pass1-backend-prompt.md','utf-8');
318
- const out = tpl
319
- .replace(/\{\{DOMAIN_GROUP\}\}/g, () => process.env.DOMAIN_LIST)
320
- .replace(/\{\{PASS_NUM\}\}/g, () => process.env.PASS_NUM);
321
- process.stdout.write(out);
322
- " | claude -p --dangerously-skip-permissions
323
-
324
- # For frontend groups, swap pass1-backend-prompt.md โ†’ pass1-frontend-prompt.md
325
- ```
326
-
327
- **Verify:** `ls claudeos-core/generated/pass1-*.json` should show one JSON per group.
328
-
329
- #### Step 5: Pass 2 โ€” Merge analysis results
330
-
331
- ```bash
332
- cat claudeos-core/generated/pass2-prompt.md \
333
- | claude -p --dangerously-skip-permissions
334
- ```
335
-
336
- **Verify:** `claudeos-core/generated/pass2-merged.json` should exist with 9+ top-level keys.
337
-
338
- #### Step 6: Pass 3 โ€” Generate all documentation (split into multiple stages)
339
-
340
- **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.
341
-
342
- **Single-call mode (small projects only, โ‰ค5 domains):**
343
-
344
- ```bash
345
- cat claudeos-core/generated/pass3-prompt.md \
346
- | claude -p --dangerously-skip-permissions
347
- ```
348
-
349
- **Stage-by-stage mode (recommended for all project sizes):**
350
-
351
- The automated pipeline runs these stages. The stage list is:
352
-
353
- | Stage | Writes | Notes |
354
- |---|---|---|
355
- | `3a` | `pass3a-facts.md` (5โ€“10 KB distilled fact sheet) | Reads `pass2-merged.json` once; later stages reference this file |
356
- | `3b-core` | `CLAUDE.md`, common `standard/`, common `.claude/rules/` | Cross-project files; no domain-specific output |
357
- | `3b-1..N` | Domain-specific `standard/60.domains/*.md` + domain rules | Batch of โ‰ค15 domains per stage (auto-divided at โ‰ฅ16 domains) |
358
- | `3c-core` | `guide/` (9 files), `skills/00.shared/MANIFEST.md`, `skills/*/` orchestrators | Shared skills and all user-facing guides |
359
- | `3c-1..N` | Domain sub-skills under `skills/20.frontend-page/scaffold-page-feature/` | Batch of โ‰ค15 domains per stage |
360
- | `3d-aux` | `database/`, `mcp-guide/` | Fixed-size, independent of domain count |
361
-
362
- 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.
363
-
364
- **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).
365
-
366
- > **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).
367
-
368
- #### Step 7: Pass 4 โ€” Memory scaffolding
369
-
370
- ```bash
371
- cat claudeos-core/generated/pass4-prompt.md \
372
- | claude -p --dangerously-skip-permissions
373
- ```
374
-
375
- **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`.
376
-
377
- > **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).
378
-
379
- > **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.
380
-
381
- #### Step 8: Run verification tools
382
-
383
- ```bash
384
- # Generate metadata (required before other checks)
385
- node claudeos-core-tools/manifest-generator/index.js
386
-
387
- # Run all checks
388
- node claudeos-core-tools/health-checker/index.js
389
-
390
- # Or run individual checks:
391
- node claudeos-core-tools/plan-validator/index.js --check # Plan โ†” disk consistency
392
- node claudeos-core-tools/sync-checker/index.js # Unregistered/orphaned files
393
- node claudeos-core-tools/content-validator/index.js # File quality checks (incl. memory/ section [9/9])
394
- node claudeos-core-tools/pass-json-validator/index.js # Pass 1โ€“4 JSON + completion marker checks
395
- ```
396
-
397
- #### Step 9: Verify the results
398
-
399
- ```bash
400
- # Count generated files
401
- find .claude claudeos-core -type f | grep -v node_modules | grep -v '/generated/' | wc -l
402
-
403
- # Check CLAUDE.md
404
- head -30 CLAUDE.md
405
-
406
- # Check a standard file
407
- cat claudeos-core/standard/00.core/01.project-overview.md | head -20
408
-
409
- # Check rules
410
- ls .claude/rules/*/
411
- ```
412
-
413
- > **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.
414
-
415
- ### Start Using
416
-
417
- ```
418
- # In Claude Code โ€” just ask naturally:
419
- "Create a CRUD for the order domain"
420
- "Add user authentication API"
421
- "Refactor this code to match project patterns"
422
-
423
- # Claude Code automatically references your generated Standards, Rules, and Skills.
424
- ```
425
-
426
- ---
427
-
428
- ## How It Works โ€” 4-Pass Pipeline
429
-
430
- ```
431
- npx claudeos-core init
432
- โ”‚
433
- โ”œโ”€โ”€ [1] npm install โ† Dependencies (~10s)
434
- โ”œโ”€โ”€ [2] Directory structure โ† Create folders (~1s)
435
- โ”œโ”€โ”€ [3] plan-installer (Node.js) โ† Project scan (~5s)
436
- โ”‚ โ”œโ”€โ”€ Auto-detect stack (multi-stack aware)
437
- โ”‚ โ”œโ”€โ”€ Extract domain list (tagged: backend/frontend)
438
- โ”‚ โ”œโ”€โ”€ Split into domain groups (per type)
439
- โ”‚ โ”œโ”€โ”€ Build pass3-context.json (slim summary, v2.1.0)
440
- โ”‚ โ””โ”€โ”€ Select stack-specific prompts (per type)
441
- โ”‚
442
- โ”œโ”€โ”€ [4] Pass 1 ร— N (claude -p) โ† Deep code analysis (~2-8min)
443
- โ”‚ โ”œโ”€โ”€ โš™๏ธ Backend groups โ†’ backend-specific prompt
444
- โ”‚ โ””โ”€โ”€ ๐ŸŽจ Frontend groups โ†’ frontend-specific prompt
445
- โ”‚
446
- โ”œโ”€โ”€ [5] Pass 2 ร— 1 (claude -p) โ† Merge analysis (~1min)
447
- โ”‚ โ””โ”€โ”€ Consolidate ALL Pass 1 results into pass2-merged.json
448
- โ”‚
449
- โ”œโ”€โ”€ [6] Pass 3 (split mode, v2.1.0) โ† Generate everything
450
- โ”‚ โ”‚
451
- โ”‚ โ”œโ”€โ”€ 3a ร— 1 (claude -p) โ† Fact extraction (~5-10min)
452
- โ”‚ โ”‚ โ””โ”€โ”€ Read pass2-merged.json once โ†’ pass3a-facts.md
453
- โ”‚ โ”‚
454
- โ”‚ โ”œโ”€โ”€ 3b-core ร— 1 (claude -p) โ† CLAUDE.md + common standard/rules
455
- โ”‚ โ”œโ”€โ”€ 3b-1..N ร— N (claude -p) โ† Domain standards/rules (โ‰ค15 domains/batch)
456
- โ”‚ โ”‚
457
- โ”‚ โ”œโ”€โ”€ 3c-core ร— 1 (claude -p) โ† Guides + shared skills + MANIFEST.md
458
- โ”‚ โ”œโ”€โ”€ 3c-1..N ร— N (claude -p) โ† Domain sub-skills (โ‰ค15 domains/batch)
459
- โ”‚ โ”‚
460
- โ”‚ โ””โ”€โ”€ 3d-aux ร— 1 (claude -p) โ† database/ + mcp-guide/ stubs
461
- โ”‚
462
- โ”œโ”€โ”€ [7] Pass 4 ร— 1 (claude -p) โ† Memory scaffolding (~30s-5min)
463
- โ”‚ โ”œโ”€โ”€ Seed memory/ (decision-log, failure-patterns, โ€ฆ)
464
- โ”‚ โ”œโ”€โ”€ Generate 60.memory/ rules
465
- โ”‚ โ”œโ”€โ”€ Append "Memory (L4)" section to CLAUDE.md
466
- โ”‚ โ””โ”€โ”€ Gap-fill: ensure skills/00.shared/MANIFEST.md exists (v2.1.0)
467
- โ”‚
468
- โ””โ”€โ”€ [8] Verification โ† Auto-run health checker
469
- ```
470
-
471
- ### Why 4 Passes?
472
-
473
- **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.
474
-
475
- **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.
476
-
477
- **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.
478
-
479
- The Pass 3 prompt template also includes a **Phase 1 "Read Once, Extract Facts" block** with five rules that further constrain output volume:
480
-
481
- - **Rule A** โ€” Reference the fact table; don't re-read `pass2-merged.json`.
482
- - **Rule B** โ€” Idempotent file writing (skip if target exists with real content), making Pass 3 safely re-runnable after interruption.
483
- - **Rule C** โ€” Cross-file consistency enforced via the fact table as single source of truth.
484
- - **Rule D** โ€” Output conciseness: one line (`[WRITE]`/`[SKIP]`) between file writes, no restating the fact table, no echoing file content.
485
- - **Rule E** โ€” Batch idempotent check: one `Glob` at PHASE 2 start instead of per-target `Read` calls.
486
-
487
- 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.
488
-
489
- **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.
490
-
491
- ---
492
-
493
- ## Generated File Structure
494
-
495
- ```
496
- your-project/
497
- โ”‚
498
- โ”œโ”€โ”€ CLAUDE.md โ† Claude Code entry point (deterministic 8-section structure, v2.2.0)
499
- โ”‚
500
- โ”œโ”€โ”€ .claude/
501
- โ”‚ โ””โ”€โ”€ rules/ โ† Glob-triggered rules
502
- โ”‚ โ”œโ”€โ”€ 00.core/
503
- โ”‚ โ”œโ”€โ”€ 10.backend/
504
- โ”‚ โ”œโ”€โ”€ 20.frontend/
505
- โ”‚ โ”œโ”€โ”€ 30.security-db/
506
- โ”‚ โ”œโ”€โ”€ 40.infra/
507
- โ”‚ โ”œโ”€โ”€ 50.sync/ โ† Sync reminder rules
508
- โ”‚ โ””โ”€โ”€ 60.memory/ โ† L4 memory on-demand scope rules (v2.0.0)
509
- โ”‚
510
- โ”œโ”€โ”€ claudeos-core/ โ† Main output directory
511
- โ”‚ โ”œโ”€โ”€ generated/ โ† Analysis JSON + dynamic prompts + Pass markers (gitignore this)
512
- โ”‚ โ”‚ โ”œโ”€โ”€ project-analysis.json โ† Stack info (multi-stack aware)
513
- โ”‚ โ”‚ โ”œโ”€โ”€ domain-groups.json โ† Groups with type: backend/frontend
514
- โ”‚ โ”‚ โ”œโ”€โ”€ pass1-backend-prompt.md โ† Backend analysis prompt
515
- โ”‚ โ”‚ โ”œโ”€โ”€ pass1-frontend-prompt.md โ† Frontend analysis prompt (if detected)
516
- โ”‚ โ”‚ โ”œโ”€โ”€ pass2-prompt.md โ† Merge prompt
517
- โ”‚ โ”‚ โ”œโ”€โ”€ pass2-merged.json โ† Pass 2 output (consumed by Pass 3a only)
518
- โ”‚ โ”‚ โ”œโ”€โ”€ pass3-context.json โ† Slim summary (< 5 KB) for Pass 3 (v2.1.0)
519
- โ”‚ โ”‚ โ”œโ”€โ”€ pass3-prompt.md โ† Pass 3 prompt template (Phase 1 block prepended)
520
- โ”‚ โ”‚ โ”œโ”€โ”€ pass3a-facts.md โ† Fact sheet written by Pass 3a, read by 3b/3c/3d (v2.1.0)
521
- โ”‚ โ”‚ โ”œโ”€โ”€ pass4-prompt.md โ† Memory scaffolding prompt (v2.0.0)
522
- โ”‚ โ”‚ โ”œโ”€โ”€ pass3-complete.json โ† Pass 3 completion marker (split mode: includes groupsCompleted, v2.1.0)
523
- โ”‚ โ”‚ โ”œโ”€โ”€ pass4-memory.json โ† Pass 4 completion marker (skip on resume)
524
- โ”‚ โ”‚ โ”œโ”€โ”€ rule-manifest.json โ† File index for verification tools
525
- โ”‚ โ”‚ โ”œโ”€โ”€ sync-map.json โ† Plan โ†” disk mapping (empty in v2.1.0; kept for sync-checker compat)
526
- โ”‚ โ”‚ โ”œโ”€โ”€ stale-report.json โ† Consolidated verification results
527
- โ”‚ โ”‚ โ”œโ”€โ”€ .i18n-cache-<lang>.json โ† Translation cache (non-English `--lang`)
528
- โ”‚ โ”‚ โ””โ”€โ”€ .staged-rules/ โ† Transient staging dir for `.claude/rules/` writes (auto-moved + cleaned)
529
- โ”‚ โ”œโ”€โ”€ standard/ โ† Coding standards (15-19 files + per-domain in 60.domains/)
530
- โ”‚ โ”‚ โ”œโ”€โ”€ 00.core/ โ† Overview, architecture, naming
531
- โ”‚ โ”‚ โ”œโ”€โ”€ 10.backend-api/ โ† API patterns (stack-specific)
532
- โ”‚ โ”‚ โ”œโ”€โ”€ 20.frontend-ui/ โ† Frontend patterns (if detected)
533
- โ”‚ โ”‚ โ”œโ”€โ”€ 30.security-db/ โ† Security, DB schema, utilities
534
- โ”‚ โ”‚ โ”œโ”€โ”€ 40.infra/ โ† Config, logging, CI/CD
535
- โ”‚ โ”‚ โ”œโ”€โ”€ 50.verification/ โ† Build verification, testing
536
- โ”‚ โ”‚ โ”œโ”€โ”€ 60.domains/ โ† Per-domain standards (written by Pass 3b-N, v2.1.0)
537
- โ”‚ โ”‚ โ””โ”€โ”€ 90.optional/ โ† Optional conventions (stack-specific extras)
538
- โ”‚ โ”œโ”€โ”€ skills/ โ† CRUD/page scaffolding skills
539
- โ”‚ โ”‚ โ””โ”€โ”€ 00.shared/MANIFEST.md โ† Single source of truth for registered skills
540
- โ”‚ โ”œโ”€โ”€ guide/ โ† Onboarding, FAQ, troubleshooting (9 files)
541
- โ”‚ โ”œโ”€โ”€ database/ โ† DB schema, migration guide
542
- โ”‚ โ”œโ”€โ”€ mcp-guide/ โ† MCP server integration guide
543
- โ”‚ โ””โ”€โ”€ memory/ โ† L4: team knowledge (4 files) โ€” commit these
544
- โ”‚ โ”œโ”€โ”€ decision-log.md โ† "Why" behind design decisions
545
- โ”‚ โ”œโ”€โ”€ failure-patterns.md โ† Recurring errors & fixes (auto-scored โ€” `npx claudeos-core memory score`)
546
- โ”‚ โ”œโ”€โ”€ compaction.md โ† 4-stage compaction strategy (run `npx claudeos-core memory compact`)
547
- โ”‚ โ””โ”€โ”€ auto-rule-update.md โ† Rule improvement proposals (`npx claudeos-core memory propose-rules`)
548
- โ”‚
549
- โ””โ”€โ”€ claudeos-core-tools/ โ† This toolkit (don't modify)
550
- ```
551
-
552
- Every standard file includes โœ… correct examples, โŒ incorrect examples, and a rules summary table โ€” all derived from your actual code patterns, not generic templates.
553
-
554
- > **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.
555
-
556
- ### Gitignore recommendations
557
-
558
- **Do commit** (team knowledge โ€” meant to be shared):
559
- - `CLAUDE.md` โ€” Claude Code entry point
560
- - `.claude/rules/**` โ€” auto-loaded rules
561
- - `claudeos-core/standard/**`, `skills/**`, `guide/**`, `database/**`, `mcp-guide/**`, `plan/**` โ€” generated documentation
562
- - `claudeos-core/memory/**` โ€” decision history, failure patterns, rule proposals
563
-
564
- **Do NOT commit** (regeneratable build artifacts):
565
-
566
- ```gitignore
567
- # ClaudeOS-Core โ€” generated analysis & translation cache
568
- claudeos-core/generated/
569
- ```
570
-
571
- 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`.
572
-
573
- ---
574
-
575
- ## Auto-scaling by Project Size
576
-
577
- 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.
578
-
579
- | Project Size | Domains | Pass 3 Stages | Total `claude -p` | Est. Time |
580
- |---|---|---|---|---|
581
- | 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 |
582
- | Medium | 5โ€“15 | 4 | 8โ€“9 | ~25โ€“45 min |
583
- | Large | 16โ€“30 | **8** (3b, 3c each split into 2 batches) | 11โ€“12 | **~60โ€“105 min** |
584
- | X-Large | 31โ€“45 | 10 | 13โ€“14 | ~100โ€“150 min |
585
- | XX-Large | 46โ€“60 | 12 | 15โ€“16 | ~150โ€“200 min |
586
- | XXX-Large | 61+ | 14+ | 17+ | 200 min+ |
587
-
588
- 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)`.
589
-
590
- 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.
591
-
592
- ---
593
-
594
- ## Verification Tools
595
-
596
- ClaudeOS-Core includes 5 built-in verification tools that run automatically after generation:
597
-
598
- ```bash
599
- # Run all checks at once (recommended)
600
- npx claudeos-core health
601
-
602
- # Individual commands
603
- npx claudeos-core validate # Plan โ†” disk comparison
604
- npx claudeos-core refresh # Disk โ†’ Plan sync
605
- npx claudeos-core restore # Plan โ†’ Disk restore
606
-
607
- # Or use node directly (git clone users)
608
- node claudeos-core-tools/health-checker/index.js
609
- node claudeos-core-tools/manifest-generator/index.js
610
- node claudeos-core-tools/plan-validator/index.js --check
611
- node claudeos-core-tools/sync-checker/index.js
612
- ```
613
-
614
- | Tool | What It Does |
615
- |---|---|
616
- | **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. |
617
- | **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. |
618
- | **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). |
619
- | **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) |
620
- | **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 |
621
-
622
- ---
623
-
624
- ## How Claude Code Uses Your Documentation
625
-
626
- ClaudeOS-Core generates documentation that Claude Code actually reads โ€” here's how:
627
-
628
- ### What Claude Code reads automatically
629
-
630
- | File | When | Guaranteed |
631
- |---|---|---|
632
- | `CLAUDE.md` | Every conversation start | Always |
633
- | `.claude/rules/00.core/*` | When any file is edited (`paths: ["**/*"]`) | Always |
634
- | `.claude/rules/10.backend/*` | When any file is edited (`paths: ["**/*"]`) | Always |
635
- | `.claude/rules/20.frontend/*` | When any frontend file is edited (scoped to component/page/style paths) | Conditional |
636
- | `.claude/rules/30.security-db/*` | When any file is edited (`paths: ["**/*"]`) | Always |
637
- | `.claude/rules/40.infra/*` | Only when editing config/infra files (scoped paths) | Conditional |
638
- | `.claude/rules/50.sync/*` | Only when editing claudeos-core files (scoped paths) | Conditional |
639
- | `.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) |
640
-
641
- ### What Claude Code reads on-demand via rule references
642
-
643
- Each rule file links to its corresponding standard via a `## Reference` section. Claude reads only the relevant standard for the current task:
644
-
645
- - `claudeos-core/standard/**` โ€” coding patterns, โœ…/โŒ examples, naming conventions
646
- - `claudeos-core/database/**` โ€” DB schema (for queries, mappers, migrations)
647
- - `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.
648
-
649
- The `00.standard-reference.md` serves as a directory of all standard files for discovering standards that have no corresponding rule.
650
-
651
- ### What Claude Code does NOT read (saves context)
652
-
653
- These folders are explicitly excluded via the `DO NOT Read` section in the standard-reference rule:
654
-
655
- | Folder | Why excluded |
656
- |---|---|
657
- | `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. |
658
- | `claudeos-core/generated/` | Build metadata JSON, prompts, Pass markers, translation cache, `.staged-rules/`. Not for coding. |
659
- | `claudeos-core/guide/` | Onboarding guides for humans. |
660
- | `claudeos-core/mcp-guide/` | MCP server docs. Not for coding. |
661
- | `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. |
662
-
663
- ---
664
-
665
- ## Daily Workflow
666
-
667
- ### After Installation
668
-
669
- ```
670
- # Just use Claude Code as normal โ€” it references your standards automatically:
671
- "Create a CRUD for the order domain"
672
- "Add user profile update API"
673
- "Refactor this code to match project patterns"
674
- ```
675
-
676
- ### After Manually Editing Standards
677
-
678
- ```bash
679
- # After editing standards or rules files:
680
- npx claudeos-core refresh
681
-
682
- # Verify everything is consistent
683
- npx claudeos-core health
684
- ```
685
-
686
- ### When Docs Get Corrupted
687
-
688
- ```bash
689
- # v2.1.0 recommendation: use git to restore (since master plans are no
690
- # longer generated). Commit your generated docs regularly so you can roll
691
- # back specific files without regenerating:
692
- git checkout HEAD -- .claude/rules/ claudeos-core/
693
-
694
- # Legacy (v2.0.x projects with claudeos-core/plan/ still present):
695
- npx claudeos-core restore
696
- ```
697
-
698
- ### Memory Layer Maintenance (v2.0.0)
699
-
700
- The L4 Memory layer (`claudeos-core/memory/`) accumulates team knowledge across sessions. Three CLI subcommands keep it healthy:
701
-
702
- ```bash
703
- # Compact: enforce 4-stage compaction policy (run periodically โ€” e.g. monthly)
704
- npx claudeos-core memory compact
705
- # Stage 1: summarize aged entries (>30 days, body โ†’ one-line)
706
- # Stage 2: merge duplicate headings (frequency summed, latest fix kept)
707
- # Stage 3: drop low-importance + aged (importance <3 AND lastSeen >60 days)
708
- # Stage 4: enforce 400-line cap per file (oldest low-importance dropped first)
709
-
710
- # Score: re-rank failure-patterns.md entries by importance
711
- npx claudeos-core memory score
712
- # importance = round(frequency ร— 1.5 + recency ร— 5), capped at 10
713
- # Run after appending several new failure patterns
714
-
715
- # Propose-rules: surface candidate rule additions from recurring failures
716
- npx claudeos-core memory propose-rules
717
- # Reads failure-patterns.md entries with frequency โ‰ฅ 3
718
- # Computes confidence (sigmoid on weighted evidence ร— anchor multiplier)
719
- # Writes proposals to memory/auto-rule-update.md (NOT auto-applied)
720
- # Confidence โ‰ฅ 0.70 deserves serious review; accept โ†’ edit rule + log decision
721
-
722
- # v2.1.0: `memory --help` now routes to subcommand help (was showing top-level)
723
- npx claudeos-core memory --help
724
- ```
725
-
726
- > **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.
727
-
728
- When to write to memory (Claude does this on-demand, but you can edit manually too):
729
- - **`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.
730
- - **`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.
731
- - `compaction.md` and `auto-rule-update.md` โ€” generated/managed by the CLI subcommands above; don't edit by hand.
732
-
733
- ### CI/CD Integration
734
-
735
- ```yaml
736
- # GitHub Actions example
737
- - run: npx claudeos-core validate
738
- # Exit code 1 blocks the PR
739
-
740
- # Optional: monthly memory housekeeping (separate cron workflow)
741
- - run: npx claudeos-core memory compact
742
- - run: npx claudeos-core memory score
743
- ```
744
-
745
- ---
746
-
747
- ## How Is This Different?
748
-
749
- ### vs Other Claude Code Tools
750
-
751
- | | ClaudeOS-Core | Everything Claude Code (50K+ โญ) | Harness | specs-generator | Claude `/init` |
752
- |---|---|---|---|---|---|
753
- | **Approach** | Code analyzes first, then LLM generates | Pre-built config presets | LLM designs agent teams | LLM generates spec docs | LLM writes CLAUDE.md |
754
- | **Reads your source code** | โœ… Deterministic static analysis | โŒ | โŒ | โŒ (LLM reads) | โŒ (LLM reads) |
755
- | **Stack detection** | Code confirms (ORM, DB, build tool, pkg manager) | N/A (stack-agnostic) | LLM guesses | LLM guesses | LLM guesses |
756
- | **Domain detection** | Code confirms (Java 5 patterns, Kotlin CQRS, Next.js FSD) | N/A | LLM guesses | N/A | N/A |
757
- | **Same project โ†’ Same result** | โœ… Deterministic analysis | โœ… (static files) | โŒ (LLM varies) | โŒ (LLM varies) | โŒ (LLM varies) |
758
- | **Large project handling** | Domain group splitting (4 domains / 40 files per group) | N/A | No splitting | No splitting | Context window limit |
759
- | **Output** | CLAUDE.md + Rules + Standards + Skills + Guides + Plans (40-50+ files) | Agents + Skills + Commands + Hooks | Agents + Skills | 6 spec documents | CLAUDE.md (1 file) |
760
- | **Output location** | `.claude/rules/` (auto-loaded by Claude Code) | `.claude/` various | `.claude/agents/` + `.claude/skills/` | `.claude/steering/` + `specs/` | `CLAUDE.md` |
761
- | **Post-generation verification** | โœ… 5 automated validators | โŒ | โŒ | โŒ | โŒ |
762
- | **Multi-language output** | โœ… 10 languages | โŒ | โŒ | โŒ | โŒ |
763
- | **Multi-stack** | โœ… Backend + Frontend simultaneous | โŒ Stack-agnostic | โŒ | โŒ | Partial |
764
- | **Persistent memory layer** | โœ… L4 โ€” decision log + failure patterns + auto-scored rule proposals (v2.0.0) | โŒ | โŒ | โŒ | โŒ |
765
- | **Agent orchestration** | โŒ | โœ… 28 agents | โœ… 6 patterns | โŒ | โŒ |
766
-
767
- ### The key difference in one sentence
768
-
769
- **Other tools give Claude "generally good instructions." ClaudeOS-Core gives Claude "instructions extracted from your actual code."**
770
-
771
- That's why Claude Code stops generating JPA code in your MyBatis project,
772
- stops using `success()` when your codebase uses `ok()`,
773
- and stops creating `user/controller/` directories when your project uses `controller/user/`.
774
-
775
- ### Complementary, not competing
776
-
777
- ClaudeOS-Core focuses on **project-specific rules and standards**.
778
- Other tools focus on **agent orchestration and workflows**.
779
-
780
- 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.
781
-
782
- ---
783
-
784
- ## FAQ
785
-
786
- **Q: Does it modify my source code?**
787
- No. It only creates `CLAUDE.md`, `.claude/rules/`, and `claudeos-core/`. Your existing code is never modified.
788
-
789
- **Q: How much does it cost?**
790
- 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.
791
-
792
- **Q: What is Pass 3 split mode and why was it added in v2.1.0?**
793
- 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.
794
- **Q: Should I commit the generated files to Git?**
795
- Yes, recommended. Your team can share the same Claude Code standards. Consider adding `claudeos-core/generated/` to `.gitignore` (analysis JSON is regeneratable).
796
-
797
- **Q: What about mixed-stack projects (e.g., Java backend + React frontend)?**
798
- 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.
799
-
800
- **Q: Does it work with Turborepo / pnpm workspaces / Lerna monorepos?**
801
- 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.
802
-
803
- **Q: What happens on re-run?**
804
- 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.
805
-
806
- **Q: Does NestJS get its own template or use the Express one?**
807
- 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.
808
-
809
- **Q: What about Vue / Nuxt projects?**
810
- 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.
811
-
812
- **Q: Does it support Kotlin?**
813
- 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.).
814
-
815
- **Q: What about CQRS / BFF architecture?**
816
- 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.
817
-
818
- **Q: What about Gradle multi-module monorepos?**
819
- 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.
820
-
821
- **Q: What is the L4 Memory layer (v2.0.0)? Should I commit `claudeos-core/memory/`?**
822
- 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.
823
-
824
- **Q: What if Pass 4 fails?**
825
- 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.
826
-
827
- **Q: What do `memory compact` / `memory score` / `memory propose-rules` do?**
828
- 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).
829
-
830
- **Q: Why does `--force` (or "fresh" resume mode) delete `.claude/rules/`?**
831
- 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.)
832
-
833
- **Q: What is `claudeos-core/generated/.staged-rules/` and why does it exist?**
834
- 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.
835
-
836
- **Q: Can I run Pass 3 manually instead of `npx claudeos-core init`?**
837
- 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.
838
-
839
- **Q: My project is an upgrade from v2.0.x and has an existing `claudeos-core/plan/` directory. What do I do?**
840
- 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.
841
-
842
- ---
843
-
844
- ## Template Structure
845
-
846
- ```
847
- pass-prompts/templates/
848
- โ”œโ”€โ”€ common/ # Shared header/footer + pass4 + staging-override + CLAUDE.md scaffold (v2.2.0)
849
- โ”‚ โ”œโ”€โ”€ header.md # Role + output-format directive (all passes)
850
- โ”‚ โ”œโ”€โ”€ pass3-footer.md # Post-Pass-3 health-check instruction + 5 CRITICAL guardrail blocks (v2.2.0)
851
- โ”‚ โ”œโ”€โ”€ pass3-phase1.md # "Read Once, Extract Facts" block with Rules A-E (v2.1.0)
852
- โ”‚ โ”œโ”€โ”€ pass4.md # Memory scaffolding prompt (v2.0.0)
853
- โ”‚ โ”œโ”€โ”€ staging-override.md # Redirects .claude/rules/** writes to .staged-rules/** (v2.0.0)
854
- โ”‚ โ”œโ”€โ”€ claude-md-scaffold.md # Deterministic 8-section CLAUDE.md template (v2.2.0)
855
- โ”‚ โ””โ”€โ”€ lang-instructions.json # Per-language output directives (10 languages)
856
- โ”œโ”€โ”€ java-spring/ # Java / Spring Boot
857
- โ”œโ”€โ”€ kotlin-spring/ # Kotlin / Spring Boot (CQRS, BFF, multi-module)
858
- โ”œโ”€โ”€ node-express/ # Node.js / Express
859
- โ”œโ”€โ”€ node-nestjs/ # Node.js / NestJS (Module, DI, Guard, Pipe, Interceptor)
860
- โ”œโ”€โ”€ node-fastify/ # Node.js / Fastify
861
- โ”œโ”€โ”€ node-nextjs/ # Next.js / React (App Router, RSC)
862
- โ”œโ”€โ”€ node-vite/ # Vite SPA (React, client-side routing, VITE_ env, Vitest)
863
- โ”œโ”€โ”€ vue-nuxt/ # Vue / Nuxt (Composition API, Pinia, Nitro)
864
- โ”œโ”€โ”€ angular/ # Angular
865
- โ”œโ”€โ”€ python-django/ # Python / Django (DRF)
866
- โ”œโ”€โ”€ python-fastapi/ # Python / FastAPI
867
- โ””โ”€โ”€ python-flask/ # Python / Flask (Blueprint, app factory, Jinja2)
868
- ```
869
-
870
- `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.
871
-
872
- **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.
873
-
874
- ---
875
-
876
- ## Monorepo Support
877
-
878
- ClaudeOS-Core automatically detects JS/TS monorepo setups and scans sub-packages for dependencies.
879
-
880
- **Supported monorepo markers** (auto-detected):
881
- - `turbo.json` (Turborepo)
882
- - `pnpm-workspace.yaml` (pnpm workspaces)
883
- - `lerna.json` (Lerna)
884
- - `package.json#workspaces` (npm/yarn workspaces)
885
-
886
- **Run from the monorepo root** โ€” ClaudeOS-Core reads `apps/*/package.json` and `packages/*/package.json` to discover framework/ORM/DB dependencies across sub-packages:
887
-
888
- ```bash
889
- cd my-monorepo
890
- npx claudeos-core init
891
- ```
892
-
893
- **What gets detected:**
894
- - Dependencies from `apps/web/package.json` (e.g., `next`, `react`) โ†’ frontend stack
895
- - Dependencies from `apps/api/package.json` (e.g., `express`, `prisma`) โ†’ backend stack
896
- - Dependencies from `packages/db/package.json` (e.g., `drizzle-orm`) โ†’ ORM/DB
897
- - Custom workspace paths from `pnpm-workspace.yaml` (e.g., `services/*`)
898
-
899
- **Domain scanning also covers monorepo layouts:**
900
- - `apps/api/src/modules/*/` and `apps/api/src/*/` for backend domains
901
- - `apps/web/app/*/`, `apps/web/src/app/*/`, `apps/web/pages/*/` for frontend domains
902
- - `packages/*/src/*/` for shared package domains
903
-
904
- ```
905
- my-monorepo/ โ† Run here: npx claudeos-core init
906
- โ”œโ”€โ”€ turbo.json โ† Auto-detected as Turborepo
907
- โ”œโ”€โ”€ apps/
908
- โ”‚ โ”œโ”€โ”€ web/ โ† Next.js detected from apps/web/package.json
909
- โ”‚ โ”‚ โ”œโ”€โ”€ app/dashboard/ โ† Frontend domain detected
910
- โ”‚ โ”‚ โ””โ”€โ”€ package.json โ† { "dependencies": { "next": "^14" } }
911
- โ”‚ โ””โ”€โ”€ api/ โ† Express detected from apps/api/package.json
912
- โ”‚ โ”œโ”€โ”€ src/modules/users/ โ† Backend domain detected
913
- โ”‚ โ””โ”€โ”€ package.json โ† { "dependencies": { "express": "^4" } }
914
- โ”œโ”€โ”€ packages/
915
- โ”‚ โ”œโ”€โ”€ db/ โ† Drizzle detected from packages/db/package.json
916
- โ”‚ โ””โ”€โ”€ ui/
917
- โ””โ”€โ”€ package.json โ† { "workspaces": ["apps/*", "packages/*"] }
918
- ```
919
-
920
- > **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.
921
-
922
- ## Troubleshooting
923
-
924
- **"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).
925
-
926
- **"npm install failed"** โ€” Node.js version may be too low. Requires v18+.
927
-
928
- **"0 domains detected"** โ€” Your project structure may be non-standard. See the detection patterns above for your stack.
929
-
930
- **"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/`.
931
-
932
- **"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`.
933
-
934
- **"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.
935
-
936
- **"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.
937
-
938
- **"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`.
939
-
940
- **"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.
941
-
942
- **"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.
943
-
944
- **"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`.
945
-
946
- **"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.
947
-
948
- **"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`.
949
-
950
- **"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.
951
-
952
- **"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.
953
-
954
- **"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.
955
-
956
- **"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`.
957
-
958
- **"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`.
959
-
960
- **"โš ๏ธ 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.
961
-
962
- **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.
963
-
964
- **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.
965
-
966
- ---
967
-
968
- ## Contributing
969
-
970
- Contributions are welcome! Areas where help is most needed:
971
-
972
- - **New stack templates** โ€” Ruby/Rails, Go (Gin/Fiber/Echo), PHP (Laravel/Symfony), Rust (Axum/Actix), Svelte/SvelteKit, Remix
973
- - **IDE integration** โ€” VS Code extension, IntelliJ plugin
974
- - **CI/CD templates** โ€” GitLab CI, CircleCI, Jenkins examples (GitHub Actions already shipped โ€” see `.github/workflows/test.yml`)
975
- - **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))
976
-
977
- 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.
978
-
979
- ---
980
-
981
- ## Author
982
-
983
- Created by **claudeos-core** โ€” [GitHub](https://github.com/claudeos-core) ยท [Email](mailto:claudeoscore@gmail.com)
984
-
985
- ## License
986
-
987
- 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
+ ---
99
+
100
+ ## Supported Stacks
101
+
102
+ | Stack | Detection | Analysis Depth |
103
+ |---|---|---|
104
+ | **Java / Spring Boot** | `build.gradle`, `pom.xml`, 5 package patterns | 10 categories, 59 sub-items |
105
+ | **Kotlin / Spring Boot** | `build.gradle.kts`, kotlin plugin, `settings.gradle.kts`, CQRS/BFF auto-detect | 12 categories, 95 sub-items |
106
+ | **Node.js / Express** | `package.json` | 9 categories, 57 sub-items |
107
+ | **Node.js / NestJS** | `package.json` (`@nestjs/core`) | 10 categories, 68 sub-items |
108
+ | **Next.js / React** | `package.json`, `next.config.*`, FSD support | 9 categories, 55 sub-items |
109
+ | **Vue / Nuxt** | `package.json`, `nuxt.config.*`, Composition API | 9 categories, 58 sub-items |
110
+ | **Python / Django** | `requirements.txt`, `pyproject.toml` | 10 categories, 55 sub-items |
111
+ | **Python / FastAPI** | `requirements.txt`, `pyproject.toml` | 10 categories, 58 sub-items |
112
+ | **Node.js / Fastify** | `package.json` | 10 categories, 62 sub-items |
113
+ | **Vite / React SPA** | `package.json`, `vite.config.*` | 9 categories, 55 sub-items |
114
+ | **Angular** | `package.json`, `angular.json` | 12 categories, 78 sub-items |
115
+
116
+ 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).
117
+
118
+ **You don't specify anything. It's all detected automatically.**
119
+
120
+ ### `.env`-driven runtime configuration (v2.2.0)
121
+
122
+ v2.2.0 adds `lib/env-parser.js` so generated `CLAUDE.md` reflects what the project actually declares rather than framework defaults.
123
+
124
+ - **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.
125
+ - **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.
126
+ - **Host & API target**: `VITE_DEV_HOST` / `VITE_API_TARGET` / `NEXT_PUBLIC_API_URL` / `NUXT_PUBLIC_API_BASE` / `BACKEND_URL` / `PROXY_TARGET` etc.
127
+ - **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.
128
+ - **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.
129
+
130
+ ### Java Domain Detection (5 patterns with fallback)
131
+
132
+ | Priority | Pattern | Structure | Example |
133
+ |---|---|---|---|
134
+ | A | Layer-first | `controller/{domain}/` | `controller/user/UserController.java` |
135
+ | B | Domain-first | `{domain}/controller/` | `user/controller/UserController.java` |
136
+ | D | Module prefix | `{module}/{domain}/controller/` | `front/member/controller/MemberController.java` |
137
+ | E | DDD/Hexagonal | `{domain}/adapter/in/web/` | `user/adapter/in/web/UserController.java` |
138
+ | C | Flat | `controller/*.java` | `controller/UserController.java` โ†’ extracts `user` from class name |
139
+
140
+ 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.
141
+
142
+ ### Kotlin Multi-Module Domain Detection
143
+
144
+ For Kotlin projects with Gradle multi-module structure (e.g., CQRS monorepo):
145
+
146
+ | Step | What It Does | Example |
147
+ |---|---|---|
148
+ | 1 | Scan `settings.gradle.kts` for `include()` | Finds 14 modules |
149
+ | 2 | Detect module type from name | `reservation-command-server` โ†’ type: `command` |
150
+ | 3 | Extract domain from module name | `reservation-command-server` โ†’ domain: `reservation` |
151
+ | 4 | Group same domain across modules | `reservation-command-server` + `common-query-server` โ†’ 1 domain |
152
+ | 5 | Detect architecture | Has `command` + `query` modules โ†’ CQRS |
153
+
154
+ Supported module types: `command`, `query`, `bff`, `integration`, `standalone`, `library`. Shared libraries (`shared-lib`, `integration-lib`) are detected as special domains.
155
+
156
+ ### Frontend Domain Detection
157
+
158
+ - **App Router**: `app/{domain}/page.tsx` (Next.js)
159
+ - **Pages Router**: `pages/{domain}/index.tsx`
160
+ - **FSD (Feature-Sliced Design)**: `features/*/`, `widgets/*/`, `entities/*/`
161
+ - **RSC/Client split**: Detects `client.tsx` pattern, tracks Server/Client component separation
162
+ - **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/`)
163
+ - **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.
164
+ - **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).
165
+ - **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.
166
+ - **Config fallback**: Detects Next.js/Vite/Nuxt from config files when not in `package.json` (monorepo support)
167
+ - **Deep directory fallback**: For React/CRA/Vite/Vue/RN projects, scans `**/components/*/`, `**/views/*/`, `**/screens/*/`, `**/containers/*/`, `**/pages/*/`, `**/routes/*/`, `**/modules/*/`, `**/domains/*/` at any depth
168
+ - **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.
169
+
170
+ ### Scanner Overrides (v2.0.0)
171
+
172
+ 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:
173
+
174
+ ```json
175
+ {
176
+ "frontendScan": {
177
+ "platformKeywords": ["kiosk"],
178
+ "skipSubappNames": ["legacy"],
179
+ "minSubappFiles": 3
180
+ }
181
+ }
182
+ ```
183
+
184
+ | Field | Default | Purpose |
185
+ |---|---|---|
186
+ | `platformKeywords` | built-in list above | Additional `{platform}` keywords for the platform scan (e.g., `kiosk`, `vr`, `embedded`) |
187
+ | `skipSubappNames` | structural dirs only | Additional subapp names to exclude from platform-scan domain emission |
188
+ | `minSubappFiles` | `2` | Override the minimum file count required before a subapp becomes a domain |
189
+
190
+ 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.
191
+
192
+ ---
193
+
194
+ ## Quick Start
195
+
196
+ ### Prerequisites
197
+
198
+ - **Node.js** v18+
199
+ - **Claude Code CLI** (installed & authenticated)
200
+
201
+ ### Installation
202
+
203
+ ```bash
204
+ cd /your/project/root
205
+
206
+ # Option A: npx (recommended โ€” no install needed)
207
+ npx claudeos-core init
208
+
209
+ # Option B: global install
210
+ npm install -g claudeos-core
211
+ claudeos-core init
212
+
213
+ # Option C: project devDependency
214
+ npm install --save-dev claudeos-core
215
+ npx claudeos-core init
216
+
217
+ # Option D: git clone (for development/contribution)
218
+ git clone https://github.com/claudeos-core/claudeos-core.git claudeos-core-tools
219
+
220
+ # Cross-platform (PowerShell, CMD, Bash, Zsh โ€” any terminal)
221
+ node claudeos-core-tools/bin/cli.js init
222
+
223
+ # Linux/macOS (Bash only)
224
+ bash claudeos-core-tools/bootstrap.sh
225
+ ```
226
+
227
+ ### Output Language (10 languages)
228
+
229
+ When you run `init` without `--lang`, an interactive selector appears โ€” use arrow keys or number keys to choose:
230
+
231
+ ```
232
+ โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
233
+ โ•‘ Select generated document language (required) โ•‘
234
+ โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
235
+
236
+ Generated files (CLAUDE.md, Standards, Rules,
237
+ Skills, Guides) will be written in English.
238
+
239
+ โฏ 1. en โ€” English
240
+ 2. ko โ€” ํ•œ๊ตญ์–ด (Korean)
241
+ 3. zh-CN โ€” ็ฎ€ไฝ“ไธญๆ–‡ (Chinese Simplified)
242
+ 4. ja โ€” ๆ—ฅๆœฌ่ชž (Japanese)
243
+ 5. es โ€” Espaรฑol (Spanish)
244
+ 6. vi โ€” Tiแบฟng Viแป‡t (Vietnamese)
245
+ 7. hi โ€” เคนเคฟเคจเฅเคฆเฅ€ (Hindi)
246
+ 8. ru โ€” ะ ัƒััะบะธะน (Russian)
247
+ 9. fr โ€” Franรงais (French)
248
+ 10. de โ€” Deutsch (German)
249
+
250
+ โ†‘โ†“ Move 1-0 Jump Enter Select ESC Cancel
251
+ ```
252
+
253
+ The description changes to the selected language as you navigate. To skip the selector, pass `--lang` directly:
254
+
255
+ ```bash
256
+ npx claudeos-core init --lang ko # Korean
257
+ npx claudeos-core init --lang ja # Japanese
258
+ npx claudeos-core init --lang en # English (default)
259
+ ```
260
+
261
+ > **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.
262
+
263
+ 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.
264
+
265
+ ### Manual Step-by-Step Installation
266
+
267
+ 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.
268
+
269
+ #### Step 1: Clone and install dependencies
270
+
271
+ ```bash
272
+ cd /your/project/root
273
+
274
+ git clone https://github.com/claudeos-core/claudeos-core.git claudeos-core-tools
275
+ cd claudeos-core-tools && npm install && cd ..
276
+ ```
277
+
278
+ #### Step 2: Create directory structure
279
+
280
+ ```bash
281
+ # Rules (v2.0.0: added 60.memory)
282
+ mkdir -p .claude/rules/{00.core,10.backend,20.frontend,30.security-db,40.infra,50.sync,60.memory}
283
+
284
+ # Standards
285
+ mkdir -p claudeos-core/standard/{00.core,10.backend-api,20.frontend-ui,30.security-db,40.infra,50.verification,90.optional}
286
+
287
+ # Skills
288
+ mkdir -p claudeos-core/skills/{00.shared,10.backend-crud/scaffold-crud-feature,20.frontend-page/scaffold-page-feature,50.testing,90.experimental}
289
+
290
+ # Guide, Database, MCP, Generated, Memory (v2.0.0: added memory; v2.1.0: removed plan)
291
+ mkdir -p claudeos-core/guide/{01.onboarding,02.usage,03.troubleshooting,04.architecture}
292
+ mkdir -p claudeos-core/{database,mcp-guide,generated,memory}
293
+ ```
294
+
295
+ > **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.
296
+
297
+ #### Step 3: Run plan-installer (project analysis)
298
+
299
+ This scans your project, detects the stack, finds domains, splits them into groups, and generates prompts.
300
+
301
+ ```bash
302
+ node claudeos-core-tools/plan-installer/index.js
303
+ ```
304
+
305
+ **Output (in `claudeos-core/generated/`):**
306
+ - `project-analysis.json` โ€” detected stack, domains, frontend info
307
+ - `domain-groups.json` โ€” domain groups for Pass 1
308
+ - `pass1-backend-prompt.md` / `pass1-frontend-prompt.md` โ€” analysis prompts
309
+ - `pass2-prompt.md` โ€” merge prompt
310
+ - `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.
311
+ - `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)
312
+ - `pass4-prompt.md` โ€” L4 memory scaffolding prompt (v2.0.0; uses the same `staging-override.md` for `60.memory/` rule writes)
313
+
314
+ You can inspect these files to verify detection accuracy before proceeding.
315
+
316
+ #### Step 4: Pass 1 โ€” Deep code analysis (per domain group)
317
+
318
+ Run Pass 1 for each domain group. Check `domain-groups.json` for the number of groups.
319
+
320
+ ```bash
321
+ # Check how many groups
322
+ cat claudeos-core/generated/domain-groups.json | node -e "
323
+ const g = JSON.parse(require('fs').readFileSync('/dev/stdin','utf-8'));
324
+ g.groups.forEach((g,i) => console.log('Group '+(i+1)+': ['+g.domains.join(', ')+'] ('+g.type+', ~'+g.estimatedFiles+' files)'));
325
+ "
326
+
327
+ # Run Pass 1 for each group (replace domains and group number)
328
+ # Note: v1.6.1+ uses Node.js String.replace() instead of perl โ€” perl is no
329
+ # longer required, and replacement-function semantics prevent regex injection
330
+ # from $/&/$1 characters that may appear in domain names.
331
+ #
332
+ # For group 1:
333
+ DOMAIN_LIST="user, order, product" PASS_NUM=1 node -e "
334
+ const fs = require('fs');
335
+ const tpl = fs.readFileSync('claudeos-core/generated/pass1-backend-prompt.md','utf-8');
336
+ const out = tpl
337
+ .replace(/\{\{DOMAIN_GROUP\}\}/g, () => process.env.DOMAIN_LIST)
338
+ .replace(/\{\{PASS_NUM\}\}/g, () => process.env.PASS_NUM);
339
+ process.stdout.write(out);
340
+ " | claude -p --dangerously-skip-permissions
341
+
342
+ # For group 2 (if exists):
343
+ DOMAIN_LIST="payment, system, delivery" PASS_NUM=2 node -e "
344
+ const fs = require('fs');
345
+ const tpl = fs.readFileSync('claudeos-core/generated/pass1-backend-prompt.md','utf-8');
346
+ const out = tpl
347
+ .replace(/\{\{DOMAIN_GROUP\}\}/g, () => process.env.DOMAIN_LIST)
348
+ .replace(/\{\{PASS_NUM\}\}/g, () => process.env.PASS_NUM);
349
+ process.stdout.write(out);
350
+ " | claude -p --dangerously-skip-permissions
351
+
352
+ # For frontend groups, swap pass1-backend-prompt.md โ†’ pass1-frontend-prompt.md
353
+ ```
354
+
355
+ **Verify:** `ls claudeos-core/generated/pass1-*.json` should show one JSON per group.
356
+
357
+ #### Step 5: Pass 2 โ€” Merge analysis results
358
+
359
+ ```bash
360
+ cat claudeos-core/generated/pass2-prompt.md \
361
+ | claude -p --dangerously-skip-permissions
362
+ ```
363
+
364
+ **Verify:** `claudeos-core/generated/pass2-merged.json` should exist with 9+ top-level keys.
365
+
366
+ #### Step 6: Pass 3 โ€” Generate all documentation (split into multiple stages)
367
+
368
+ **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.
369
+
370
+ **Single-call mode (small projects only, โ‰ค5 domains):**
371
+
372
+ ```bash
373
+ cat claudeos-core/generated/pass3-prompt.md \
374
+ | claude -p --dangerously-skip-permissions
375
+ ```
376
+
377
+ **Stage-by-stage mode (recommended for all project sizes):**
378
+
379
+ The automated pipeline runs these stages. The stage list is:
380
+
381
+ | Stage | Writes | Notes |
382
+ |---|---|---|
383
+ | `3a` | `pass3a-facts.md` (5โ€“10 KB distilled fact sheet) | Reads `pass2-merged.json` once; later stages reference this file |
384
+ | `3b-core` | `CLAUDE.md`, common `standard/`, common `.claude/rules/` | Cross-project files; no domain-specific output |
385
+ | `3b-1..N` | Domain-specific `standard/60.domains/*.md` + domain rules | Batch of โ‰ค15 domains per stage (auto-divided at โ‰ฅ16 domains) |
386
+ | `3c-core` | `guide/` (9 files), `skills/00.shared/MANIFEST.md`, `skills/*/` orchestrators | Shared skills and all user-facing guides |
387
+ | `3c-1..N` | Domain sub-skills under `skills/20.frontend-page/scaffold-page-feature/` | Batch of โ‰ค15 domains per stage |
388
+ | `3d-aux` | `database/`, `mcp-guide/` | Fixed-size, independent of domain count |
389
+
390
+ 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.
391
+
392
+ **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).
393
+
394
+ > **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).
395
+
396
+ #### Step 7: Pass 4 โ€” Memory scaffolding
397
+
398
+ ```bash
399
+ cat claudeos-core/generated/pass4-prompt.md \
400
+ | claude -p --dangerously-skip-permissions
401
+ ```
402
+
403
+ **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`.
404
+
405
+ > **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).
406
+
407
+ > **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.
408
+
409
+ #### Step 8: Run verification tools
410
+
411
+ ```bash
412
+ # Generate metadata (required before other checks)
413
+ node claudeos-core-tools/manifest-generator/index.js
414
+
415
+ # Run all checks
416
+ node claudeos-core-tools/health-checker/index.js
417
+
418
+ # Or run individual checks:
419
+ node claudeos-core-tools/plan-validator/index.js --check # Plan โ†” disk consistency
420
+ node claudeos-core-tools/sync-checker/index.js # Unregistered/orphaned files
421
+ node claudeos-core-tools/content-validator/index.js # File quality checks (incl. memory/ section [9/9])
422
+ node claudeos-core-tools/pass-json-validator/index.js # Pass 1โ€“4 JSON + completion marker checks
423
+ ```
424
+
425
+ #### Step 9: Verify the results
426
+
427
+ ```bash
428
+ # Count generated files
429
+ find .claude claudeos-core -type f | grep -v node_modules | grep -v '/generated/' | wc -l
430
+
431
+ # Check CLAUDE.md
432
+ head -30 CLAUDE.md
433
+
434
+ # Check a standard file
435
+ cat claudeos-core/standard/00.core/01.project-overview.md | head -20
436
+
437
+ # Check rules
438
+ ls .claude/rules/*/
439
+ ```
440
+
441
+ > **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.
442
+
443
+ ### Start Using
444
+
445
+ ```
446
+ # In Claude Code โ€” just ask naturally:
447
+ "Create a CRUD for the order domain"
448
+ "Add user authentication API"
449
+ "Refactor this code to match project patterns"
450
+
451
+ # Claude Code automatically references your generated Standards, Rules, and Skills.
452
+ ```
453
+
454
+ ---
455
+
456
+ ## How It Works โ€” 4-Pass Pipeline
457
+
458
+ ```
459
+ npx claudeos-core init
460
+ โ”‚
461
+ โ”œโ”€โ”€ [1] npm install โ† Dependencies (~10s)
462
+ โ”œโ”€โ”€ [2] Directory structure โ† Create folders (~1s)
463
+ โ”œโ”€โ”€ [3] plan-installer (Node.js) โ† Project scan (~5s)
464
+ โ”‚ โ”œโ”€โ”€ Auto-detect stack (multi-stack aware)
465
+ โ”‚ โ”œโ”€โ”€ Extract domain list (tagged: backend/frontend)
466
+ โ”‚ โ”œโ”€โ”€ Split into domain groups (per type)
467
+ โ”‚ โ”œโ”€โ”€ Build pass3-context.json (slim summary, v2.1.0)
468
+ โ”‚ โ””โ”€โ”€ Select stack-specific prompts (per type)
469
+ โ”‚
470
+ โ”œโ”€โ”€ [4] Pass 1 ร— N (claude -p) โ† Deep code analysis (~2-8min)
471
+ โ”‚ โ”œโ”€โ”€ โš™๏ธ Backend groups โ†’ backend-specific prompt
472
+ โ”‚ โ””โ”€โ”€ ๐ŸŽจ Frontend groups โ†’ frontend-specific prompt
473
+ โ”‚
474
+ โ”œโ”€โ”€ [5] Pass 2 ร— 1 (claude -p) โ† Merge analysis (~1min)
475
+ โ”‚ โ””โ”€โ”€ Consolidate ALL Pass 1 results into pass2-merged.json
476
+ โ”‚
477
+ โ”œโ”€โ”€ [6] Pass 3 (split mode, v2.1.0) โ† Generate everything
478
+ โ”‚ โ”‚
479
+ โ”‚ โ”œโ”€โ”€ 3a ร— 1 (claude -p) โ† Fact extraction (~5-10min)
480
+ โ”‚ โ”‚ โ””โ”€โ”€ Read pass2-merged.json once โ†’ pass3a-facts.md
481
+ โ”‚ โ”‚
482
+ โ”‚ โ”œโ”€โ”€ 3b-core ร— 1 (claude -p) โ† CLAUDE.md + common standard/rules
483
+ โ”‚ โ”œโ”€โ”€ 3b-1..N ร— N (claude -p) โ† Domain standards/rules (โ‰ค15 domains/batch)
484
+ โ”‚ โ”‚
485
+ โ”‚ โ”œโ”€โ”€ 3c-core ร— 1 (claude -p) โ† Guides + shared skills + MANIFEST.md
486
+ โ”‚ โ”œโ”€โ”€ 3c-1..N ร— N (claude -p) โ† Domain sub-skills (โ‰ค15 domains/batch)
487
+ โ”‚ โ”‚
488
+ โ”‚ โ””โ”€โ”€ 3d-aux ร— 1 (claude -p) โ† database/ + mcp-guide/ stubs
489
+ โ”‚
490
+ โ”œโ”€โ”€ [7] Pass 4 ร— 1 (claude -p) โ† Memory scaffolding (~30s-5min)
491
+ โ”‚ โ”œโ”€โ”€ Seed memory/ (decision-log, failure-patterns, โ€ฆ)
492
+ โ”‚ โ”œโ”€โ”€ Generate 60.memory/ rules
493
+ โ”‚ โ”œโ”€โ”€ Append "Memory (L4)" section to CLAUDE.md
494
+ โ”‚ โ””โ”€โ”€ Gap-fill: ensure skills/00.shared/MANIFEST.md exists (v2.1.0)
495
+ โ”‚
496
+ โ””โ”€โ”€ [8] Verification โ† Auto-run health checker
497
+ ```
498
+
499
+ ### Why 4 Passes?
500
+
501
+ **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.
502
+
503
+ **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.
504
+
505
+ **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.
506
+
507
+ The Pass 3 prompt template also includes a **Phase 1 "Read Once, Extract Facts" block** with five rules that further constrain output volume:
508
+
509
+ - **Rule A** โ€” Reference the fact table; don't re-read `pass2-merged.json`.
510
+ - **Rule B** โ€” Idempotent file writing (skip if target exists with real content), making Pass 3 safely re-runnable after interruption.
511
+ - **Rule C** โ€” Cross-file consistency enforced via the fact table as single source of truth.
512
+ - **Rule D** โ€” Output conciseness: one line (`[WRITE]`/`[SKIP]`) between file writes, no restating the fact table, no echoing file content.
513
+ - **Rule E** โ€” Batch idempotent check: one `Glob` at PHASE 2 start instead of per-target `Read` calls.
514
+
515
+ 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.
516
+
517
+ **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.
518
+
519
+ ---
520
+
521
+ ## Generated File Structure
522
+
523
+ ```
524
+ your-project/
525
+ โ”‚
526
+ โ”œโ”€โ”€ CLAUDE.md โ† Claude Code entry point (deterministic 8-section structure, v2.2.0)
527
+ โ”‚
528
+ โ”œโ”€โ”€ .claude/
529
+ โ”‚ โ””โ”€โ”€ rules/ โ† Glob-triggered rules
530
+ โ”‚ โ”œโ”€โ”€ 00.core/
531
+ โ”‚ โ”œโ”€โ”€ 10.backend/
532
+ โ”‚ โ”œโ”€โ”€ 20.frontend/
533
+ โ”‚ โ”œโ”€โ”€ 30.security-db/
534
+ โ”‚ โ”œโ”€โ”€ 40.infra/
535
+ โ”‚ โ”œโ”€โ”€ 50.sync/ โ† Sync reminder rules
536
+ โ”‚ โ””โ”€โ”€ 60.memory/ โ† L4 memory on-demand scope rules (v2.0.0)
537
+ โ”‚
538
+ โ”œโ”€โ”€ claudeos-core/ โ† Main output directory
539
+ โ”‚ โ”œโ”€โ”€ generated/ โ† Analysis JSON + dynamic prompts + Pass markers (gitignore this)
540
+ โ”‚ โ”‚ โ”œโ”€โ”€ project-analysis.json โ† Stack info (multi-stack aware)
541
+ โ”‚ โ”‚ โ”œโ”€โ”€ domain-groups.json โ† Groups with type: backend/frontend
542
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass1-backend-prompt.md โ† Backend analysis prompt
543
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass1-frontend-prompt.md โ† Frontend analysis prompt (if detected)
544
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass2-prompt.md โ† Merge prompt
545
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass2-merged.json โ† Pass 2 output (consumed by Pass 3a only)
546
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass3-context.json โ† Slim summary (< 5 KB) for Pass 3 (v2.1.0)
547
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass3-prompt.md โ† Pass 3 prompt template (Phase 1 block prepended)
548
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass3a-facts.md โ† Fact sheet written by Pass 3a, read by 3b/3c/3d (v2.1.0)
549
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass4-prompt.md โ† Memory scaffolding prompt (v2.0.0)
550
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass3-complete.json โ† Pass 3 completion marker (split mode: includes groupsCompleted, v2.1.0)
551
+ โ”‚ โ”‚ โ”œโ”€โ”€ pass4-memory.json โ† Pass 4 completion marker (skip on resume)
552
+ โ”‚ โ”‚ โ”œโ”€โ”€ rule-manifest.json โ† File index for verification tools
553
+ โ”‚ โ”‚ โ”œโ”€โ”€ sync-map.json โ† Plan โ†” disk mapping (empty in v2.1.0; kept for sync-checker compat)
554
+ โ”‚ โ”‚ โ”œโ”€โ”€ stale-report.json โ† Consolidated verification results
555
+ โ”‚ โ”‚ โ”œโ”€โ”€ .i18n-cache-<lang>.json โ† Translation cache (non-English `--lang`)
556
+ โ”‚ โ”‚ โ””โ”€โ”€ .staged-rules/ โ† Transient staging dir for `.claude/rules/` writes (auto-moved + cleaned)
557
+ โ”‚ โ”œโ”€โ”€ standard/ โ† Coding standards (15-19 files + per-domain in 60.domains/)
558
+ โ”‚ โ”‚ โ”œโ”€โ”€ 00.core/ โ† Overview, architecture, naming
559
+ โ”‚ โ”‚ โ”œโ”€โ”€ 10.backend-api/ โ† API patterns (stack-specific)
560
+ โ”‚ โ”‚ โ”œโ”€โ”€ 20.frontend-ui/ โ† Frontend patterns (if detected)
561
+ โ”‚ โ”‚ โ”œโ”€โ”€ 30.security-db/ โ† Security, DB schema, utilities
562
+ โ”‚ โ”‚ โ”œโ”€โ”€ 40.infra/ โ† Config, logging, CI/CD
563
+ โ”‚ โ”‚ โ”œโ”€โ”€ 50.verification/ โ† Build verification, testing
564
+ โ”‚ โ”‚ โ”œโ”€โ”€ 60.domains/ โ† Per-domain standards (written by Pass 3b-N, v2.1.0)
565
+ โ”‚ โ”‚ โ””โ”€โ”€ 90.optional/ โ† Optional conventions (stack-specific extras)
566
+ โ”‚ โ”œโ”€โ”€ skills/ โ† CRUD/page scaffolding skills
567
+ โ”‚ โ”‚ โ””โ”€โ”€ 00.shared/MANIFEST.md โ† Single source of truth for registered skills
568
+ โ”‚ โ”œโ”€โ”€ guide/ โ† Onboarding, FAQ, troubleshooting (9 files)
569
+ โ”‚ โ”œโ”€โ”€ database/ โ† DB schema, migration guide
570
+ โ”‚ โ”œโ”€โ”€ mcp-guide/ โ† MCP server integration guide
571
+ โ”‚ โ””โ”€โ”€ memory/ โ† L4: team knowledge (4 files) โ€” commit these
572
+ โ”‚ โ”œโ”€โ”€ decision-log.md โ† "Why" behind design decisions
573
+ โ”‚ โ”œโ”€โ”€ failure-patterns.md โ† Recurring errors & fixes (auto-scored โ€” `npx claudeos-core memory score`)
574
+ โ”‚ โ”œโ”€โ”€ compaction.md โ† 4-stage compaction strategy (run `npx claudeos-core memory compact`)
575
+ โ”‚ โ””โ”€โ”€ auto-rule-update.md โ† Rule improvement proposals (`npx claudeos-core memory propose-rules`)
576
+ โ”‚
577
+ โ””โ”€โ”€ claudeos-core-tools/ โ† This toolkit (don't modify)
578
+ ```
579
+
580
+ Every standard file includes โœ… correct examples, โŒ incorrect examples, and a rules summary table โ€” all derived from your actual code patterns, not generic templates.
581
+
582
+ > **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.
583
+
584
+ ### Gitignore recommendations
585
+
586
+ **Do commit** (team knowledge โ€” meant to be shared):
587
+ - `CLAUDE.md` โ€” Claude Code entry point
588
+ - `.claude/rules/**` โ€” auto-loaded rules
589
+ - `claudeos-core/standard/**`, `skills/**`, `guide/**`, `database/**`, `mcp-guide/**`, `plan/**` โ€” generated documentation
590
+ - `claudeos-core/memory/**` โ€” decision history, failure patterns, rule proposals
591
+
592
+ **Do NOT commit** (regeneratable build artifacts):
593
+
594
+ ```gitignore
595
+ # ClaudeOS-Core โ€” generated analysis & translation cache
596
+ claudeos-core/generated/
597
+ ```
598
+
599
+ 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`.
600
+
601
+ ---
602
+
603
+ ## Auto-scaling by Project Size
604
+
605
+ 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.
606
+
607
+ | Project Size | Domains | Pass 3 Stages | Total `claude -p` | Est. Time |
608
+ |---|---|---|---|---|
609
+ | 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 |
610
+ | Medium | 5โ€“15 | 4 | 8โ€“9 | ~25โ€“45 min |
611
+ | Large | 16โ€“30 | **8** (3b, 3c each split into 2 batches) | 11โ€“12 | **~60โ€“105 min** |
612
+ | X-Large | 31โ€“45 | 10 | 13โ€“14 | ~100โ€“150 min |
613
+ | XX-Large | 46โ€“60 | 12 | 15โ€“16 | ~150โ€“200 min |
614
+ | XXX-Large | 61+ | 14+ | 17+ | 200 min+ |
615
+
616
+ 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)`.
617
+
618
+ 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.
619
+
620
+ ---
621
+
622
+ ## Verification Tools
623
+
624
+ ClaudeOS-Core includes 5 built-in verification tools that run automatically after generation:
625
+
626
+ ```bash
627
+ # Run all checks at once (recommended)
628
+ npx claudeos-core health
629
+
630
+ # Individual commands
631
+ npx claudeos-core validate # Plan โ†” disk comparison
632
+ npx claudeos-core refresh # Disk โ†’ Plan sync
633
+ npx claudeos-core restore # Plan โ†’ Disk restore
634
+
635
+ # Or use node directly (git clone users)
636
+ node claudeos-core-tools/health-checker/index.js
637
+ node claudeos-core-tools/manifest-generator/index.js
638
+ node claudeos-core-tools/plan-validator/index.js --check
639
+ node claudeos-core-tools/sync-checker/index.js
640
+ ```
641
+
642
+ | Tool | What It Does |
643
+ |---|---|
644
+ | **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. |
645
+ | **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. |
646
+ | **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). |
647
+ | **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. |
648
+ | **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`. |
649
+ | **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 |
650
+
651
+ ---
652
+
653
+ ## How Claude Code Uses Your Documentation
654
+
655
+ ClaudeOS-Core generates documentation that Claude Code actually reads โ€” here's how:
656
+
657
+ ### What Claude Code reads automatically
658
+
659
+ | File | When | Guaranteed |
660
+ |---|---|---|
661
+ | `CLAUDE.md` | Every conversation start | Always |
662
+ | `.claude/rules/00.core/*` | When any file is edited (`paths: ["**/*"]`) | Always |
663
+ | `.claude/rules/10.backend/*` | When any file is edited (`paths: ["**/*"]`) | Always |
664
+ | `.claude/rules/20.frontend/*` | When any frontend file is edited (scoped to component/page/style paths) | Conditional |
665
+ | `.claude/rules/30.security-db/*` | When any file is edited (`paths: ["**/*"]`) | Always |
666
+ | `.claude/rules/40.infra/*` | Only when editing config/infra files (scoped paths) | Conditional |
667
+ | `.claude/rules/50.sync/*` | Only when editing claudeos-core files (scoped paths) | Conditional |
668
+ | `.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) |
669
+
670
+ ### What Claude Code reads on-demand via rule references
671
+
672
+ Each rule file links to its corresponding standard via a `## Reference` section. Claude reads only the relevant standard for the current task:
673
+
674
+ - `claudeos-core/standard/**` โ€” coding patterns, โœ…/โŒ examples, naming conventions
675
+ - `claudeos-core/database/**` โ€” DB schema (for queries, mappers, migrations)
676
+ - `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.
677
+
678
+ The `00.standard-reference.md` serves as a directory of all standard files for discovering standards that have no corresponding rule.
679
+
680
+ ### What Claude Code does NOT read (saves context)
681
+
682
+ These folders are explicitly excluded via the `DO NOT Read` section in the standard-reference rule:
683
+
684
+ | Folder | Why excluded |
685
+ |---|---|
686
+ | `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. |
687
+ | `claudeos-core/generated/` | Build metadata JSON, prompts, Pass markers, translation cache, `.staged-rules/`. Not for coding. |
688
+ | `claudeos-core/guide/` | Onboarding guides for humans. |
689
+ | `claudeos-core/mcp-guide/` | MCP server docs. Not for coding. |
690
+ | `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. |
691
+
692
+ ---
693
+
694
+ ## Daily Workflow
695
+
696
+ ### After Installation
697
+
698
+ ```
699
+ # Just use Claude Code as normal โ€” it references your standards automatically:
700
+ "Create a CRUD for the order domain"
701
+ "Add user profile update API"
702
+ "Refactor this code to match project patterns"
703
+ ```
704
+
705
+ ### After Manually Editing Standards
706
+
707
+ ```bash
708
+ # After editing standards or rules files:
709
+ npx claudeos-core refresh
710
+
711
+ # Verify everything is consistent
712
+ npx claudeos-core health
713
+ ```
714
+
715
+ ### When Docs Get Corrupted
716
+
717
+ ```bash
718
+ # v2.1.0 recommendation: use git to restore (since master plans are no
719
+ # longer generated). Commit your generated docs regularly so you can roll
720
+ # back specific files without regenerating:
721
+ git checkout HEAD -- .claude/rules/ claudeos-core/
722
+
723
+ # Legacy (v2.0.x projects with claudeos-core/plan/ still present):
724
+ npx claudeos-core restore
725
+ ```
726
+
727
+ ### Memory Layer Maintenance (v2.0.0)
728
+
729
+ The L4 Memory layer (`claudeos-core/memory/`) accumulates team knowledge across sessions. Three CLI subcommands keep it healthy:
730
+
731
+ ```bash
732
+ # Compact: enforce 4-stage compaction policy (run periodically โ€” e.g. monthly)
733
+ npx claudeos-core memory compact
734
+ # Stage 1: summarize aged entries (>30 days, body โ†’ one-line)
735
+ # Stage 2: merge duplicate headings (frequency summed, latest fix kept)
736
+ # Stage 3: drop low-importance + aged (importance <3 AND lastSeen >60 days)
737
+ # Stage 4: enforce 400-line cap per file (oldest low-importance dropped first)
738
+
739
+ # Score: re-rank failure-patterns.md entries by importance
740
+ npx claudeos-core memory score
741
+ # importance = round(frequency ร— 1.5 + recency ร— 5), capped at 10
742
+ # Run after appending several new failure patterns
743
+
744
+ # Propose-rules: surface candidate rule additions from recurring failures
745
+ npx claudeos-core memory propose-rules
746
+ # Reads failure-patterns.md entries with frequency โ‰ฅ 3
747
+ # Computes confidence (sigmoid on weighted evidence ร— anchor multiplier)
748
+ # Writes proposals to memory/auto-rule-update.md (NOT auto-applied)
749
+ # Confidence โ‰ฅ 0.70 deserves serious review; accept โ†’ edit rule + log decision
750
+
751
+ # v2.1.0: `memory --help` now routes to subcommand help (was showing top-level)
752
+ npx claudeos-core memory --help
753
+ ```
754
+
755
+ > **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.
756
+
757
+ When to write to memory (Claude does this on-demand, but you can edit manually too):
758
+ - **`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.
759
+ - **`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.
760
+ - `compaction.md` and `auto-rule-update.md` โ€” generated/managed by the CLI subcommands above; don't edit by hand.
761
+
762
+ ### CI/CD Integration
763
+
764
+ ```yaml
765
+ # GitHub Actions example
766
+ - run: npx claudeos-core validate
767
+ # Exit code 1 blocks the PR
768
+
769
+ # Optional: monthly memory housekeeping (separate cron workflow)
770
+ - run: npx claudeos-core memory compact
771
+ - run: npx claudeos-core memory score
772
+ ```
773
+
774
+ ---
775
+
776
+ ## How Is This Different?
777
+
778
+ ### vs Other Claude Code Tools
779
+
780
+ | | ClaudeOS-Core | Everything Claude Code (50K+ โญ) | Harness | specs-generator | Claude `/init` |
781
+ |---|---|---|---|---|---|
782
+ | **Approach** | Code analyzes first, then LLM generates | Pre-built config presets | LLM designs agent teams | LLM generates spec docs | LLM writes CLAUDE.md |
783
+ | **Reads your source code** | โœ… Deterministic static analysis | โŒ | โŒ | โŒ (LLM reads) | โŒ (LLM reads) |
784
+ | **Stack detection** | Code confirms (ORM, DB, build tool, pkg manager) | N/A (stack-agnostic) | LLM guesses | LLM guesses | LLM guesses |
785
+ | **Domain detection** | Code confirms (Java 5 patterns, Kotlin CQRS, Next.js FSD) | N/A | LLM guesses | N/A | N/A |
786
+ | **Same project โ†’ Same result** | โœ… Deterministic analysis | โœ… (static files) | โŒ (LLM varies) | โŒ (LLM varies) | โŒ (LLM varies) |
787
+ | **Large project handling** | Domain group splitting (4 domains / 40 files per group) | N/A | No splitting | No splitting | Context window limit |
788
+ | **Output** | CLAUDE.md + Rules + Standards + Skills + Guides + Plans (40-50+ files) | Agents + Skills + Commands + Hooks | Agents + Skills | 6 spec documents | CLAUDE.md (1 file) |
789
+ | **Output location** | `.claude/rules/` (auto-loaded by Claude Code) | `.claude/` various | `.claude/agents/` + `.claude/skills/` | `.claude/steering/` + `specs/` | `CLAUDE.md` |
790
+ | **Post-generation verification** | โœ… 5 automated validators | โŒ | โŒ | โŒ | โŒ |
791
+ | **Multi-language output** | โœ… 10 languages | โŒ | โŒ | โŒ | โŒ |
792
+ | **Multi-stack** | โœ… Backend + Frontend simultaneous | โŒ Stack-agnostic | โŒ | โŒ | Partial |
793
+ | **Persistent memory layer** | โœ… L4 โ€” decision log + failure patterns + auto-scored rule proposals (v2.0.0) | โŒ | โŒ | โŒ | โŒ |
794
+ | **Agent orchestration** | โŒ | โœ… 28 agents | โœ… 6 patterns | โŒ | โŒ |
795
+
796
+ ### The key difference in one sentence
797
+
798
+ **Other tools give Claude "generally good instructions." ClaudeOS-Core gives Claude "instructions extracted from your actual code."**
799
+
800
+ That's why Claude Code stops generating JPA code in your MyBatis project,
801
+ stops using `success()` when your codebase uses `ok()`,
802
+ and stops creating `user/controller/` directories when your project uses `controller/user/`.
803
+
804
+ ### Complementary, not competing
805
+
806
+ ClaudeOS-Core focuses on **project-specific rules and standards**.
807
+ Other tools focus on **agent orchestration and workflows**.
808
+
809
+ 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.
810
+
811
+ ---
812
+
813
+ ## FAQ
814
+
815
+ **Q: Does it modify my source code?**
816
+ No. It only creates `CLAUDE.md`, `.claude/rules/`, and `claudeos-core/`. Your existing code is never modified.
817
+
818
+ **Q: How much does it cost?**
819
+ 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.
820
+
821
+ **Q: What is Pass 3 split mode and why was it added in v2.1.0?**
822
+ 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.
823
+ **Q: Should I commit the generated files to Git?**
824
+ Yes, recommended. Your team can share the same Claude Code standards. Consider adding `claudeos-core/generated/` to `.gitignore` (analysis JSON is regeneratable).
825
+
826
+ **Q: What about mixed-stack projects (e.g., Java backend + React frontend)?**
827
+ 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.
828
+
829
+ **Q: Does it work with Turborepo / pnpm workspaces / Lerna monorepos?**
830
+ 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.
831
+
832
+ **Q: What happens on re-run?**
833
+ 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.
834
+
835
+ **Q: Does NestJS get its own template or use the Express one?**
836
+ 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.
837
+
838
+ **Q: What about Vue / Nuxt projects?**
839
+ 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.
840
+
841
+ **Q: Does it support Kotlin?**
842
+ 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.).
843
+
844
+ **Q: What about CQRS / BFF architecture?**
845
+ 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.
846
+
847
+ **Q: What about Gradle multi-module monorepos?**
848
+ 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.
849
+
850
+ **Q: What is the L4 Memory layer (v2.0.0)? Should I commit `claudeos-core/memory/`?**
851
+ 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.
852
+
853
+ **Q: What if Pass 4 fails?**
854
+ 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.
855
+
856
+ **Q: What do `memory compact` / `memory score` / `memory propose-rules` do?**
857
+ 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).
858
+
859
+ **Q: Why does `--force` (or "fresh" resume mode) delete `.claude/rules/`?**
860
+ 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.)
861
+
862
+ **Q: What is `claudeos-core/generated/.staged-rules/` and why does it exist?**
863
+ 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.
864
+
865
+ **Q: Can I run Pass 3 manually instead of `npx claudeos-core init`?**
866
+ 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.
867
+
868
+ **Q: My project is an upgrade from v2.0.x and has an existing `claudeos-core/plan/` directory. What do I do?**
869
+ 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.
870
+
871
+ ---
872
+
873
+ ## Template Structure
874
+
875
+ ```
876
+ pass-prompts/templates/
877
+ โ”œโ”€โ”€ common/ # Shared header/footer + pass4 + staging-override + CLAUDE.md scaffold (v2.2.0)
878
+ โ”‚ โ”œโ”€โ”€ header.md # Role + output-format directive (all passes)
879
+ โ”‚ โ”œโ”€โ”€ pass3-footer.md # Post-Pass-3 health-check instruction + 5 CRITICAL guardrail blocks (v2.2.0)
880
+ โ”‚ โ”œโ”€โ”€ pass3-phase1.md # "Read Once, Extract Facts" block with Rules A-E (v2.1.0)
881
+ โ”‚ โ”œโ”€โ”€ pass4.md # Memory scaffolding prompt (v2.0.0)
882
+ โ”‚ โ”œโ”€โ”€ staging-override.md # Redirects .claude/rules/** writes to .staged-rules/** (v2.0.0)
883
+ โ”‚ โ”œโ”€โ”€ claude-md-scaffold.md # Deterministic 8-section CLAUDE.md template (v2.2.0)
884
+ โ”‚ โ””โ”€โ”€ lang-instructions.json # Per-language output directives (10 languages)
885
+ โ”œโ”€โ”€ java-spring/ # Java / Spring Boot
886
+ โ”œโ”€โ”€ kotlin-spring/ # Kotlin / Spring Boot (CQRS, BFF, multi-module)
887
+ โ”œโ”€โ”€ node-express/ # Node.js / Express
888
+ โ”œโ”€โ”€ node-nestjs/ # Node.js / NestJS (Module, DI, Guard, Pipe, Interceptor)
889
+ โ”œโ”€โ”€ node-fastify/ # Node.js / Fastify
890
+ โ”œโ”€โ”€ node-nextjs/ # Next.js / React (App Router, RSC)
891
+ โ”œโ”€โ”€ node-vite/ # Vite SPA (React, client-side routing, VITE_ env, Vitest)
892
+ โ”œโ”€โ”€ vue-nuxt/ # Vue / Nuxt (Composition API, Pinia, Nitro)
893
+ โ”œโ”€โ”€ angular/ # Angular
894
+ โ”œโ”€โ”€ python-django/ # Python / Django (DRF)
895
+ โ”œโ”€โ”€ python-fastapi/ # Python / FastAPI
896
+ โ””โ”€โ”€ python-flask/ # Python / Flask (Blueprint, app factory, Jinja2)
897
+ ```
898
+
899
+ `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.
900
+
901
+ **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.
902
+
903
+ ---
904
+
905
+ ## Monorepo Support
906
+
907
+ ClaudeOS-Core automatically detects JS/TS monorepo setups and scans sub-packages for dependencies.
908
+
909
+ **Supported monorepo markers** (auto-detected):
910
+ - `turbo.json` (Turborepo)
911
+ - `pnpm-workspace.yaml` (pnpm workspaces)
912
+ - `lerna.json` (Lerna)
913
+ - `package.json#workspaces` (npm/yarn workspaces)
914
+
915
+ **Run from the monorepo root** โ€” ClaudeOS-Core reads `apps/*/package.json` and `packages/*/package.json` to discover framework/ORM/DB dependencies across sub-packages:
916
+
917
+ ```bash
918
+ cd my-monorepo
919
+ npx claudeos-core init
920
+ ```
921
+
922
+ **What gets detected:**
923
+ - Dependencies from `apps/web/package.json` (e.g., `next`, `react`) โ†’ frontend stack
924
+ - Dependencies from `apps/api/package.json` (e.g., `express`, `prisma`) โ†’ backend stack
925
+ - Dependencies from `packages/db/package.json` (e.g., `drizzle-orm`) โ†’ ORM/DB
926
+ - Custom workspace paths from `pnpm-workspace.yaml` (e.g., `services/*`)
927
+
928
+ **Domain scanning also covers monorepo layouts:**
929
+ - `apps/api/src/modules/*/` and `apps/api/src/*/` for backend domains
930
+ - `apps/web/app/*/`, `apps/web/src/app/*/`, `apps/web/pages/*/` for frontend domains
931
+ - `packages/*/src/*/` for shared package domains
932
+
933
+ ```
934
+ my-monorepo/ โ† Run here: npx claudeos-core init
935
+ โ”œโ”€โ”€ turbo.json โ† Auto-detected as Turborepo
936
+ โ”œโ”€โ”€ apps/
937
+ โ”‚ โ”œโ”€โ”€ web/ โ† Next.js detected from apps/web/package.json
938
+ โ”‚ โ”‚ โ”œโ”€โ”€ app/dashboard/ โ† Frontend domain detected
939
+ โ”‚ โ”‚ โ””โ”€โ”€ package.json โ† { "dependencies": { "next": "^14" } }
940
+ โ”‚ โ””โ”€โ”€ api/ โ† Express detected from apps/api/package.json
941
+ โ”‚ โ”œโ”€โ”€ src/modules/users/ โ† Backend domain detected
942
+ โ”‚ โ””โ”€โ”€ package.json โ† { "dependencies": { "express": "^4" } }
943
+ โ”œโ”€โ”€ packages/
944
+ โ”‚ โ”œโ”€โ”€ db/ โ† Drizzle detected from packages/db/package.json
945
+ โ”‚ โ””โ”€โ”€ ui/
946
+ โ””โ”€โ”€ package.json โ† { "workspaces": ["apps/*", "packages/*"] }
947
+ ```
948
+
949
+ > **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.
950
+
951
+ ## Troubleshooting
952
+
953
+ **"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).
954
+
955
+ **"npm install failed"** โ€” Node.js version may be too low. Requires v18+.
956
+
957
+ **"0 domains detected"** โ€” Your project structure may be non-standard. See the detection patterns above for your stack.
958
+
959
+ **"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/`.
960
+
961
+ **"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`.
962
+
963
+ **"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.
964
+
965
+ **"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.
966
+
967
+ **"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`.
968
+
969
+ **"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.
970
+
971
+ **"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.
972
+
973
+ **"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`.
974
+
975
+ **"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.
976
+
977
+ **"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`.
978
+
979
+ **"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.
980
+
981
+ **"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.
982
+
983
+ **"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.
984
+
985
+ **"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`.
986
+
987
+ **"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`.
988
+
989
+ **"โš ๏ธ 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.
990
+
991
+ **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.
992
+
993
+ **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.
994
+
995
+ ---
996
+
997
+ ## Contributing
998
+
999
+ Contributions are welcome! Areas where help is most needed:
1000
+
1001
+ - **New stack templates** โ€” Ruby/Rails, Go (Gin/Fiber/Echo), PHP (Laravel/Symfony), Rust (Axum/Actix), Svelte/SvelteKit, Remix
1002
+ - **IDE integration** โ€” VS Code extension, IntelliJ plugin
1003
+ - **CI/CD templates** โ€” GitLab CI, CircleCI, Jenkins examples (GitHub Actions already shipped โ€” see `.github/workflows/test.yml`)
1004
+ - **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))
1005
+
1006
+ 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.
1007
+
1008
+ ---
1009
+
1010
+ ## Author
1011
+
1012
+ Created by **claudeos-core** โ€” [GitHub](https://github.com/claudeos-core) ยท [Email](mailto:claudeoscore@gmail.com)
1013
+
1014
+ ## License
1015
+
1016
+ ISC