CLAUDE.md cho dự án Node.js và TypeScript
Bộ chỉ dẫn ngắn cho Claude về lệnh build, test, lint và quy ước code của một dự án TypeScript. Thay các chỗ {{…}} bằng lệnh và thư mục thật của bạn rồi xóa mục không dùng.
Đã thử với Claude Code 2.1.329
Chỗ cần điền
{{project_name}}Tên dự ánví dụcheckout-api{{package_manager}}Trình quản lý gói bạn dùng (npm, pnpm, yarn hoặc bun)ví dụpnpm{{source_dir}}Thư mục chứa mã nguồnví dụsrc
CLAUDE.md
# {{project_name}}
TypeScript on Node.js. Package manager: {{package_manager}} (never mix in another one).
## Commands
- Install: `{{package_manager}} install`
- Type check: `{{package_manager}} run typecheck`
- Test all: `{{package_manager}} test`
- Test one file: `{{package_manager}} test -- path/to/file.test.ts`
- Lint and format: `{{package_manager}} run lint --fix`
Run the type check and the tests for the files you touched before saying a task is done.
## Layout
- Source lives in `{{source_dir}}/`; tests sit next to the code as `*.test.ts`.
- Shared types go in `{{source_dir}}/types/`. Do not redefine a type that already exists there.
## Conventions
- `strict` TypeScript: no `any`, no `@ts-ignore`. Use `unknown` and narrow it.
- Named exports only; no default exports.
- Use `async`/`await`, never raw `.then()` chains.
- Errors: throw `Error` subclasses with a clear message; never swallow an error silently.
## Do not
- Edit generated files under `dist/` or anything ignored by git.
- Add a dependency without saying why in your reply.
- Commit `.env` files or print secrets.
CLAUDE.md
# checkout-api
TypeScript on Node.js. Package manager: pnpm (never mix in another one).
## Commands
- Install: `pnpm install`
- Type check: `pnpm run typecheck`
- Test all: `pnpm test`
- Test one file: `pnpm test -- path/to/file.test.ts`
- Lint and format: `pnpm run lint --fix`
Run the type check and the tests for the files you touched before saying a task is done.
## Layout
- Source lives in `src/`; tests sit next to the code as `*.test.ts`.
- Shared types go in `src/types/`. Do not redefine a type that already exists there.
## Conventions
- `strict` TypeScript: no `any`, no `@ts-ignore`. Use `unknown` and narrow it.
- Named exports only; no default exports.
- Use `async`/`await`, never raw `.then()` chains.
- Errors: throw `Error` subclasses with a clear message; never swallow an error silently.
## Do not
- Edit generated files under `dist/` or anything ignored by git.
- Add a dependency without saying why in your reply.
- Commit `.env` files or print secrets.