CLAUDE.md

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.

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.