효과적인 CLAUDE.md 파일 작성하기

Claude Code로 배우는 Software Development

Dani Zysman

AI Curriculum Manager @ DataCamp

CLAUDE.md 모범 사례

  • /init으로 시작한 다음 반복 개선하세요
    • Claude가 실수할 때 컨텍스트를 추가하세요
    • 컨벤션 변경 사항을 포함하세요
  • 목표: 프로젝트와 함께 발전하는 살아있는 문서
Claude Code로 배우는 Software Development

지금까지의 프로젝트

music-analytics-api/
  app.py           # Application entry point
  routes.py        # API endpoints
  models.py        # Artist/Album models
  analytics.py     # Statistics functions
  middleware.py    # Request logging
  config.py        # Session settings
  CLAUDE.md        # <- Project memory file
Claude Code로 배우는 Software Development

CLAUDE.md에 포함할 것과 제외할 것

recraft: CLAUDE.md에 포함할 내용과 제외할 내용

규칙: 포스트잇 한 장보다 길면 CLAUDE.md에 넣지 마세요.

Claude Code로 배우는 Software Development

CLAUDE.md 반복 개선하기

> Add error handling to the /artists endpoint.
Done. I've added error handling to /artists (routes.py:9-19):
- Try-except block wrapping retrieval and serialization
- AttributeError handler if the data store isn't initialized
- General exception handler returning error details with 500 status

return jsonify({'error': f'Failed to retrieve artists: {str(e)}'}), 500
> Don't expose exception details to users, that's a security risk. Log internally 
and return a generic message.  Update CLAUDE.md.
Updated /artists to log errors internally and return a 
generic 500 message. CLAUDE.md updated with the convention: 
never expose exception details in responses.
Claude Code로 배우는 Software Development

적절한 CLAUDE.md vs. 방대한 CLAUDE.md

지나치게 방대한 버전 (200줄 이상)

# Inventory API
This is an Inventory Management 
API built with Flask...

## Full Source Code
### routes.py
from flask import jsonify...
[entire file pasted]

### models.py
[entire file pasted]

## API Documentation
GET /items returns...

적절한 버전 (15줄)

# Inventory API
Flask REST API for inventory.

## Commands
- Run: flask run --port 5001
- Test: pytest tests/

## Conventions
- Use type hints
- Keep routes thin
Claude Code로 배우는 Software Development

파일 참조 - @ 사용하기

> @routes.py what endpoints does this API have?
API Endpoints (6 GET routes)

Artists
- GET /artists              All artists
- GET /artists/<id>         Single artist by ID
- GET /artists/<id>/albums  Albums for an artist
Albums
- GET /albums               All albums
- GET /stats/albums         Album popularity statistics
- GET /stats/average-tracks Average track count per album

All endpoints return JSON.
Claude Code로 배우는 Software Development

CLAUDE.md와 @ 함께 사용하기

# CLAUDE.md - Music Analytics API
A Flask-based REST API for music data analytics, providing endpoints for artists,
albums, and statistics.
...

## Key Files @routes.py - API endpoint definition @models.py - Artist and Album data models with in-memory store ...

CLAUDE.md는 지속적인 컨텍스트를 제공합니다. @를 사용하면 Claude가 항상 핵심 파일을 파악할 수 있습니다.

Claude Code로 배우는 Software Development

컨텍스트의 세 가지 수준

CLAUDE.md 컨텍스트의 세 가지 수준

Claude Code로 배우는 Software Development

언제 무엇을 사용할까요

  • CLAUDE.md (프로젝트, 공유)

    • 테스트 명령어, 코딩 컨벤션, 프로젝트 구조
  • CLAUDE.local.md (프로젝트, 개인)

    • 로컬 경로, API 키, 개인 워크플로 설정
  • ~/.claude/CLAUDE.md (전역, 개인)

    • 모든 프로젝트에 적용되는 스타일 설정
    • 항상 원하는 기본 동작
Claude Code로 배우는 Software Development

1장 요약

  • /init과CLAUDE.md → 지속적인 프로젝트 컨텍스트
  • Shift+Tab 또는 /plan → Plan 모드 전환
  • think ... ultrathink → 심층 추론 (5단계)
Claude Code로 배우는 Software Development

연습해 봅시다!

Claude Code로 배우는 Software Development

Preparing Video For Download...