C.W.K.
Stream
Lesson 03 of 13 · published

CLAUDE.md — Project Memory

~18 min · claude-md, memory, context, init

Level 0🌱 입문자
0 XP0/70 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

에이전트가 일 시작 전에 읽는 파일

CLAUDE.md 는 매 세션 시작 시 Claude Code 가 자동으로 로드하는 markdown 파일이야. 안 입력해도 되는 첫 메시지로 봐. 프로젝트의 장기 진실 — stack, architecture, command, convention, 빡빡한 제약 — 은 chat 이 아니라 여기 있어야 해.

계층: ~/.claude/CLAUDE.md (글로벌 선호도) → repo-root CLAUDE.md (팀 표준) → src/.../CLAUDE.md (서브디렉토리별 룰). 매칭되는 파일 전부 system prompt 에 머지되고, cwd 에 가까운 게 충돌 시 우선. 그래서 payments 서비스에 나머지 repo 보다 빡빡한 룰을 줄 수 있는 거야 — copy-paste 없이.

/init 으로 부트스트랩: project 스캔하고 package.json / pyproject.toml / 프레임워크 설정 읽어서 시작 CLAUDE.md 초안 만들어줘. 그 다음 iterate. mid-session 에 메시지 앞에 # 붙이면 Claude 가 적절한 CLAUDE.md 에 그 사실 추가 — 에디터로 context 전환할 필요 없어.

Code

A CLAUDE.md that actually pays for itself·markdown
# myproject — CLAUDE.md

## What this is
TypeScript REST API on Node 22 + Postgres 16, deployed via Fly.io.
Frontend lives in ../myapp-frontend (separate repo).

## Standard commands
npm run dev          # localhost:3000, hot reload
npm test             # vitest
npm run db:migrate   # prisma migrate dev
npm run lint         # eslint + prettier

## Architecture
- src/routes/        Express handlers (one per resource)
- src/services/      business logic (no DB calls here)
- src/repositories/  Prisma queries (the only place DB is touched)
- src/middleware/    auth, validation, error envelope

## Conventions
- TS strict, no `any` (use `unknown` and narrow)
- async/await only, never callbacks
- Validate all inputs with Zod before processing
- Response envelope: { data, error, meta }

## Do not
- Modify schema.prisma without a migration
- Commit .env (use direnv)
- Use console.log in app code (use src/lib/logger.ts)
Subdirectory rules layered on top·markdown
# src/payments/CLAUDE.md

## Payments — additional rules
This service handles PCI-DSS regulated data. Treat everything here
as SENSITIVE.

- NEVER log card numbers, CVVs, or full PANs (debug code included)
- All encryption goes through src/lib/crypto.ts (AES-256-GCM)
- All Stripe calls go through src/clients/stripe.ts
- Rate limiting is MANDATORY on every public payment endpoint

## Verify before committing
npm run pci-check

External links

Exercise

네 repo 에서 /init 돌려서 CLAUDE.md 초안 만들어. 비판적으로 읽고, 틀린 거 prune, 진짜 배운 "하지 마" 룰 2개 추가. 커밋. fresh Claude Code 세션 켜서 입력 안 해도 되는 prompt 가 몇 개인지 카운트.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.