GrepBoard/매뉴얼
47 편 ·

Claude 대화가 너무 길 때 요약해 새 대화로 넘기기

·claude-sonnet-5-5 · Claude Code 2.1.302 (claude -p) · Ubuntu 24.04 · 2026-10-19 · claude.ai 화면은 공식 도움말 기준·7 단계

길이 제한에 걸린 대화에서 인계 요약을 뽑고, 요약 속 숫자가 원문에 있는지 grep 으로 대조한 뒤 새 대화에 붙여 이어 가는 순서입니다.

한 대화가 너무 길어져 더 못 이어 갈 때는 새 대화로 옮겨야 합니다. 맥락을 잃지 않으려면 옮기기 전에 요약을 뽑고, 그 요약이 원문과 맞는지 확인합니다.

[1] 어떤 제한인지 먼저 가립니다. 공식 도움말은 둘을 나눕니다. 사용량 제한은 정해진 기간 동안 Claude 를 얼마나 쓸 수 있는지이고, 길이 제한은 한 대화에서 Claude 가 다룰 수 있는 정보량(컨텍스트 창)입니다. 길이 제한이면 도움말 안내는 「새 대화를 시작하거나, 많은 자료는 프로젝트로 다루라」는 것입니다.

[2] 창 크기는 모델마다 다릅니다. 2026-10 도움말(채팅, 유료)은 모델에 따라 1M · 500K · 200K 토큰으로 나눕니다. 어느 모델이 어디에 드는지는 자주 바뀌니 도움말 원문을 확인하세요.

[3] 현재 대화에 인계 요약을 요청합니다. 섹션을 고정하고, 바뀐 값은 따로 적게 하는 것이 요점입니다. 안 그러면 요약에 처음 값(500)과 나중 값(200)이 같이 남습니다.

handoff-prompt.txt
This conversation is too long to continue. I will paste your summary into a new chat, so write a handoff note that lets a fresh assistant continue without me re-explaining anything. Rules:- Use exactly these sections: GOAL, DECISIONS (final values only), SUPERSEDED (values that were changed, with what replaced them), NUMBERS (every figure with its unit and what it measures), OPEN QUESTIONS, NEXT STEP.- Copy numbers, names and dates exactly as written. Do not round, do not add figures that are not in the conversation.- If something was never decided, put it under OPEN QUESTIONS, not DECISIONS.- Plain text, no preamble.

[4] 시험용으로 30줄짜리 가상 대화(chat.txt)를 만들었습니다. 송장 내보내기 작업을 큐 워커로 옮기는 내용이고, 배치 크기가 500 에서 200 으로 바뀌고 알림 담당자는 정하지 못한 채 끝납니다. 프롬프트 뒤에 대화를 붙여 claude -p 로 돌립니다. claude.ai 에서는 같은 프롬프트를 그 대화 끝에 보내면 됩니다.

console
$ (cat handoff-prompt.txt; echo; echo "<conversation>"; cat chat.txt; echo "</conversation>") > prompt.txt$ claude -p --model claude-sonnet-5-5 --tools "" < prompt.txt > handoff.txt$ wc -l chat.txt handoff.txt  30 chat.txt  36 handoff.txt

앞부분입니다(줄임).

output
DECISIONS (final values only)- Queue: database queue, table jobs_export. No Redis.- Batch size: 200 invoices per job (91 jobs for 18,200 invoices).…SUPERSEDED (values that were changed, with what replaced them)- Batch size 500 (37 jobs) was replaced by 200 (91 jobs), because 500 per batch peaked at 610 MB on staging and the worker was killed.…OPEN QUESTIONS- Who owns alerting when a job fails 3 times: Dana from ops or the dev on call? Not decided. Ask Dana and decide before the production switch on 2026-11-12.

[5] 요약 속 숫자가 대화에 있는지 대조합니다. 요약에서 숫자 토큰을 뽑아 grep -F 로 원문에서 찾고, 없는 것만 알려 줍니다.

check.sh
#!/bin/bash# usage: check.sh chat.txt handoff.txtmiss=0for t in $(grep -oE '[0-9][0-9,.:-]*[0-9]|[0-9]' "$2" | sort -u); do  grep -qF -- "$t" "$1" || { echo "NOT IN CHAT: $t"; miss=$((miss+1)); }doneecho "$miss not found"; [ "$miss" -eq 0 ]
console
$ chmod +x check.sh$ ./check.sh chat.txt handoff.txt; echo "exit $?"0 not foundexit 0

요약의 서로 다른 숫자 토큰 21개가 모두 대화에 있었습니다. 실패 출력은 238 MB 를 손으로 283 MB 로 바꾼 handoff-bad.txt 로 낸 것입니다(모델이 틀린 것이 아닙니다).

console
$ ./check.sh chat.txt handoff-bad.txt; echo "exit $?"NOT IN CHAT: 2831 not foundexit 1

[6] 새 대화를 열고 요약을 붙입니다. 요약 앞에 한 줄을 달아 「이어서 하라」고 알립니다. 시험에서는 요약만 넣은 새 claude -p 호출에 질문을 하나 던졌습니다.

new-chat-first-message.txt
Below is a handoff note from an earlier conversation. Continue from it. Do not ask me to repeat anything it already says. <handoff>(handoff.txt 내용)</handoff> Question: what batch size and bucket do we use in production, and how many jobs is that per night?
output
Production uses a batch size of **200 invoices per job** and the bucket **`exports-eu-2`**. That gives **91 jobs per night** for 18,200 invoices (18,200 ÷ 200 = 91).

처음 값 500 이 아니라 바뀐 200 으로, 스테이징이 아니라 운영 버킷으로 답했습니다. 첫 질문으로 「바뀐 값」 하나를 물어 보면 인계가 됐는지 바로 압니다.

[7] 원래 대화에서 파일이나 이미지를 올렸다면 요약에는 내용이 들어가지 않습니다. 새 대화에 그 파일을 다시 올립니다.

Claude Code 의 터미널 대화라면 요약을 손으로 넘기는 대신 /compact 를 씁니다. Claude Code 대화가 길어질 때 /compact 와 /clear 를 보세요. 요약문의 인용을 원문과 대조하는 방법은 Claude 요약에 원문 인용을 붙이게 하고 grep 으로 검증에 있습니다.

#claude#prompt#context-window#handoff