Claude Code 컨텍스트 관리 실전 가이드: /context, /compact, CLAUDE.md 활용법
Claude Code 세션을 안정적으로 유지하기 위한 컨텍스트 관리, /compact, /memory, Obsidian 분업 가이드.
Claude Code에서 긴 작업이 흐려지는 이유는 대개 오래된 로그와 파일 읽기 결과가 컨텍스트를 채우기 때문입니다. 컨텍스트 관리는 지금 필요한 정보와 나중에 읽을 정보를 나누는 습관입니다.
/context는 현재 사용량을 보여주고, /compact는 대화를 요약하며, /clear는 새 출발을 만들고, /memory는 로드된 메모리 파일을 확인합니다.
실무 목표는 긴 리서치와 오래된 로그를 활성 컨텍스트 밖에 두고, 메인 세션을 좁고 선명하게 유지하는 것입니다.
Think of the context window as the working desk
컨텍스트 윈도우에는 대화 기록, 파일 읽기 결과, 도구 출력, CLAUDE.md, auto memory, rules, skills가 들어갑니다. 창이 가득 차면 중요한 제약이 오래된 출력과 경쟁합니다.
| What enters context | Why it gets heavy | Practical response |
|---|---|---|
| Conversation | Long discussion and side quests | Cut by task boundary |
| Files | Reading huge files whole | Search first, then read narrow ranges |
| Tool output | Long logs and repeated failures | Summarize into a note |
| Memory | Oversized CLAUDE.md | Move details to rules or docs |
Use /context, /compact, /clear, and /memory differently
/context는 현재 사용량을 보여줍니다. /compact는 요약 후 같은 세션을 이어갑니다. /clear는 실제 작업 경계에서 새로 시작할 때 씁니다. /memory는 CLAUDE.md와 auto memory를 확인합니다.
/context all
/compact focus on files changed, failing tests, and next command
/clear
/memory
Set a context budget before the task
작업 시작 시 objective, scope, out-of-scope, 완료 기준, 검증 명령을 적습니다. 전체 저장소를 읽히기보다 rg 검색과 선택된 파일로 시작합니다.
# narrow discovery before asking Claude to read files
rg -n "getUserById|User not found|auth middleware" src tests
git diff --stat
npm test -- --runInBand
Copy-paste runbook for long work
이 runbook은 refactor, security fix, 긴 article, conversion experiment에 유용합니다. 세션을 작게 유지하고 다음 단계에 필요한 receipt를 남깁니다.
## Task brief
- Objective:
- In scope:
- Out of scope:
- Files likely involved:
- Done when:
- Verification commands:
## Handoff receipt
- Changed files:
- Commands run:
- Result:
- Remaining risk:
- Next best action:
What survives compaction
/compact 후 root CLAUDE.md와 auto memory는 돌아옵니다. nested CLAUDE.md와 path-scoped rules는 matching file을 다시 읽어야 돌아옵니다. 지속 규칙은 채팅에만 두지 않습니다.
# CLAUDE.md
## Compact Instructions
- Keep the current business objective and monetization hypothesis.
- Keep changed files, verification commands, deploy state, and blockers.
- Drop raw logs unless a line explains the root cause.
- If article work is in progress, preserve slug, locale list, and quality gaps.
Three use cases: code, content, conversion
- 대규모 refactor에서는 넓은 조사를 subagent나 별도 세션에 맡기고, main context에는 decision summary만 남깁니다.
- Publishing workflow에서는 raw research는 Obsidian, editorial rules는 CLAUDE.md, final MDX는 repository에 둡니다.
- Conversion 개선에서는 metric, hypothesis, change, verification result를 작은 ticket처럼 남깁니다.
Common failures and fixes
- /compact를 전체 transcript backup으로 생각하지 마세요. summary이므로 지속 제약은 파일에 둡니다.
- 거대한 discovery 직후 바로 구현하지 말고, 먼저 short note로 압축합니다.
- Auto memory를 shared team docs로 보지 마세요. 공유 규칙은 committed CLAUDE.md에 둡니다.
How Obsidian fits in
This workflow works with CLAUDE.md best practices, token optimization, prompt engineering, and Obsidian workflow. Team setup can start from consultation page.
| Place | Best information |
|---|---|
| CLAUDE.md | Short rules needed every session |
| Obsidian | Long research, hypotheses, article ideas |
| MDX / docs | Published content, specs, handoff notes |
| Auto memory | Local preferences and repeated learnings |
What was verified
공식 context window, commands, memory 문서를 바탕으로 /context, /compact, /memory, /usage 중심 workflow로 업데이트했습니다. Official references: context window, commands, memory, and common workflows.
무료 PDF: Claude Code 치트시트
이메일을 입력하면 명령, 리뷰 습관, 안전한 워크플로를 정리한 PDF를 받을 수 있습니다.
개인정보를 안전하게 관리하며 스팸을 보내지 않습니다.
작성자 소개
Masa
Claude Code 실무 워크플로와 팀 도입을 검증하는 엔지니어입니다.
관련 글
Claude Code Permission Receipt Pattern: 권한, 증거, 롤백을 남기는 운영
Claude Code 작업마다 허용 범위, 승인 경계, 검증 명령, 롤백 메모, Gumroad와 상담 CTA 확인을 남기는 permission receipt 패턴입니다.
Claude Code/Codex 안전 Agent Harness 설계: 권한, 검증, 롤백
Claude Code와 Codex를 안전하게 운영하기 위한 Agent Harness를 권한 정책, 실행 계획, 검증, 복구 계층으로 설계합니다.
Claude Code 서브에이전트 실전 가이드: 기사와 코드 작업을 안전하게 위임하기
Claude Code 서브에이전트로 기사와 코드 작업을 안전하게 나누는 방법. 위임 규칙, 프롬프트, 실패 사례를 정리합니다.