023. .claude 디렉터리 살펴보기 (Explore the .claude directory)
- 원문: English
- 위치: Getting started › Core concepts › Explore the .claude directory
한 줄 요약
Claude Code는 프로젝트의 .claude/(팀 공유, git 커밋)와 홈의 ~/.claude/(개인, 모든 프로젝트 적용)에서 지시·설정·스킬·서브에이전트·메모리를 읽고, ~/.claude/에는 대화 기록 등 평문 애플리케이션 데이터도 씁니다.
쉽게 말하면
대부분은 CLAUDE.md와 settings.json만 고치면 됩니다. 나머지(스킬, 규칙, 서브에이전트 등)는 필요할 때 추가합니다. 대화 기록은 기본 30일 후 자동 삭제되며 암호화되지 않습니다.
- Windows에서
~/.claude는%USERPROFILE%\.claude입니다. CLAUDE_CONFIG_DIR를 설정하면 모든~/.claude경로와~/.claude.json이 그 아래로 이동합니다.
핵심 내용
프로젝트 파일 (저장소)
| 파일 | 로드 시점 | 역할 |
|---|---|---|
CLAUDE.md | 세션 시작 | 프로젝트 지시(규칙, 명령, 구조). AGENTS.md로 대체 가능 |
CLAUDE.local.md | 세션 시작(CLAUDE.md와 함께) | 개인 선호. 직접 만들고 .gitignore에 추가 |
.mcp.json | 세션 시작(승인된 서버) | 팀 공유 MCP 서버. 개인 서버는 ~/.claude.json |
.worktreeinclude | worktree 생성 시(--worktree, EnterWorktree, isolation: worktree) | 새 worktree로 복사할 gitignore 파일(.env 등). .gitignore 문법, gitignore된 파일만 복사 |
.claude/settings.json | 세션 시작(대부분 실행 중 반영) | 권한·훅 등 강제되는 설정 |
.claude/settings.local.json | 세션 시작 | 프로젝트 개인 설정. Claude Code가 저장하면 gitignore 처리 |
.claude/rules/ | paths: 없으면 시작 시, 있으면 일치 파일 읽기/쓰기 시 | 주제별 지시(강제 아님) |
.claude/skills/<name>/SKILL.md | /skill-name 또는 자동 매칭 | 스킬. disable-model-invocation: true(Claude 자동 호출 금지), user-invocable: false(Claude만 호출) |
.claude/commands/*.md | /command-name | 단일 파일 명령(deploy.md → /deploy). 새로 만들 땐 스킬 권장 |
.claude/output-styles/ | 터미널 시작 시(수정 후 재시작 필요) | 출력 스타일 |
.claude/agents/*.md | 호출 시 별도 컨텍스트 | 서브에이전트(name, description 필수) |
.claude/workflows/*.js | 워크플로 켜져 있으면 시작 시 | 동적 워크플로, /<name>으로 실행. /workflows에서 저장 |
.claude/agent-memory/<agent>/MEMORY.md | 서브에이전트 실행 시 처음 200줄(최대 25KB) | memory: project 서브에이전트 전용 메모리 |
전역 파일 (홈)
| 파일 | 역할 |
|---|---|
~/.claude.json | 계정 정보, 프로젝트별 신뢰 결정, 개인 MCP 서버, UI 토글. /config 변경·폴더 신뢰 시 Claude Code가 다시 씀 |
~/.claude/CLAUDE.md | 모든 프로젝트 공통 지시. ⚠️ 프로젝트 CLAUDE.md와 충돌하면 어느 쪽을 따를지 보장 안 됨 |
~/.claude/settings.json | 모든 프로젝트 공통 설정(허용 규칙, 선호 모델, 알림 훅) |
~/.claude/keybindings.json | 단축키. /keybindings로 생성, 수정 시 즉시 반영 |
~/.claude/themes/*.json | 커스텀 테마(base + overrides). /theme, 선택 시 custom:<slug> 저장 |
~/.claude/projects/<project>/memory/MEMORY.md | 자동 메모리 인덱스. 처음 200줄(최대 25KB) 로드, 주제 파일은 필요 시 |
~/.claude/rules/, skills/, commands/, agents/, output-styles/, workflows/ | 프로젝트 버전과 같은 형식, 모든 프로젝트 적용 |
~/.claude/agent-memory/ | memory: user 서브에이전트 메모리(프로젝트 공통) |
- 같은 이름이면 프로젝트 쪽 출력 스타일·워크플로가 우선합니다.
- 기타:
managed-settings.json(OS별 시스템 경로, 조직 강제 설정),~/.claude/plugins(설치 플러그인,installed_plugins.json, 동기화 플러그인은plugins/synced/). 마켓플레이스command소스는 v2.1.229 이상 필요.
설정 우선순위
~/.claude/settings.json<.claude/settings.json<.claude/settings.local.json<--settings플래그 < managed settings- 단일 값(
model등)은 가장 높은 값, 대부분의 목록(permissions.allow등)은 병합됩니다. --permission-mode같은 CLI 플래그는 해당 세션에서settings.json보다 우선. 일부 환경 변수는 설정보다 우선(변수마다 다름). 자세히는 설정.- 📝
CLAUDE.md·rules는 지침이고,settings.json의 권한·훅은 Claude의 판단과 무관하게 강제됩니다.
무엇을 어디에
| 하고 싶은 일 | 파일 |
|---|---|
| 프로젝트 규칙 | CLAUDE.md |
| 도구 호출 허용/차단 | settings.json permissions 또는 hooks |
| 도구 호출 전후 스크립트 | settings.json hooks |
| 세션 환경 변수 | settings.json env |
| 개인 설정을 git에서 제외 | settings.local.json |
/name 명령 | skills/<name>/SKILL.md |
| 전문 서브에이전트 | agents/*.md |
| 다수 서브에이전트 스크립트 | workflows/*.js |
| MCP 연결 | .mcp.json(프로젝트만) |
| 응답 형식 | output-styles/*.md |
프런트매터 필드
| 파일 | 필드 |
|---|---|
SKILL.md | name, description, when_to_use, argument-hint, arguments, disable-model-invocation, user-invocable, allowed-tools, disallowed-tools, model, effort, context, agent, background, hooks, paths, shell, metadata, license, compatibility |
commands/*.md | 스킬 필드에서 name, paths 제외 |
agents/*.md | name, description, tools, disallowedTools, model, permissionMode, maxTurns, autoCompactWindow, skills, mcpServers, hooks, memory, background, effort, isolation, color, initialPrompt, omitClaudeMd, experimental |
output-styles/*.md | name, description, keep-coding-instructions, force-for-plugin |
rules/*.md | paths |
설정이 반영되지 않으면 설정 디버그를 참고합니다.
애플리케이션 데이터
⚠️ 모두 평문입니다. 도구를 거친 모든 것(파일 내용, 명령 출력, 붙여 넣은 텍스트)과 시스템 프롬프트·도구 정의·요청 파라미터·로드된 CLAUDE.md까지 기록에 남을 수 있습니다.
자동 삭제 대상 (cleanupPeriodDays 기준, 기본 30일, 최소 1, 0은 검증 에러)
~/.claude/ 아래 | 내용 |
|---|---|
projects/<project>/<session>.jsonl | 대화 기록 |
projects/<project>/<session>/subagents/, tool-results/, mcp-tasks/ | 서브에이전트 기록, 큰 도구 출력, MCP 작업 상태 |
file-history/<session>/ | 체크포인트용 수정 전 스냅샷(최근 100개 체크포인트) |
plans/, debug/, paste-cache/, session-env/, tasks/, shell-snapshots/ | 계획 파일, 디버그 로그, 큰 붙여넣기 등 |
uploads/<session>/ | Remote Control 세션에 웹/모바일에서 첨부한 파일 |
backups/ | ~/.claude.json 이전 버전(최신 5개 유지) |
feedback/drafts/ | 초안 피드백(최대 10개, cleanupPeriodDays와 30일 중 짧은 쪽) |
usage-data/ | /insights 보고서 |
todos/, statsig/, logs/ | 구버전 레거시(더 이상 안 씀) |
- 고아(orphaned) worktree 자동 삭제에도 같은 기한이 적용됩니다.
- 자동 메모리(
projects/<project>/memory/)는 삭제하지 않습니다(보존 기간 내내 비어 있을 때만 디렉터리 제거). ⚠️ v2.1.228 이전에는 메모리 하위 폴더가 삭제될 수 있었습니다. - Desktop/Cowork 기록은 나이와 무관하게 보존 →
desktopSessionCleanupPeriodDays로 제한(v2.1.248 이상). managed settings가cleanupPeriodDays를 정하거나 HIPAA 구성이면cleanupPeriodDays로 삭제. - 삭제를 건너뛰는 경우:
claude -p --bare, 보존 기간을 안전하게 판단 못 할 때(retention_sweep이벤트,/status경고). managedcleanupPeriodDays가 있으면 하위 설정 파일 오류와 무관하게 실행됩니다.
직접 지울 때까지 유지: history.jsonl(입력 프롬프트, ↑·Ctrl+R·! 완성), stats-cache.json(/usage), remote-settings.json(서버 관리 설정 캐시, 시작 시·매시간 확인, 로그아웃 시 삭제), remote-settings-consent.json, cache/changelog.md, policy-limits.json
지우면 안 되는 상태 파일: .credentials.json(로그인), agent-memory/, jobs/·daemon/(백그라운드 세션), 그리고 ~/.claude.json, ~/.claude/settings.json, ~/.claude/plugins/
스크래치패드(Scratchpad)
- 세션별 임시 작업 폴더. Claude가
/tmp대신 쓰며 권한 확인 없이 생성·수정·읽기 가능합니다. - 경로: macOS
/private/tmp/claude-<uid>/<project>/<session-id>/scratchpad/, Linux/tmp/claude-<uid>/...(또는$TMPDIR), Windows%TEMP%\claude\<project>\<session-id>\scratchpad\.CLAUDE_CODE_TMPDIR로 변경. 훅에는scratchpad_dir로 전달. - 조건: claude.ai 계정 로그인(API 키 아님) + Anthropic API 사용(Bedrock/Agent Platform/Foundry 아님) +
enableArtifact가false아님 - ⚠️ OS가 임시 폴더를 비울 수 있으니 보존할 파일은 프로젝트로 옮기라고 요청하세요.
평문 노출 줄이기 / 데이터 삭제
cleanupPeriodDays낮추기,desktopSessionCleanupPeriodDays설정CLAUDE_CODE_SKIP_PROMPT_HISTORY환경 변수: 모든 모드에서 기록·프롬프트 이력 저장 안 함. 비대화형은-p --no-session-persistence, TypeScript SDK는persistSession: false(Python SDK는 없음)- 권한 규칙으로 자격 증명 파일 읽기 거부
claude purge(v2.1.288 이전은claude project purge): 한 프로젝트의 기록·자동 메모리·tasks/·debug/·file-history/·해당history.jsonl줄·~/.claude.json항목 삭제
claude purge <project-path> --dry-run # 계획만 출력
claude purge <project-path> # 확인 후 삭제 [y/N]
claude purge <project-path> --yes # 스크립트용, 확인 생략
claude purge --all # 전체 프로젝트(history.jsonl 통째 삭제)
claude purge -i <project-path> # 항목별 확인
- ⚠️
purge는 임시 폴더의 이미지·스크래치패드,shell-snapshots/,backups/는 지우지 않습니다./heapdump로 만든.heapsnapshot에는 전체 대화와 자격 증명이 담기므로 직접 삭제해야 합니다.
실무 관점
- 보안: 기록이 암호화되지 않고 OS 파일 권한만으로 보호됩니다. 공용 머신·VDI 환경이면
cleanupPeriodDays를 managed settings로 짧게 강제하고,.env·자격 증명 읽기를 권한 규칙으로 막는 것을 검토하세요. - 커밋 기준:
CLAUDE.md,.claude/settings.json,.mcp.json, skills/agents/rules는 커밋하고settings.local.json,CLAUDE.local.md는 제외합니다. .worktreeinclude가 없으면 worktree에서.env가 빠져 실행이 실패할 수 있습니다. 반대로 비밀 파일을 여러 worktree에 복제하는 것이기도 하니 범위를 최소화하세요.- 감사 대응:
retention_sweep이벤트로 조직 내 머신이 정한 보존 기간대로 삭제하는지 확인할 수 있습니다(모니터링).