claudeos-core 2.3.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +736 -74
  2. package/CODE_OF_CONDUCT.md +15 -0
  3. package/README.de.md +321 -883
  4. package/README.es.md +322 -883
  5. package/README.fr.md +322 -883
  6. package/README.hi.md +322 -883
  7. package/README.ja.md +322 -883
  8. package/README.ko.md +322 -882
  9. package/README.md +321 -883
  10. package/README.ru.md +322 -885
  11. package/README.vi.md +322 -883
  12. package/README.zh-CN.md +321 -881
  13. package/SECURITY.md +51 -0
  14. package/bin/commands/init.js +192 -37
  15. package/content-validator/index.js +97 -4
  16. package/health-checker/index.js +44 -10
  17. package/package.json +92 -90
  18. package/pass-json-validator/index.js +58 -7
  19. package/pass-prompts/templates/angular/pass3.md +15 -14
  20. package/pass-prompts/templates/common/claude-md-scaffold.md +81 -0
  21. package/pass-prompts/templates/common/pass3-footer.md +104 -0
  22. package/pass-prompts/templates/java-spring/pass3.md +19 -18
  23. package/pass-prompts/templates/kotlin-spring/pass3.md +23 -22
  24. package/pass-prompts/templates/node-express/pass3.md +18 -17
  25. package/pass-prompts/templates/node-fastify/pass3.md +11 -10
  26. package/pass-prompts/templates/node-nestjs/pass3.md +11 -10
  27. package/pass-prompts/templates/node-nextjs/pass3.md +18 -17
  28. package/pass-prompts/templates/node-vite/pass3.md +11 -10
  29. package/pass-prompts/templates/python-django/pass3.md +18 -17
  30. package/pass-prompts/templates/python-fastapi/pass3.md +18 -17
  31. package/pass-prompts/templates/python-flask/pass3.md +9 -8
  32. package/pass-prompts/templates/vue-nuxt/pass3.md +9 -8
  33. package/plan-installer/domain-grouper.js +45 -5
  34. package/plan-installer/index.js +11 -1
  35. package/plan-installer/scanners/scan-java.js +98 -2
  36. package/plan-installer/stack-detector.js +44 -0
package/README.md CHANGED
@@ -1,1016 +1,454 @@
1
1
  # ClaudeOS-Core
