CLAUDE.md cho monorepo
CLAUDE.md gốc cho monorepo nhiều package. File gốc chỉ nói những gì chung cho cả repo; mỗi package có CLAUDE.md riêng, Claude chỉ đọc khi làm việc trong package đó nên không tốn context.
Đã thử với Claude Code 2.1.329
Chỗ cần điền
{{repo_name}}Tên monorepoví dụacme-platform{{workspace_tool}}Công cụ quản lý workspace (pnpm, turbo, nx…)ví dụpnpm{{package}}Tên một package (lặp lại file thứ hai cho từng package)ví dụui-kit
CLAUDE.md
# {{repo_name}}
Monorepo managed with {{workspace_tool}} workspaces.
## Layout
- `apps/`: deployable apps. `packages/`: shared libraries.
- Each app or package has its own `CLAUDE.md` with its commands; read it before working there.
## Commands (from the repo root)
- Install everything: `{{workspace_tool}} install`
- Run one package's tests: `{{workspace_tool}} --filter <package> test`
- Affected packages only: `{{workspace_tool}} --filter "...[origin/main]" test`
Test only what you changed and what depends on it; the full suite is for CI.
## Rules that apply everywhere
- A package may import another only through its public entry point, never a deep path.
- Changing a shared package means checking every app that uses it.
- One concern per pull request; do not mix a refactor with a feature.
## Do not
- Edit lockfiles by hand.
- Change CI files under `.github/` unless asked.
CLAUDE.md
# acme-platform
Monorepo managed with pnpm workspaces.
## Layout
- `apps/`: deployable apps. `packages/`: shared libraries.
- Each app or package has its own `CLAUDE.md` with its commands; read it before working there.
## Commands (from the repo root)
- Install everything: `pnpm install`
- Run one package's tests: `pnpm --filter <package> test`
- Affected packages only: `pnpm --filter "...[origin/main]" test`
Test only what you changed and what depends on it; the full suite is for CI.
## Rules that apply everywhere
- A package may import another only through its public entry point, never a deep path.
- Changing a shared package means checking every app that uses it.
- One concern per pull request; do not mix a refactor with a feature.
## Do not
- Edit lockfiles by hand.
- Change CI files under `.github/` unless asked.
packages/{{package}}/CLAUDE.md
# {{package}}
What this package does in one sentence.
## Commands
- Test: `{{workspace_tool}} --filter {{package}} test`
## Notes
- Public entry point: `src/index.ts`. Everything else is internal.
packages/ui-kit/CLAUDE.md
# ui-kit
What this package does in one sentence.
## Commands
- Test: `pnpm --filter ui-kit test`
## Notes
- Public entry point: `src/index.ts`. Everything else is internal.