CLAUDE.md

CLAUDE.md cho dự án Python

Chỉ dẫn cho Claude về môi trường ảo, cách chạy test, lint và quy ước kiểu dữ liệu trong một dự án Python. Đổi lệnh cho đúng công cụ bạn dùng (uv, pip, poetry).

Đã thử với Claude Code 2.1.329

Chỗ cần điền

  • {{project_name}}Tên dự ánví dụ billing-service
  • {{python_version}}Phiên bản Python dự án yêu cầuví dụ 3.12
  • {{package_dir}}Thư mục package chínhví dụ billing
CLAUDE.md
# {{project_name}}

Python {{python_version}}, managed with uv. Always run tools through `uv run` so the
project's virtual environment is used.

## Commands
- Install: `uv sync`
- Test all: `uv run pytest`
- Test one: `uv run pytest tests/test_x.py::test_name -x`
- Lint and format: `uv run ruff check --fix . && uv run ruff format .`
- Types: `uv run mypy {{package_dir}}`

Before saying a task is done, run ruff, mypy and the tests that cover what you changed.

## Layout
- Code: `{{package_dir}}/`. Tests: `tests/`, mirroring the package structure.
- Configuration comes from environment variables read in `{{package_dir}}/config.py` only.

## Conventions
- Type hints on every public function; no bare `except:`.
- Prefer dataclasses or pydantic models over loose dicts.
- Use `logging`, not `print`, outside scripts.
- New dependencies go in `pyproject.toml` via `uv add`; explain why in your reply.

## Do not
- Touch `.venv/`, migrations that already ran, or files listed in `.gitignore`.
- Commit `.env` or print secret values.

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.