CLAUDE.md

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.
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.

Bài học liên quan

Gõ để tìm trong tra cứu, mẫu cấu hình và bài học. Không dấu cũng được.