Claude.md 파일 최적화

 

CLAUDE.md 파일의 역할

Claude Code는 세션 시작 시 자동으로 CLAUDE.md 파일을 읽어 컨텍스트에 포함시킵니다. 이를 통해 프로젝트의 핵심 정보를 Claude에게 영구적으로 "학습"시킬 수 있습니다.

핵심 최적화 전략

1. 계층적 구조 활용

Claude는 CLAUDE.md 파일을 계층적으로 읽습니다: 홈 디렉토리(~/.claude/CLAUDE.md) → 프로젝트 루트 → 개별 디렉토리 순으로, 가장 구체적인 설정이 우선합니다.

권장 구조:

  • ~/.claude/CLAUDE.md - 개인 코딩 스타일, 일반 규칙
  • 프로젝트 루트 CLAUDE.md - 프로젝트 아키텍처, 라이브러리, 규칙
  • 하위 디렉토리 - 모듈별 특수 규칙

2. 명확한 컨텍스트 제공

포함해야 할 핵심 내용:

  • 프로젝트 구조: 주요 디렉토리와 파일 역할
  • 기술 스택: 사용 중인 언어, 프레임워크, 라이브러리
  • 코딩 규칙: 네이밍, 포맷팅, 아키텍처 패턴
  • 명령어: 빌드, 테스트, 린트 등 주요 명령어
  • 금지 사항: 읽지 말아야 할 디렉토리, 피해야 할 패턴

3. 토큰 최적화

CLAUDE.md를 활용해 Claude가 읽을 수 있는 파일과 금지된 디렉토리를 명시하세요. 이렇게 하면 불필요한 코드로 인한 컨텍스트 소비를 방지할 수 있습니다.

## File Reading Guidelines
- Always check: src/, tests/, docs/
- Never read: node_modules/, .git/, build/, dist/
- For database queries, check schema.sql first

4. 구체적인 예시 포함

좋은 예시(✅)와 나쁜 예시(❌)를 포함하여 원하는 패턴을 명확히 하세요.

## Code Patterns
✅ Good: Reuse existing DAO functions
✅ Good: Always run type checks before committing

❌ Bad: Create redundant DAO functions
❌ Bad: Uncomment test blocks automatically

5. 반복적 개선

Claude가 실수할 때마다 CLAUDE.md를 업데이트하세요. 이는 AI 어시스턴트를 반복적으로 훈련시키는 것과 같습니다.

실전 예시

# CLAUDE.md

## Project Overview
Drug discovery pipeline using Python/PyTorch for molecular property prediction.

## Architecture
- `models/`: PyTorch neural network architectures
- `data/`: Dataset loaders and preprocessing
- `pipeline/`: Training and inference workflows
- `notebooks/`: Jupyter notebooks for analysis

## Key Commands
- Build: `python setup.py build`
- Test: `pytest tests/`
- Lint: `flake8 . && black --check .`
- Type check: `mypy src/`

## Coding Standards
- Always use type hints
- Document all functions with docstrings
- Follow PEP 8 style guide
- Never commit without running tests

## Dependencies
- PyTorch for deep learning
- RDKit for molecular featurization
- scikit-learn for ML utilities

## File Reading Rules
- Always read: requirements.txt, README.md, models/
- Check before editing: pipeline/, data/
- Never modify: .venv/, __pycache__/, *.egg-info/

## Common Tasks
When training models:
1. Load data from data/processed/
2. Use models/base.py as template
3. Log metrics to wandb
4. Save checkpoints to checkpoints/

## Specific Guidelines
- Timeout for large downloads: 300s
- Never uncomment test blocks unless explicitly asked
- Always validate molecular SMILES strings before processing

추가 팁

  1. Plan Mode 활용: 복잡한 작업은 Plan Mode(Shift+Tab 두 번)로 먼저 계획을 수립하세요.

  2. Custom Commands: .claude/commands/ 폴더에 자주 쓰는 워크플로우를 저장하여 슬래시 커맨드로 활용하세요.

  3. 세션 관리: 한 세션은 하나의 프로젝트나 기능에 집중시켜 컨텍스트를 관련성 있게 유지하세요.

  4. 정기적 업데이트: 프로젝트가 진화함에 따라 CLAUDE.md도 함께 업데이트하세요.

Claude Code를 효과적으로 사용하는 핵심은 명확한 컨텍스트 제공과 지속적인 가이드입니다. CLAUDE.md는 단순한 설정 파일이 아니라, Claude와 협업하기 위한 "온보딩 문서"로 생각하시면 됩니다.

댓글

이 블로그의 인기 게시물

Claude AI의 생명과학 적용: 최신 자료 종합 리뷰

클로드 코드 빠른 시작

Claude Code를 사용할 때 유용한 명령어와 팁