짧은 질문 하나에도 Claude Code의 토큰 사용량이 높은 이유와 개인이 비용을 줄이는 방법을 묻는 글입니다. Claude Code는 메시지를 보낼 때마다 시스템 프롬프트, 프로젝트 컨텍스트, 전체 대화 이력을 다시 전송하므로 비용은 컨텍스트 크기에 비례하고 실제 단가는 캐시 적중률이 정합니다. 작업을 바꿀 때마다 /clear로 새로 시작하고 CLAUDE.md를 200줄 이하로 유지하며 모델과 effort를 작업에 맞추고 도구 오버헤드를 /context로 점검하면 개인이 통제할 수 있는 낭비 경로는 대부분 닫힙니다.This post asks why Claude Code token usage is high even for a single short question and how an individual can bring the cost down. Claude Code resends the system prompt, the project context, and the entire conversation history with every message, so cost is proportional to context size and the price you actually pay is set by the cache hit rate. Starting fresh with /clear every time you switch tasks, keeping CLAUDE.md to 200 lines or fewer, matching the model and effort to the task, and checking tool overhead with /context closes most of the paths to waste that an individual can control.
Claude Code를 팀에 도입하고 나면 비슷한 질문들이 찾아옵니다. 짧은 한 문장의 질문만 했는데 토큰 사용량이 왜 이렇게 높은지, 하루가 끝날 때쯤이면 세션이 왜 이렇게 무거워져 있는지 같은 의문입니다.
Claude Code는 메시지를 보낼 때마다 시스템 프롬프트, 프로젝트 컨텍스트, 지금까지의 전체 대화 이력을 다시 전송하고 비용은 그 컨텍스트 크기에 비례합니다. 그리고 실제로 지불하는 토큰 단가는 프롬프트 캐싱(prompt caching) 적중률이 정합니다. 이 글은 Claude Code 토큰 비용 최적화를 다루는 2부작 시리즈의 1부로, 비용 구조와 측정 도구, 그리고 개인이 바로 적용할 수 있는 세션 습관을 다룹니다. 캐시 경제학과 Amazon Bedrock을 포함한 조직 단위 비용 관리는 2부에서 이어집니다. 대상 독자는 Claude Code를 실무에서 사용해 본 분들이며 토큰과 기본 슬래시 명령 사용 경험은 전제하되 프롬프트 캐싱 같은 핵심 개념은 본문에서 정의합니다. 본문의 수치와 기본값은 Claude Code 공식 문서와 Amazon Bedrock 사용자 가이드의 2026년 8월 기준입니다.
01
모델은 요청 사이에 아무것도 기억하지 않습니다. 그래서 Claude Code는 메시지를 보낼 때마다 시스템 프롬프트, 프로젝트 컨텍스트, 지금까지의 모든 대화와 도구 결과 전체를 다시 전송합니다. 한 번의 턴(Turn) 안에서 Claude가 도구를 여러 번 사용하면 그때마다 또 한 번의 요청이 전송됩니다. 토큰 비용이 질문의 길이가 아니라 세션의 크기에 비례하는 이유입니다.
요청은 세 계층으로 이뤄지며 잘 변하지 않는 내용일수록 앞에 옵니다.
| 계층 | 내용 | 바뀌는 시점 |
|---|---|---|
| 시스템 프롬프트 | 코어 지시, 도구 정의, 출력 스타일 | 도구 정의 집합이 바뀌거나 Claude Code 업그레이드 시 |
| 프로젝트 컨텍스트 | CLAUDE.md, 자동 메모리, 스코프별 규칙 | 세션 시작, /clear 또는 /compact 이후 |
| 대화 | 사용자 메시지, 응답, 도구 결과 | 매 턴(Turn) |
표 1. 요청을 구성하는 세 계층
이 반복 전송을 감당할 수 있게 해 주는 장치가 프롬프트 캐싱입니다. 직전 요청과 동일한 프리픽스(prefix)는 재처리하는 대신 캐시에서 읽어오고 표준 입력 단가의 약 10%로 과금됩니다. 캐시를 새로 쓰는 비용은 표준보다 비싸지만 한 번뿐이고 이후 턴은 그 프리픽스를 계속 낮은 단가로 재사용합니다. 표의 TTL(Time To Live)은 캐시가 유지되는 시간입니다.
| 처리 경로 | 상대 단가(표준 입력 = 1.0배) |
|---|---|
| 캐시 쓰기(1시간 TTL) | 2.0배 |
| 캐시 쓰기(5분 TTL) | 1.25배 |
| 표준 입력 | 1.0배 |
| 캐시 읽기 | 약 0.1배 |
표 2. 처리 경로별 상대 단가. 캐시 쓰기 비용은 이후 턴의 할인을 얻기 위한 1회성 투자입니다
과금 방식은 접속 방법에 따라 달라집니다. 구독 플랜(Pro, Max, Team)은 달러 대신 사용량 한도를 소모하고 이 한도는 5시간 롤링 윈도우와 주간 윈도우 단위로 관리됩니다. Claude Console의 API 및 Claude Enterprise와 Amazon Bedrock 같은 클라우드 프로바이더는 토큰 단위로 과금됩니다.
원칙은 하나입니다. 비용은 컨텍스트 크기에 비례하고 실제로 지불하는 토큰 단가는 캐시 적중률이 정합니다. 이 글의 모든 전략은 이 두 가지 변수를 줄이는 방법입니다.
02
최적화는 측정에서 시작합니다. /usage는 인증 방식에 따라 보여주는 내용이 다릅니다. API 과금 사용자(Claude Enterprise)에게는 현재 세션의 토큰 통계와 추정 비용을 담은 Session 블록을, 구독자에게는 플랜 사용량 바와 최근 사용량의 어트리뷰션(소모 주체별 내역)을 보여줍니다. Skills, 서브에이전트, 플러그인, 개별 MCP 서버가 각각 전체의 몇 %를 차지하는지 확인할 수 있고 긴 컨텍스트나 캐시 미스처럼 최근 사용량의 10% 이상을 차지하는 행동 플래그도 여기에 함께 표시됩니다.
다음은 대표적인 출력 형태입니다. 표기는 버전에 따라 조금씩 다르지만 담기는 정보는 같습니다.
> /usage
# API 과금 사용자에게 표시되는 Session 블록
Session
Input 1,242,310 tokens (cache read 1,180,450 | cache write 38,220 | uncached 23,640)
Output 18,940 tokens
Est. cost $4.87
# 구독 사용자에게 표시되는 플랜 사용량과 어트리뷰션
Plan usage
Session (5h) ████████░░░░░░░░░░░░ 41% resets 18:00
Week (all) ███░░░░░░░░░░░░░░░░░ 16% resets Mon 09:00
Week (Opus) █░░░░░░░░░░░░░░░░░░░ 4%
Recent usage attribution
Subagents 28% | MCP: playwright 17% | Skills: pdf 6%
Behavior flags
Long context sessions 14% | Cache misses after breaks 12%참고: /usage의 달러 표시는 추정치입니다. Claude Code는 이 금액을 표준 정가 기준으로 로컬에서 계산합니다. 프로모션이나 계약 할인 단가가 반영되지 않으므로 실제 청구액과 다를 수 있습니다. 청구 기준 수치는 Claude Console의 Usage 페이지에서 확인합니다.
/context는 지금 컨텍스트를 무엇이 차지하는지 보여줍니다. MCP 도구 정의, CLAUDE.md, 대화 이력의 비중을 확인해서 어디를 줄일지 정합니다. 상태 표시줄(statusline)을 설정하면 컨텍스트 사용률과 함께 응답마다 돌아오는 cache_creation_input_tokens와 cache_read_input_tokens를 상시 표시할 수 있습니다.
> /context
claude-sonnet-5 | 96.0K / 1.0M tokens (10%)
System prompt 3.2K ( 0.3%)
System tools 12.8K ( 1.3%)
MCP tools 28.4K ( 2.8%) playwright, github 도구 정의
Memory files 4.1K ( 0.4%) CLAUDE.md, 자동 메모리
Messages 47.5K ( 4.8%) 대화 이력과 도구 결과
Free space 904.0K (90.4%)이 예시에서는 선로딩된 MCP 도구 정의가 대화 이력의 절반을 넘는 크기입니다. 이런 비중이 보이면 도구 오버헤드가 점검 대상입니다.
두 가지 캐시 지표를 읽는 법은 단순합니다. 읽기(read)가 쓰기(creation)보다 훨씬 크면 캐시가 잘 동작하는 상태입니다. 반대로 creation이 턴마다 높게 유지되면 프리픽스가 계속 바뀌고 있다는 신호이므로, 모델 전환이나 도구 구성 변경처럼 캐시를 무효화하는 행동이 없었는지 점검합니다. 무효화 행동의 전체 목록은 2부에서 다룹니다.
/insights는 토큰 수 대신 일하는 방식을 분석합니다. 같은 머신의 최근 세션을 최대 200개까지 살펴, 어떤 작업을 자주 반복하는지, 어느 지점에서 요청 의도가 잘못 전달됐는지 같은 작업 흐름의 마찰 지점을 HTML 리포트(~/.claude/usage-data/report.html)로 정리해 줍니다. 분석 자체도 플랜이나 API 사용량을 소모하므로 주기적으로 한 번씩 실행하는 정도가 적당합니다.
03
가성비가 높은 최적화 방법은 컨텍스트를 처음부터 만들지 않는 것입니다. 무관한 작업으로 넘어갈 때는 /clear로 새로 시작합니다. 추가 비용이 없고 이전 이력이 다음 요청에 포함되지 않습니다. 세션을 나중에 찾아야 하면 /rename으로 이름을 붙인 뒤 비우고 필요할 때 /resume으로 돌아옵니다.
같은 작업을 이어가면서 컨텍스트만 줄여야 하면 /compact가 이력을 요약으로 교체합니다. /compact Focus on code samples and API usage처럼 보존할 내용을 지시할 수 있고 매번 같은 지시를 사용한다면 CLAUDE.md에 상시 규칙으로 둡니다.
# Compact instructions
When you are using compact, please focus on test output and code changes컴팩션(compaction) 자체의 비용도 계산에 넣어야 합니다. 요약을 만드는 요청은 전체 대화를 프롬프트로 보내는 큰 요청입니다. 캐시가 유지되는 동안은 대부분 캐시 읽기로 처리되어 저렴하지만 캐시 수명이 지난 뒤(예를 들어 오래된 세션을 resume한 직후) 실행하면 전체를 재처리하는 가장 비싼 컴팩션이 됩니다. auto-compact가 작업 한가운데서 끼어들기 전에, 일이 일단락된 지점에서 직접 실행해야 시점을 통제할 수 있습니다.
방향이 틀렸을 때는 컴팩션 대신 /rewind를 사용합니다. 대화를 이전 턴으로 되돌리면 그 지점까지의 프리픽스는 이미 캐시에 있으므로 다음 요청이 그대로 캐시에 적중합니다. 새 요약을 만들어 캐시를 다시 쌓는 컴팩션보다 되돌리기가 훨씬 저렴합니다.
다음은 세 가지 명령의 선택 기준입니다.
| 상황 | 명령 | 비용과 캐시 영향 |
|---|---|---|
| 무관한 새 작업으로 전환 | /clear | 추가 비용 없음, 캐시를 처음부터 다시 쌓기 시작 |
| 같은 작업을 이어가는데 컨텍스트가 가득 참 | /compact | 요약 요청 1회 지불, 캐시가 만료되기 전에 실행 |
| 잘못된 방향에서 복구 | /rewind | 기존 캐시를 그대로 적중 |
표 3. 컨텍스트 전환 명령의 선택 기준. 셋 중 기존 캐시를 그대로 적중하는 것은 /rewind뿐입니다
auto-compact 윈도우는 기본값이 모델에 맞춰 자동으로 정해집니다. /autocompact 명령으로 윈도우 값을 설정하고(/autocompact auto는 모델 기본값 복귀) CLAUDE_CODE_AUTO_COMPACT_WINDOW 환경 변수로도 조정할 수 있습니다. 다만 윈도우를 낮추면 컴팩션이 잦아져서 요약 요청 비용이 누적되므로, 특별한 이유가 없으면 자동값을 둡니다. Sonnet 5는 기본값으로 약 967,000토큰에서 자동 컴팩션됩니다(다른 모델은 별도 문서화된 임계값이 없습니다).
CLAUDE.md는 세션 시작마다 로드되어 프로젝트 컨텍스트 계층에 상주합니다. 모든 턴이 이 비용을 지불하므로 200줄 이하로 유지하고 특정 워크플로우에만 필요한 상세 지시는 호출 시에만 로드되는 Skills로 옮깁니다.
주의: 프로젝트 루트와 사용자 레벨 CLAUDE.md는 세션 시작 시 한 번 읽혀 메모리에 유지됩니다. 세션 중에 파일을 고쳐도 캐시는 깨지지 않지만 변경도 반영되지 않습니다. 새 내용은 다음 /clear, /compact, 재시작 때 로드됩니다. 지시가 안 먹힌다고 같은 세션에서 파일을 반복 수정하며 재시도하는 것은 토큰만 낭비합니다.
04
모델 선택이 단가의 첫 결정입니다. 대부분의 코딩 작업은 Sonnet으로 충분하고 Opus는 복잡한 아키텍처 결정이나 다단계 추론에 아껴 사용합니다. /model로 전환하고 /config에서 기본값을 정합니다. 조회나 포매팅처럼 단순한 서브에이전트 작업은 서브에이전트 설정에 model: haiku를 지정해 더 낮은 단가로 실행합니다.
effort는 같은 모델 안에서 사고 깊이를 조절합니다. 확장 사고(extended thinking)의 토큰은 출력 토큰으로 과금되고 기본값으로는 모델에 따라 요청당 수만 토큰까지 사용합니다. 깊은 추론이 필요 없는 작업에서는 /effort 명령이나 /model 화면의 슬라이더로 수준을 낮추고 고정해 두려면 effortLevel 설정이나 CLAUDE_CODE_EFFORT_LEVEL 환경 변수를 사용합니다. 값은 low, medium, high, xhigh 중에서 선택합니다(환경 변수는 auto도 허용).
{
"effortLevel": "medium"
}위 설정은 .claude/settings.json(프로젝트) 또는 ~/.claude/settings.json(사용자)에 둡니다. 셸 환경 변수로도 같은 효과를 냅니다.
export CLAUDE_CODE_EFFORT_LEVEL=mediumthinking 토큰에 고정 상한을 받는 모델은 MAX_THINKING_TOKENS로 제한합니다(예: MAX_THINKING_TOKENS=8000). adaptive reasoning 모델은 0이 아닌 상한 값을 무시하므로 effort로만 조절합니다. Claude Fable 5는 확장 사고를 끌 수 없어서 역시 effort 조절이 유일한 수단입니다.
캐시와의 관계를 알면 바꾸는 시점이 보입니다. 모델과 effort는 각각 별도의 캐시 키라서 세션 중간에 바꾸면 다음 요청이 전체 이력을 캐시 미적중으로 재처리합니다. opusplan 설정은 plan mode 진입과 이탈마다 Opus와 Sonnet 사이를 오가므로 토글할 때마다 새 캐시를 쌓습니다. 모델과 effort는 세션 초반에 정하고 작업 중에는 유지하는 것이 캐시 관점의 정답입니다.
05
MCP 서버의 도구 정의는 지원 모델(Claude 4.5 세대 이상)에서 기본적으로 지연(deferred) 로딩됩니다. tool search가 동작하면 도구 이름과 서버 지시만 컨텍스트에 올라가고 실제 정의는 Claude가 그 도구를 사용하는 시점에 로드됩니다. 그래도 서버가 많으면 부담이 쌓이므로 /context로 실제 점유를 확인하고 /mcp에서 사용하지 않는 서버를 비활성화합니다.
지연 로딩이 안 되는 경우가 문제입니다. custom ANTHROPIC_BASE_URL 게이트웨이, 그리고 Claude 4.5 세대보다 앞선 모델을 사용하는 환경에서는 tool search가 동작하지 않아 도구 정의 전체가 프리픽스에 로딩됩니다. 게이트웨이는 ENABLE_TOOL_SEARCH=true로 재정의할 수 있지만 클라우드 프로바이더의 일부 플랫폼은 재정의되지 않습니다. Amazon Bedrock을 포함해 4.5 세대 이상 모델을 사용하는 환경에서는 Anthropic API와 동일하게 기본 동작합니다. alwaysLoad로 지정한 서버나 도구, threshold 기반 선로딩도 같은 결과를 만듭니다. 이때는 서버 하나가 연결되거나 끊기는 것만으로 캐시 전체가 무효화됩니다.
같은 일을 하는 CLI가 있으면 CLI를 우선합니다. aws, gh, gcloud, sentry-cli 같은 도구는 도구 목록 비용 자체가 없고 Claude가 명령을 직접 실행하면 됩니다.
타입 언어를 사용한다면 코드 인텔리전스 플러그인이 탐색 비용을 줄입니다. LSP의 go to definition 한 번이 grep 한 번과 후보 파일 여러 개 읽기를 대체하고 편집 직후 타입 에러를 자동 보고해 컴파일을 실행하지 않고도 실수를 잡습니다.
06
장황한 출력은 서브에이전트로 격리합니다. 테스트 실행, 로그 처리, 문서 fetch를 위임하면 장황한 출력은 서브에이전트의 컨텍스트에 남고 요약만 본 대화로 돌아옵니다. 부모의 캐시도 손상되지 않습니다. 다만 서브에이전트는 자체 시스템 프롬프트와 자체 캐시로 시작하고 구독에서도 5분 TTL을 사용합니다.
Hook은 Claude가 보기 전에 데이터를 전처리합니다. 10,000줄 로그를 통째로 읽히는 대신 Hook이 ERROR 줄만 추려서 넘기면 수만 토큰이 수백 토큰이 됩니다. 다음은 테스트 출력에서 실패만 남기는 PreToolUse Hook 예시입니다.
#!/bin/bash
# ~/.claude/hooks/filter-test-output.sh
input=$(cat)
cmd=$(echo "$input" | jq -r '.tool_input.command')
# 테스트 명령이면 실패 부분만 남기도록 명령을 재작성한다
if [[ "$cmd" =~ ^(npm test|pytest|go test) ]]; then
filtered="$cmd 2>&1 | grep -A 5 -E '(FAIL|ERROR|error:)' | head -100"
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"allow\",\"updatedInput\":{\"command\":\"$filtered\"}}}"
else
echo "{}"
fi이 스크립트를 settings.json의 hooks.PreToolUse에 Bash matcher로 연결하면 매 실행 전에 적용됩니다. 전체 설정 예시는 공식 비용 문서에 그대로 있습니다.
CLAUDE.md에 쌓인 워크플로우 지시는 Skills로 옮깁니다. Skills은 호출될 때만 로드되므로 기본 컨텍스트가 가벼워집니다. 프로젝트 아키텍처, 핵심 디렉토리, 네이밍 규칙을 담은 codebase-overview Skills을 만들어 두면, Claude가 구조를 파악하려고 파일 여러 개를 읽는 대신 Skills 호출 한 번으로 같은 맥락을 얻습니다.
에이전트 팀은 실험 기능이며 비용 배수가 큽니다. 팀원마다 별도 인스턴스와 컨텍스트 윈도우를 유지해서 plan mode 기준 일반 세션의 약 7배 토큰을 사용합니다. 사용한다면 팀을 작게, 팀원 모델은 Sonnet으로, 일이 끝난 팀원은 바로 종료합니다.
작업 습관도 토큰입니다. “이 코드베이스 개선해줘”처럼 모호한 요청은 광범위한 스캔을 유발하고 “auth.ts의 login 함수에 입력 검증 추가”는 최소한의 파일만 읽게 합니다. 복잡한 작업은 plan mode(Shift+Tab)로 방향을 합의한 뒤 실행하고 잘못 가면 Escape로 즉시 멈춰 /rewind 합니다. 테스트 케이스나 기대 출력 같은 검증 목표를 주면 재작업 요청 자체가 줄어듭니다.
07
짧은 한 문장의 질문에도 토큰 사용량이 높은 것은 하루 종일 열려 있던 세션이 전체 이력을 매번 재전송하기 때문입니다. 작업을 바꿀 때마다 /clear 하는 습관이 답입니다. 여기에 CLAUDE.md를 200줄 이하로 유지하고 모델과 effort를 작업에 맞추며 도구 오버헤드를 /context로 점검하는 습관이 더해지면 개인이 통제할 수 있는 낭비 경로는 대부분 닫힙니다.
다만 습관만으로는 설명되지 않는 비용이 남습니다. 자리를 비운 뒤 첫 응답이 유난히 느리고 비싼 이유, 그리고 Amazon Bedrock으로 사용하는 조직에서 사용자별 지출을 확인하는 방법은 캐시의 수명과 조직 단위 관리 체계의 문제입니다. 2부에서는 캐시 경제학(TTL, 무효화 행동, 캐시 범위)과 구독, Claude Console, Amazon Bedrock의 조직 비용 관리, 그리고 전체 적용 우선순위를 다룹니다.
Once a team adopts Claude Code, the same kinds of questions tend to come up. Why is token usage so high when all I asked was a single short sentence, and why has the session become so heavy by the end of the day?
Every time you send a message, Claude Code resends the system prompt, the project context, and the entire conversation history so far, and cost is proportional to the size of that context. The token price you actually pay is then determined by the prompt caching hit rate. This post is part 1 of a two-part series on optimizing Claude Code token costs, and it covers the cost structure, the measurement tools, and the session habits that an individual can apply right away. Cache economics and organization-level cost management, including Amazon Bedrock, continue in part 2. This post is written for readers who have used Claude Code in real work. It assumes experience with tokens and the basic slash commands, and defines key concepts such as prompt caching in the text. The figures and defaults in this post are based on the official Claude Code documentation and the Amazon Bedrock User Guide as of August 2026.
01
The model remembers nothing between requests. So every time you send a message, Claude Code resends the system prompt, the project context, and all of the conversation and tool results so far. When Claude uses tools several times within a single turn, each use sends one more request. This is why token cost is proportional to the size of the session, not to the length of your question.
A request is made up of three layers, and the less often content changes, the earlier it appears.
| Layer | Contents | When it changes |
|---|---|---|
| System prompt | Core instructions, tool definitions, output style | When the set of tool definitions changes or Claude Code is upgraded |
| Project context | CLAUDE.md, auto memory, scoped rules | At session start, and after /clear or /compact |
| Conversation | User messages, responses, tool results | Every turn |
Table 1. The three layers that make up a request
Prompt caching is what makes this repeated resending affordable. A prefix that is identical to the previous request is read from the cache instead of being reprocessed, and it is billed at about 10% of the standard input price. Writing a new cache entry costs more than standard input, but you pay for it only once, and later turns keep reusing that prefix at the lower price. The TTL (time to live) in the table is how long a cache entry is kept.
| Processing path | Relative price (standard input = 1.0x) |
|---|---|
| Cache write (1-hour TTL) | 2.0x |
| Cache write (5-minute TTL) | 1.25x |
| Standard input | 1.0x |
| Cache read | About 0.1x |
Table 2. Relative price by processing path. The cache write cost is a one-time investment that earns the discount on later turns
How you are billed depends on how you connect. Subscription plans (Pro, Max, Team) consume a usage allowance instead of dollars, and that allowance is managed in a 5-hour rolling window and a weekly window. The Claude Console API, Claude Enterprise, and cloud providers such as Amazon Bedrock are billed per token.
There is one principle. Cost is proportional to context size, and the token price you actually pay is determined by the cache hit rate. Every strategy in this post is a way to reduce these two variables.
02
Optimization starts with measurement. What /usage shows depends on how you authenticate. For API-billed users (Claude Enterprise), it shows a Session block with the token statistics and estimated cost of the current session. For subscribers, it shows plan usage bars and an attribution of recent usage (a breakdown by what consumed it). You can see what percentage of the total is taken by skills, subagents, plugins, and each individual MCP server, and behavior flags that account for 10% or more of recent usage, such as long contexts or cache misses, are shown here as well.
The following is a typical output. The notation varies slightly from version to version, but the information it carries is the same.
> /usage
# Session block shown to API-billed users
Session
Input 1,242,310 tokens (cache read 1,180,450 | cache write 38,220 | uncached 23,640)
Output 18,940 tokens
Est. cost $4.87
# Plan usage and attribution shown to subscribers
Plan usage
Session (5h) ████████░░░░░░░░░░░░ 41% resets 18:00
Week (all) ███░░░░░░░░░░░░░░░░░ 16% resets Mon 09:00
Week (Opus) █░░░░░░░░░░░░░░░░░░░ 4%
Recent usage attribution
Subagents 28% | MCP: playwright 17% | Skills: pdf 6%
Behavior flags
Long context sessions 14% | Cache misses after breaks 12%Note: The dollar amount in /usage is an estimate. Claude Code calculates this amount locally based on standard list prices. Promotional pricing and contract discount rates are not reflected, so it can differ from your actual bill. For the figures that billing is based on, check the Usage page in the Claude Console.
/context shows what is occupying the context right now. Check the share taken by MCP tool definitions, CLAUDE.md, and the conversation history, and decide where to cut. If you configure the status line, you can keep the context usage on display at all times, along with the cache_creation_input_tokens and cache_read_input_tokens values returned with each response.
> /context
claude-sonnet-5 | 96.0K / 1.0M tokens (10%)
System prompt 3.2K ( 0.3%)
System tools 12.8K ( 1.3%)
MCP tools 28.4K ( 2.8%) playwright, github tool definitions
Memory files 4.1K ( 0.4%) CLAUDE.md, auto memory
Messages 47.5K ( 4.8%) conversation history and tool results
Free space 904.0K (90.4%)In this example, the preloaded MCP tool definitions are more than half the size of the conversation history. When you see a share like this, tool overhead is the thing to review.
Reading the two cache metrics is simple. When read is far larger than creation, the cache is working well. Conversely, when creation stays high turn after turn, it is a sign that the prefix keeps changing, so check whether something invalidated the cache, such as switching models or changing the tool configuration. The full list of invalidating actions is covered in part 2.
/insights analyzes the way you work instead of the number of tokens. It looks at up to 200 recent sessions on the same machine and compiles the friction points in your workflow, such as which tasks you repeat often and where the intent of a request was misunderstood, into an HTML report (~/.claude/usage-data/report.html). The analysis itself consumes plan or API usage, so running it once every so often is about right.
03
A cost-effective way to optimize is to avoid building up context in the first place. When you move on to an unrelated task, start fresh with /clear. It costs nothing extra, and the earlier history is not included in the next request. If you need to find the session later, give it a name with /rename before you clear it, and come back with /resume when you need it.
When you need to continue the same task and only shrink the context, /compact replaces the history with a summary. You can tell it what to preserve, as in /compact Focus on code samples and API usage, and if you use the same instruction every time, put it in CLAUDE.md as a standing rule.
# Compact instructions
When you are using compact, please focus on test output and code changesThe cost of compaction itself also has to be counted. The request that creates the summary is a large request that sends the entire conversation as the prompt. While the cache is still alive, most of it is processed as cache reads and is cheap, but if you run it after the cache lifetime has passed (for example, right after resuming an old session), it becomes the most expensive kind of compaction, one that reprocesses everything. To control the timing, run it yourself at a point where a piece of work has wrapped up, before auto-compact cuts in mid-task.
When you have gone in the wrong direction, use /rewind instead of compaction. When you rewind the conversation to an earlier turn, the prefix up to that point is already in the cache, so the next request hits the cache as is. Rewinding is far cheaper than compaction, which creates a new summary and builds the cache again.
The following are the criteria for choosing among the three commands.
| Situation | Command | Cost and cache impact |
|---|---|---|
| Switching to an unrelated new task | /clear | No extra cost, the cache starts being built again from scratch |
| Continuing the same task with a full context | /compact | Pay for one summary request, run it before the cache expires |
| Recovering from a wrong direction | /rewind | Hits the existing cache as is |
Table 3. Criteria for choosing a context-switching command. Of the three, only /rewind hits the existing cache as is
The default auto-compact window is set automatically to suit the model. You can set the window value with the /autocompact command (/autocompact auto returns to the model default) and can also adjust it with the CLAUDE_CODE_AUTO_COMPACT_WINDOW environment variable. However, lowering the window makes compaction more frequent and the cost of the summary requests adds up, so leave it on the automatic value unless you have a specific reason. By default, Sonnet 5 is auto-compacted at about 967,000 tokens (other models have no separately documented threshold).
CLAUDE.md is loaded at the start of every session and stays in the project context layer. Every turn pays this cost, so keep it to 200 lines or fewer, and move detailed instructions that only specific workflows need into skills, which are loaded only when they are invoked.
Caution: The project root and user-level CLAUDE.md files are read once at session start and kept in memory. Editing a file during the session does not break the cache, but the change is not picked up either. The new content is loaded at the next /clear, /compact, or restart. Editing the file again and again and retrying in the same session because an instruction is not taking effect only wastes tokens.
04
Model selection is the first decision that sets your unit price. Sonnet is enough for most coding tasks, and Opus is best saved for complex architecture decisions or multi-step reasoning. Switch with /model and set the default in /config. For simple subagent tasks such as lookups or formatting, specify model: haiku in the subagent configuration to run them at a lower unit price.
Effort adjusts the depth of thinking within the same model. Extended thinking tokens are billed as output tokens, and by default they use up to tens of thousands of tokens per request, depending on the model. For tasks that do not need deep reasoning, lower the level with the /effort command or the slider on the /model screen, and to pin it, use the effortLevel setting or the CLAUDE_CODE_EFFORT_LEVEL environment variable. Choose a value from low, medium, high, and xhigh (the environment variable also accepts auto).
{
"effortLevel": "medium"
}Put the setting above in .claude/settings.json (project) or ~/.claude/settings.json (user). A shell environment variable has the same effect.
export CLAUDE_CODE_EFFORT_LEVEL=mediumFor models that accept a fixed cap on thinking tokens, limit it with MAX_THINKING_TOKENS (for example, MAX_THINKING_TOKENS=8000). Adaptive reasoning models ignore any nonzero cap, so effort is the only way to adjust them. Extended thinking cannot be turned off on Claude Fable 5, so adjusting effort is again the only option.
Once you know how these settings relate to the cache, it becomes clear when to change them. The model and the effort level are each a separate cache key, so changing either one in the middle of a session makes the next request reprocess the entire history as a cache miss. The opusplan setting moves between Opus and Sonnet each time you enter and leave plan mode, so every toggle builds a new cache. From a cache point of view, the right answer is to decide on the model and effort early in the session and keep them while you work.
05
On supported models (the Claude 4.5 generation and later), MCP server tool definitions use deferred loading by default. When tool search is working, only the tool names and server instructions go into the context, and the actual definition is loaded at the point where Claude uses that tool. Even so, the load adds up when you have many servers, so check the actual footprint with /context and disable the servers you do not use in /mcp.
The problem is the cases where deferred loading does not work. With a custom ANTHROPIC_BASE_URL gateway, and in environments that use models older than the Claude 4.5 generation, tool search does not work, so the full set of tool definitions is loaded into the prefix. A gateway can override this with ENABLE_TOOL_SEARCH=true, but some cloud provider platforms cannot be overridden. In environments that use 4.5 generation or later models, including Amazon Bedrock, it works by default in the same way as with the Anthropic API. Servers or tools marked with alwaysLoad and threshold-based preloading produce the same result. In that case, a single server connecting or disconnecting is enough to invalidate the entire cache.
When a CLI does the same job, prefer the CLI. Tools such as aws, gh, gcloud, and sentry-cli carry no tool listing cost at all, and Claude only has to run the commands directly.
If you use a typed language, a code intelligence plugin reduces the cost of navigation. A single LSP go to definition replaces one grep plus reading several candidate files, and type errors are reported automatically right after an edit, which catches mistakes without running a compile.
06
Isolate verbose output in subagents. When you delegate test runs, log processing, and document fetches, the verbose output stays in the subagent's context and only the summary comes back to the main conversation. The parent's cache is not damaged either. However, a subagent starts with its own system prompt and its own cache, and it uses the 5-minute TTL even on a subscription.
Hooks preprocess data before Claude sees it. Instead of having Claude read a 10,000-line log in full, a hook can pick out only the ERROR lines and pass them on, which turns tens of thousands of tokens into hundreds. The following is an example of a PreToolUse hook that keeps only the failures from test output.
#!/bin/bash
# ~/.claude/hooks/filter-test-output.sh
input=$(cat)
cmd=$(echo "$input" | jq -r '.tool_input.command')
# If this is a test command, rewrite it so that only the failures remain
if [[ "$cmd" =~ ^(npm test|pytest|go test) ]]; then
filtered="$cmd 2>&1 | grep -A 5 -E '(FAIL|ERROR|error:)' | head -100"
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"allow\",\"updatedInput\":{\"command\":\"$filtered\"}}}"
else
echo "{}"
fiConnect this script to hooks.PreToolUse in settings.json with a Bash matcher, and it is applied before every run. The full configuration example is available as is in the official cost documentation.
Move the workflow instructions that have piled up in CLAUDE.md into skills. Skills are loaded only when they are invoked, so the base context gets lighter. If you create a codebase-overview skill that holds the project architecture, key directories, and naming conventions, Claude gets the same context from a single skill invocation instead of reading several files to work out the structure.
Agent teams are an experimental feature, and their cost multiplier is large. Each teammate keeps a separate instance and context window, so a team uses about 7 times the tokens of a standard session, measured in plan mode. If you use them, keep the team small, use Sonnet as the teammate model, and shut down teammates as soon as their work is done.
Work habits are tokens too. A vague request such as “improve this codebase” triggers a broad scan, while “add input validation to the login function in auth.ts” makes Claude read only the minimum set of files. For complex tasks, agree on the direction in plan mode (Shift+Tab) before executing, and if it goes the wrong way, stop it immediately with Escape and /rewind. Giving verification targets such as test cases or expected output reduces the number of rework requests in the first place.
07
Token usage is high even for a single short question because a session that has been open all day resends its entire history every time. The answer is the habit of running /clear every time you switch tasks. Add the habits of keeping CLAUDE.md to 200 lines or fewer, matching the model and effort to the task, and checking tool overhead with /context, and most of the paths to waste that an individual can control are closed.
Still, some costs cannot be explained by habits alone. Why the first response after you step away is unusually slow and expensive, and how an organization that uses Claude Code through Amazon Bedrock can check spending per user, are questions of cache lifetime and of organization-level management. Part 2 covers cache economics (TTL, invalidating actions, cache scope), organizational cost management for subscriptions, the Claude Console, and Amazon Bedrock, and the overall order of priority for applying these practices.
| No. | 출처Source | 종류Kind | 확인한 날Checked |
|---|---|---|---|
| 1 | Manage costs effectively - Anthropic, Claude Code Docs (2026-08-25 확인) | 웹 문서Web | 2026-11-15 |
| 2 | Model configuration - Anthropic, Claude Code Docs | 웹 문서Web | 2026-11-15 |
| 3 | Prompt caching - Anthropic, Claude Platform Docs (TTL별 캐시 쓰기/읽기 단가표 포함) | 웹 문서Web | 2026-11-15 |
| 4 | Lessons from building Claude Code: Prompt caching is everything - Anthropic (plan mode, 지연 도구 로딩, 컴팩션의 설계 배경) | 웹 문서Web | 2026-11-15 |