2
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.**
3
+ [![npm version](https://img.shields.io/npm/v/claudeos-core.svg?logo=npm&label=npm)](https://www.npmjs.com/package/claudeos-core)
4
+ [![CI](https://img.shields.io/github/actions/workflow/status/claudeos-core/claudeos-core/test.yml?branch=master&logo=github&label=CI)](https://github.com/claudeos-core/claudeos-core/actions/workflows/test.yml)
5
+ [![tests](https://img.shields.io/badge/tests-736%20passing-brightgreen?logo=node.js&logoColor=white)](https://github.com/claudeos-core/claudeos-core/actions/workflows/test.yml)
6
+ [![node](https://img.shields.io/node/v/claudeos-core.svg?logo=node.js&logoColor=white&label=node)](https://nodejs.org/)
7
+ [![license](https://img.shields.io/npm/l/claudeos-core.svg?color=blue)](LICENSE)
8
+ [![downloads](https://img.shields.io/npm/dm/claudeos-core.svg?logo=npm&color=blue&label=downloads)](https://www.npmjs.com/package/claudeos-core)
9
+
10
+ **Auto-generate Claude Code documentation from your actual source code.** A CLI tool that statically analyzes your project, then runs a 4-pass Claude pipeline to generate `.claude/rules/`, standards, skills, and guides — so Claude Code follows your project's conventions, not generic ones.
4
11
 
5
12
  ```bash
6
13
  npx claudeos-core init
7
14
  ```
8
15
 
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)
16
+ [🇰🇷 한국어](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
17
 
13
18
  ---
14
19
 
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.
20
+ ## What is this?
28
21
 
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).
22
+ You use Claude Code. It's smart, but it doesn't know **your project's conventions**:
23
+ - Your team uses MyBatis, but Claude generates JPA code.
24
+ - Your wrapper is `ApiResponse.ok()`, but Claude writes `ResponseEntity.success()`.
25
+ - Your packages are `controller/order/`, but Claude creates `order/controller/`.
32
26
 
33
- **ClaudeOS-Core doesn't guess.** Before Claude ever sees your project, Node.js code has already:
27
+ So you spend a chunk of time fixing every generated file.
34
28
 
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
29
+ **ClaudeOS-Core fixes this.** It scans your actual source code, figures out your conventions, and writes a complete set of rules into `.claude/rules/` — the directory Claude Code reads automatically. Next time you say *"Create a CRUD for orders"*, Claude follows your conventions on the first try.
40
30
 
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
31
  ```
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
32
+ Before: You Claude Code "generally good" code → manual fixing
33
+ After: You Claude Code → code that matches your project ship it
57
34
  ```
58
35
 
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
36
  ---
71
37
 
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. Three canonical classes: (1) **identifier-to-filename renormalization** — inferring a filename from an ALL_CAPS TypeScript constant or Java annotation when the actual filename lives under a different convention; (2) **framework-convention entry-point invention** — assuming a stock entry-point file (Vite's main module, Next.js app-router providers, etc.) in a project that chose a different layout; (3) **plausibly-named utility invention** — citing a concrete filename for a helper that "would naturally" exist under a seen directory.
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
-
38
+ ## See it on a real project
39
+
40
+ Run on [`spring-boot-realworld-example-app`](https://github.com/gothinkster/spring-boot-realworld-example-app)Java 11 · Spring Boot 2.6 · MyBatis · SQLite · 187 source files. Output: **75 generated files**, total time **53 minutes**, all validators ✅.
41
+
42
+ <p align="center">
43
+ <img src="docs/assets/spring-boot-realworld-demo.gif" alt="ClaudeOS-Core init running on spring-boot-realworld-example-app — stack detection, 4-pass pipeline, validators, completion summary" width="769">
44
+ </p>
45
+
46
+ <details>
47
+ <summary><strong>📺 Terminal output (text version, for search & copy)</strong></summary>
48
+
49
+ ```text
50
+ ╔════════════════════════════════════════════════════╗
51
+ ║ ClaudeOS-Core — Bootstrap (4-Pass) ║
52
+ ╚════════════════════════════════════════════════════╝
53
+ Project root: spring-boot-realworld-example-app
54
+ Language: English (en)
55
+
56
+ [Phase 1] Detecting stack...
57
+ Language: java 11
58
+ Framework: spring-boot 2.6.3
59
+ Database: sqlite
60
+ ORM: mybatis
61
+ PackageMgr: gradle
62
+
63
+ [Phase 2] Scanning structure...
64
+ Backend: 2 domains
65
+ Total: 2 domains
66
+ Package: io.spring.infrastructure
67
+
68
+ [Phase 5] Active domains...
69
+ ✅ 00.core ✅ 10.backend ⏭️ 20.frontend
70
+ ✅ 30.security-db ✅ 40.infra
71
+ ✅ 80.verification ✅ 90.optional
72
+
73
+ [4] Pass 1 — Deep analysis per domain group...
74
+ ✅ pass1-1.json created (5m 34s)
75
+ [█████░░░░░░░░░░░░░░░] 25% (1/4)
76
+
77
+ [5] Pass 2 — Merging analysis results...
78
+ ✅ pass2-merged.json created (4m 22s)
79
+ [██████████░░░░░░░░░░] 50% (2/4)
80
+
81
+ [6] Pass 3 — Generating all files...
82
+ 🚀 Pass 3 split mode (3a → 3b → 3c → 3d-aux)
83
+ ✅ 3a complete (2m 57s) — pass3a-facts.md (187-path allowlist)
84
+ ✅ 3b complete (18m 49s) — CLAUDE.md + 19 standards + 20 rules
85
+ ✅ 3c complete (12m 35s) — 13 skills + 9 guides
86
+ ✅ 3d-aux complete (3m 18s) — database/ + mcp-guide/
87
+ 🎉 Pass 3 split complete: 4/4 stages successful
88
+ [███████████████░░░░░] 75% (3/4)
89
+
90
+ [7] Pass 4 — Memory scaffolding...
91
+ 📦 Pass 4 staged-rules: 6 rule files moved to .claude/rules/
92
+ ✅ Pass 4 complete (5m)
93
+ 📋 Gap-fill: all 12 expected files already present
94
+ [████████████████████] 100% (4/4)
95
+
96
+ ╔═══════════════════════════════════════╗
97
+ ║ ClaudeOS-Core — Health Checker ║
98
+ ╚═══════════════════════════════════════╝
99
+ ✅ plan-validator pass
100
+ ✅ sync-checker pass
101
+ ✅ content-validator pass
102
+ ✅ pass-json-validator pass
103
+ ✅ All systems operational
104
+
105
+ [Lint] ✅ CLAUDE.md structure valid (25 checks)
106
+ [Content] ✅ All content validation passed
107
+ Total: 0 advisories, 0 notes
108
+
109
+ ╔════════════════════════════════════════════════════╗
110
+ ║ ✅ ClaudeOS-Core — Complete ║
111
+ ║ Files created: 75 ║
112
+ ║ Domains analyzed: 1 group ║
113
+ ║ L4 scaffolded: memory + rules ║
114
+ ║ Output language: English ║
115
+ ║ Total time: 53m 8s ║
116
+ ╚════════════════════════════════════════════════════╝
117
+ ```
118
+
119
+ </details>
120
+
121
+ <details>
122
+ <summary><strong>📄 What ends up in your <code>CLAUDE.md</code> (real excerpt)</strong></summary>
123
+
124
+ ```markdown
125
+ ## 4. Core Architecture
126
+
127
+ ### Core Patterns
128
+
129
+ - **Hexagonal ports & adapters**: domain ports live in `io.spring.core.{aggregate}`
130
+ and are implemented by `io.spring.infrastructure.repository.MyBatis{Aggregate}Repository`.
131
+ The domain layer has zero MyBatis imports.
132
+ - **CQRS-lite read/write split (same DB)**: write side goes through repository ports
133
+ + entities; read side is a separate `readservice` package whose `@Mapper`
134
+ interfaces return `*Data` DTOs directly (no entity hydration).
135
+ - **No aggregator/orchestrator layer**: multi-source orchestration happens inside
136
+ application services (e.g., `ArticleQueryService`); there is no `*Aggregator`
137
+ class in the codebase.
138
+ - **Application-supplied UUIDs**: entity constructors assign their own UUID; PK is
139
+ passed via `#{user.id}` on INSERT. The global
140
+ `mybatis.configuration.use-generated-keys=true` flag is dead config
141
+ (auto-increment is unused).
142
+ - **JWT HS512 authentication**: `io.spring.infrastructure.service.DefaultJwtService`
143
+ is the sole token subject in/out; `io.spring.api.security.JwtTokenFilter`
144
+ extracts the token at the servlet layer.
145
+ ```
146
+
147
+ Note: every claim above is grounded in the actual source — class names, package paths, configuration keys, and the dead-config flag are all extracted by the scanner before Claude writes the file.
148
+
149
+ </details>
150
+
151
+ <details>
152
+ <summary><strong>🛡️ A real auto-loaded rule (<code>.claude/rules/10.backend/03.data-access-rules.md</code>)</strong></summary>
153
+
154
+ ````markdown
98
155
  ---
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
-
156
+ paths:
157
+ - "**/*"
192
158
  ---
193
159
 
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
160
+ # Data Access Rules
219
161
 
220
- # Cross-platform (PowerShell, CMD, Bash, Zsh — any terminal)
221
- node claudeos-core-tools/bin/cli.js init
162
+ ## XML-only SQL
163
+ - Every SQL statement lives in `src/main/resources/mapper/*.xml`.
164
+ NO `@Select` / `@Insert` / `@Update` / `@Delete` annotations on `@Mapper` methods.
165
+ - Each `@Mapper` interface has exactly one XML file at
166
+ `src/main/resources/mapper/{InterfaceName}.xml`.
167
+ - `<mapper namespace="...">` MUST be the fully qualified Java interface name.
168
+ The single existing exception is `TransferData.xml` (free-form `transfer.data`).
222
169
 
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)
170
+ ## Dynamic SQL
171
+ - `<if>` predicates MUST guard both null and empty:
172
+ `<if test="X != null and X != ''">`. Empty-only is the existing HIGH-severity bug pattern.
173
+ - Prefer `LIMIT n OFFSET m` over MySQL-style `LIMIT m, n`.
317
174
 
318
- Run Pass 1 for each domain group. Check `domain-groups.json` for the number of groups.
175
+ ## Examples
319
176
 
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
177
+ ✅ Correct:
178
+ ```xml
179
+ <update id="update">
180
+ UPDATE articles
181
+ <set>
182
+ <if test="article.title != null and article.title != ''">title = #{article.title},</if>
183
+ updated_at = #{article.updatedAt}
184
+ </set>
185
+ WHERE id = #{article.id}
186
+ </update>
353
187
  ```
354
188
 
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
189
+ Incorrect:
190
+ ```xml
191
+ <mapper namespace="article.mapper"> <!-- NO namespace MUST be FQCN -->
362
192
  ```
193
+ ````
363
194
 
364
- **Verify:** `claudeos-core/generated/pass2-merged.json` should exist with 9+ top-level keys.
195
+ The `paths: ["**/*"]` glob means Claude Code auto-loads this rule whenever you edit any file in the project. The ✅/❌ examples come straight from this codebase's actual conventions and existing bug patterns.
365
196
 
366
- #### Step 6: Pass 3 — Generate all documentation (split into multiple stages)
197
+ </details>
367
198
 
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.
199
+ <details>
200
+ <summary><strong>🧠 An auto-generated <code>decision-log.md</code> seed (real excerpt)</strong></summary>
369
201
 
370
- **Single-call mode (small projects only, ≤5 domains):**
202
+ ```markdown
203
+ ## 2026-04-26 — CQRS-lite read/write split inside the persistence layer
371
204
 
372
- ```bash
373
- cat claudeos-core/generated/pass3-prompt.md \
374
- | claude -p --dangerously-skip-permissions
205
+ - **Context:** Writes go through `core.*Repository` port → `MyBatis*Repository`
206
+ adapter → `io.spring.infrastructure.mybatis.mapper.{Aggregate}Mapper`.
207
+ Reads bypass the domain port: application service →
208
+ `io.spring.infrastructure.mybatis.readservice.{Concept}ReadService` directly,
209
+ returning flat `*Data` DTOs from `io.spring.application.data.*`.
210
+ - **Options considered:** Single repository surface returning hydrated entities
211
+ for both reads and writes.
212
+ - **Decision:** Same database, two `@Mapper` packages — `mapper/` (write side,
213
+ operates on core entities) and `readservice/` (read side, returns `*Data` DTOs).
214
+ Read DTOs avoid entity hydration overhead.
215
+ - **Consequences:** Reads are NOT routed through the domain port — this is
216
+ intentional, not a bug. Application services may inject both a `*Repository`
217
+ (writes) and one or more `*ReadService` interfaces (reads) at the same time.
218
+ Do NOT add hydrate-then-map glue in the read path.
375
219
  ```
376
220
 
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).
221
+ Pass 4 seeds `decision-log.md` with the architectural decisions extracted from `pass2-merged.json` so future sessions remember *why* the codebase looks the way it does — not just *what* it looks like.
393
222
 
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).
223
+ </details>
395
224
 
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
225
+ ---
417
226
 
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
- ```
227
+ ## Quick Start
424
228
 
425
- #### Step 9: Verify the results
229
+ **Prerequisites:** Node.js 18+, [Claude Code](https://docs.anthropic.com/en/docs/claude-code) installed and authenticated.
426
230
 
427
231
  ```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
- ```
232
+ # 1. Go to your project root
233
+ cd my-spring-boot-project
440
234
 
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
- ```
235
+ # 2. Run init (this analyzes your code and asks Claude to write the rules)
459
236
  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
237
 
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
- ---
238
+ # 3. Done. Open Claude Code and start coding your rules are already loaded.
239
+ ```
520
240
 
521
- ## Generated File Structure
241
+ **What you get** after `init` finishes:
522
242
 
523
243
  ```
524
244
  your-project/
525
-
526
- ├── CLAUDE.md ← Claude Code entry point (deterministic 8-section structure, v2.2.0)
527
-
528
245
  ├── .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`.
246
+ │ └── rules/ Auto-loaded by Claude Code
247
+ │ ├── 00.core/ (general rules — naming, architecture)
248
+ │ ├── 10.backend/ (backend stack rules, if any)
249
+ │ ├── 20.frontend/ (frontend stack rules, if any)
250
+ │ ├── 30.security-db/ (security & DB conventions)
251
+ │ ├── 40.infra/ (env, logging, CI/CD)
252
+ │ ├── 50.sync/ (doc-sync reminders rules only)
253
+ ├── 60.memory/ (memory rules Pass 4, rules only)
254
+ ├── 70.domains/{type}/ (per-domain rules, type = backend|frontend)
255
+ │ └── 80.verification/ (testing strategy + build verification reminders)
256
+ ├── claudeos-core/
257
+ │ ├── standard/ Reference docs (mirror category structure)
258
+ │ │ ├── 00.core/ (project overview, architecture, naming)
259
+ │ │ ├── 10.backend/ (backend reference if backend stack)
260
+ │ │ ├── 20.frontend/ (frontend reference if frontend stack)
261
+ │ │ ├── 30.security-db/ (security & DB reference)
262
+ │ │ ├── 40.infra/ (env / logging / CI-CD reference)
263
+ │ │ ├── 70.domains/{type}/ (per-domain reference)
264
+ │ │ ├── 80.verification/ (build / startup / testing reference standard only)
265
+ │ │ └── 90.optional/ (stack-specific extras standard only)
266
+ │ ├── skills/ (reusable patterns Claude can apply)
267
+ │ ├── guide/ (how-to guides for common tasks)
268
+ │ ├── database/ (schema overview, migration guide)
269
+ │ ├── mcp-guide/ (MCP integration notes)
270
+ └── memory/ (decision log, failure patterns, compaction)
271
+ └── CLAUDE.md (the index Claude reads first)
272
+ ```
273
+
274
+ Categories sharing the same number prefix between `rules/` and `standard/` represent the same conceptual area (e.g., `10.backend` rules ↔ `10.backend` standards). Rules-only categories: `50.sync` (doc sync reminders) and `60.memory` (Pass 4 memory). Standard-only category: `90.optional` (stack-specific extras with no enforcement). All other prefixes (`00`, `10`, `20`, `30`, `40`, `70`, `80`) appear in BOTH `rules/` and `standard/`. Claude Code now knows your project.
600
275
 
601
276
  ---
602
277
 
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.
278
+ ## Who is this for?
606
279
 
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)`.
280
+ | You are... | This helps you... |
281
+ |---|---|
282
+ | **A solo dev** starting a new project with Claude Code | Skip the "teach Claude my conventions" phase entirely |
283
+ | **A team lead** maintaining shared standards | Automate the tedious part of keeping `.claude/rules/` up to date |
284
+ | **Already using Claude Code** but tired of fixing generated code | Make Claude follow YOUR patterns, not "generally good" patterns |
617
285
 
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.
286
+ **Not a fit if:** you want a one-size-fits-all preset bundle of agents/skills/rules that works on day one without a scan step (see [docs/comparison.md](docs/comparison.md) for what fits where), or your project doesn't fit one of the [supported stacks](#supported-stacks) yet.
619
287
 
620
288
  ---
621
289
 
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
290
+ ## How does it work?
629
291
 
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
292
+ ClaudeOS-Core inverts the usual Claude Code workflow:
634
293
 
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
294
+ ```
295
+ Usual: You describe project → Claude guesses your stack → Claude writes docs
296
+ This: Code reads your stack → Code passes confirmed facts to Claude → Claude writes docs from facts
640
297
  ```
641
298
 
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` (LLM-fabricated paths from identifier-to-filename renormalization, framework-convention entry-point invention, or plausibly-named utility invention) 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:
299
+ The key idea: **a Node.js scanner reads your source code first** (deterministic, no AI), then a 4-pass Claude pipeline writes the documentation, constrained by what the scanner found. Claude can't invent paths or frameworks that aren't actually in your code.
656
300
 
657
- ### What Claude Code reads automatically
301
+ For the full architecture, see [docs/architecture.md](docs/architecture.md).
658
302
 
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) |
303
+ ---
669
304
 
670
- ### What Claude Code reads on-demand via rule references
305
+ ## Supported Stacks
671
306
 
672
- Each rule file links to its corresponding standard via a `## Reference` section. Claude reads only the relevant standard for the current task:
307
+ 12 stacks, auto-detected from your project files:
673
308
 
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.
309
+ **Backend:** Java/Spring Boot · Kotlin/Spring Boot · Node/Express · Node/Fastify · Node/NestJS · Python/Django · Python/FastAPI · Python/Flask
677
310
 
678
- The `00.standard-reference.md` serves as a directory of all standard files for discovering standards that have no corresponding rule.
311
+ **Frontend:** Node/Next.js · Node/Vite · Angular · Vue/Nuxt
679
312
 
680
- ### What Claude Code does NOT read (saves context)
313
+ Multi-stack projects (e.g., Spring Boot backend + Next.js frontend) work out of the box.
681
314
 
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. |
315
+ For detection rules and what each scanner extracts, see [docs/stacks.md](docs/stacks.md).
691
316
 
692
317
  ---
693
318
 
694
319
  ## Daily Workflow
695
320
 
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
321
+ Three commands cover ~95% of usage:
706
322
 
707
323
  ```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
324
+ # First time on a project
325
+ npx claudeos-core init
716
326
 
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/
327
+ # After you manually edited standards or rules
328
+ npx claudeos-core lint
722
329
 
723
- # Legacy (v2.0.x projects with claudeos-core/plan/ still present):
724
- npx claudeos-core restore
330
+ # Health check (run before commits, or in CI)
331
+ npx claudeos-core health
725
332
  ```
726
333
 
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:
334
+ Two more for memory layer maintenance:
730
335
 
731
336
  ```bash
732
- # Compact: enforce 4-stage compaction policy (run periodically — e.g. monthly)
337
+ # Compact the failure-patterns log (run periodically)
733
338
  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
339
 
744
- # Propose-rules: surface candidate rule additions from recurring failures
340
+ # Promote frequent failure patterns into proposed rules
745
341
  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
342
  ```
754
343
 
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.
344
+ For each command's full options, see [docs/commands.md](docs/commands.md).
810
345
 
811
346
  ---
812
347
 
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).
348
+ ## What makes this different
858
349
 
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.)
350
+ Most Claude Code documentation tools generate from a description (you tell the tool, the tool tells Claude). ClaudeOS-Core generates from your actual source code (the tool reads, the tool tells Claude what's confirmed, Claude writes only what's confirmed).
861
351
 
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.
352
+ Three concrete consequences:
864
353
 
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.
354
+ 1. **Deterministic stack detection.** Same project + same code = same output. No "Claude rolled differently this time."
355
+ 2. **No invented paths.** The Pass 3 prompt explicitly lists every allowed source path; Claude can't cite paths that don't exist.
356
+ 3. **Multi-stack aware.** Backend and frontend domains use different analysis prompts in the same run.
867
357
 
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.
358
+ For a side-by-side scope comparison with other tools, see [docs/comparison.md](docs/comparison.md). The comparison is about **what each tool does**, not **which is better** — most are complementary.
870
359
 
871
360
  ---
872
361
 
873
- ## Template Structure
362
+ ## Verification (post-generation)
874
363
 
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.
364
+ After Claude writes the docs, code verifies them. Five separate validators:
908
365
 
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)
366
+ | Validator | What it checks | Run by |
367
+ |---|---|---|
368
+ | `claude-md-validator` | CLAUDE.md structural invariants (8 sections, language-invariant) | `claudeos-core lint` |
369
+ | `content-validator` | Path claims actually exist; manifest consistency | `health` (advisory) |
370
+ | `pass-json-validator` | Pass 1 / 2 / 3 / 4 outputs are well-formed JSON | `health` (warn) |
371
+ | `plan-validator` | Saved plan matches what's on disk | `health` (fail-on-error) |
372
+ | `sync-checker` | Disk files match `sync-map.json` registrations (orphaned/unregistered detection) | `health` (fail-on-error) |
914
373
 
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:
374
+ A `health-checker` orchestrates the four runtime validators with three-tier severity (fail / warn / advisory) and exits with the appropriate code for CI. `claude-md-validator` runs separately via the `lint` command since structural drift is a re-init signal, not a soft warning. Run anytime:
916
375
 
917
376
  ```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/*"] }
377
+ npx claudeos-core health
947
378
  ```
948
379
 
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.
380
+ For each validator's checks in detail, see [docs/verification.md](docs/verification.md).
950
381
 
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/`.
382
+ ---
960
383
 
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`.
384
+ ## Memory Layer (optional, for long-running projects)
962
385
 
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.
386
+ After v2.0, ClaudeOS-Core writes a `claudeos-core/memory/` folder with four files:
964
387
 
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.
388
+ - `decision-log.md` append-only "why we chose X over Y"
389
+ - `failure-patterns.md` — recurring errors with frequency/importance scores
390
+ - `compaction.md` — how memory is auto-compacted over time
391
+ - `auto-rule-update.md` — patterns that should become new rules
966
392
 
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`.
393
+ You can run `npx claudeos-core memory propose-rules` to ask Claude to look at recent failure patterns and suggest new rules to add.
968
394
 
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.
395
+ For the memory model and lifecycle, see [docs/memory-layer.md](docs/memory-layer.md).
970
396
 
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.
397
+ ---
972
398
 
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`.
399
+ ## FAQ
974
400
 
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.
401
+ **Q: Do I need a Claude API key?**
402
+ A: No. ClaudeOS-Core uses your existing Claude Code installation — it pipes prompts to `claude -p` on your machine. No extra accounts.
976
403
 
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`.
404
+ **Q: Will this overwrite my existing CLAUDE.md or `.claude/rules/`?**
405
+ A: First run on a fresh project: it creates them. Re-running without `--force` preserves your edits — pass markers from the previous run are detected and the passes are skipped. Re-running with `--force` wipes and regenerates everything (your edits are lost — that's what `--force` means). See [docs/safety.md](docs/safety.md).
978
406
 
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.
407
+ **Q: My stack isn't supported. Can I add one?**
408
+ A: Yes. New stacks need ~3 prompt templates + a domain scanner. See [CONTRIBUTING.md](CONTRIBUTING.md) for the 8-step guide.
980
409
 
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.
410
+ **Q: How do I generate docs in Korean (or another language)?**
411
+ A: `npx claudeos-core init --lang ko`. 10 languages supported: en, ko, ja, zh-CN, es, vi, hi, ru, fr, de.
982
412
 
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.
413
+ **Q: Does this work with monorepos?**
414
+ A: Yes — Turborepo (`turbo.json`), pnpm workspaces (`pnpm-workspace.yaml`), Lerna (`lerna.json`), and npm/yarn workspaces (`package.json#workspaces`) are detected by the stack-detector. Each app gets its own analysis. Other monorepo layouts (e.g., NX) are not detected specifically, but generic `apps/*/` and `packages/*/` patterns are still picked up by the per-stack scanners.
984
415
 
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`.
416
+ **Q: What if Claude Code generates rules I disagree with?**
417
+ A: Edit them directly. Then run `npx claudeos-core lint` to verify CLAUDE.md is still structurally valid. Your edits are preserved on subsequent `init` runs (without `--force`) — the resume mechanism skips passes whose markers exist.
986
418
 
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`.
419
+ **Q: Where do I report bugs?**
420
+ A: [GitHub Issues](https://github.com/claudeos-core/claudeos-core/issues). For security issues, see [SECURITY.md](SECURITY.md).
988
421
 
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.
422
+ ---
990
423
 
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.
424
+ ## Documentation
992
425
 
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.
426
+ | Topic | Read this |
427
+ |---|---|
428
+ | How the 4-pass pipeline works (deeper than the diagram) | [docs/architecture.md](docs/architecture.md) |
429
+ | Visual diagrams (Mermaid) of the architecture | [docs/diagrams.md](docs/diagrams.md) |
430
+ | Stack detection — what each scanner looks for | [docs/stacks.md](docs/stacks.md) |
431
+ | Memory layer — decision logs and failure patterns | [docs/memory-layer.md](docs/memory-layer.md) |
432
+ | All 5 validators in detail | [docs/verification.md](docs/verification.md) |
433
+ | Every CLI command and option | [docs/commands.md](docs/commands.md) |
434
+ | Manual installation (no `npx`) | [docs/manual-installation.md](docs/manual-installation.md) |
435
+ | Scanner overrides — `.claudeos-scan.json` | [docs/advanced-config.md](docs/advanced-config.md) |
436
+ | Safety: what gets preserved on re-init | [docs/safety.md](docs/safety.md) |
437
+ | Comparison with similar tools (scope, not quality) | [docs/comparison.md](docs/comparison.md) |
438
+ | Errors and recovery | [docs/troubleshooting.md](docs/troubleshooting.md) |
994
439
 
995
440
  ---
996
441
 
997
442
  ## Contributing
998
443
 
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))
444
+ Contributions welcome adding stack support, improving prompts, fixing bugs. See [CONTRIBUTING.md](CONTRIBUTING.md).
1005
445
 
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
- ---
446
+ For Code of Conduct and security policy, see [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) and [SECURITY.md](SECURITY.md).
1009
447
 
1010
- ## Author
448
+ ## License
1011
449
 
1012
- Created by **claudeos-core** — [GitHub](https://github.com/claudeos-core) · [Email](mailto:claudeoscore@gmail.com)
450
+ [ISC](LICENSE) free for any use, including commercial.
1013
451
 
1014
- ## License
452
+ ---
1015
453
 
1016
- ISC
454
+ <sub>Built with care by [@claudeos-core](https://github.com/claudeos-core). If this saved you time, a ⭐ on GitHub keeps it visible.</sub>