
conPACT 제작: 작업이 끝나면 Claude Code가 스스로 컨텍스트를 압축하고, 프롬프트 캐시가 만료되기 전에 유휴 세션 압축을 제안
conPACT는 작업이 끝나면 MCP 도구를 통해 세션 컨텍스트를 자동으로 압축하고, 프롬프트 캐시가 만료되기 전에 유휴 세션의 압축을 안내하는 Claude Code 모드입니다. Claude Code 2.1.284 이상에서는 프로세스 내 플러그인 hooks 모드로 동작하며, Remote Control을 통해서는 Stop hook으로 /compact를 보냅니다. Codex와 ChatGPT Desktop도 지원합니다. 작성자에 따르면 지출이 약 4.7% 줄고 최대 컨텍스트도 작아졌습니다. MIT 라이선스입니다.

이 mod 소개
작성자는 conPACT를 소개합니다. MCP 도구 queue_compaction으로 자체 압축을 대기열에 넣고, 최종 답변 뒤에 실제 /compact로 압축을 실행합니다. 채팅 기록은 유지하면서 실시간 컨텍스트를 요약합니다.
집중 지시와 최소 크기를 지정할 수 있습니다. 캐시 만료 5분 전에 토스트가 나타나 즉시 압축하거나 세션별 자동 압축을 선택할 수 있습니다. 프롬프트 위에는 상태 행이 표시됩니다.
작성자는 Claude Code로 개발했고, 9월 중순부터 자신의 개발 세션에서 사용하고 있습니다. Claude Code 2.1.284 이상의 새로운 프로세스 내 플러그인 hooks를 사용하는 모드로 통합되며, Remote Control을 통해 쓸 때는 Stop hook이 /compact를 보냅니다. 선택 사항인 sidecar를 쓰면 ChatGPT Desktop(Codex)에서도 동작하며, Stop hook으로 Codex CLI도 지원합니다.
작성자의 핵심 교훈은 다음과 같습니다. /compact는 턴 진행 중에는 보낼 수 없으므로, 압축은 턴이 끝난 뒤에 한 번만 실행됩니다. 크기보다 타이밍이 더 중요합니다.
API 호출 187,978건을 측정한 결과, conPACT의 압축 134건은 모두 캐시가 따뜻한 상태에서 이루어졌습니다. 반면 수동 압축 121건 중 캐시가 따뜻했던 것은 30건뿐입니다. 정가 기준으로 압축 1회당 약 $5.67 대 $0.20입니다. 최대 컨텍스트의 중앙값은 501k에서 337k tokens로 줄었고, 콜드 재개 시 다시 읽는 양의 중앙값은 493k에서 255k tokens로 줄었습니다. 콜드 재개가 지출에서 차지하는 비율은 6.4%에서 3.8%로 낮아졌으며, 재작업에 따른 불이익도 없었습니다.
요구 사항은 Python 3.11 이상입니다. 표준 라이브러리만 사용하며 Windows, Linux, macOS에서 실행됩니다. MIT 라이선스입니다. GitHub: https://github.com/st0nebridge/conPACT
설치
설치 방법은 원본 출처를 확인하세요.
원문 / README
Long Claude Code sessions cost you twice. The context keeps growing after the work that needed it is done, and if you come back after the prompt cache has expired, your next message re-reads all of it uncached. /compact fixes both, but only if you type it at the right moment. I usually didn't. What it does When a piece of work is finished, Claude queues a compaction of its own session through an MCP tool ( queue_compaction ). It runs after the final answer, as a real /compact : your chat history stays visible and only the live context is summarised. It can take a focus ("keep the plan and the open decisions") and a minimum size. When a big session sits idle, a toast appears five minutes before the cache expires and offers to compact it now, or always for that session. A row above the prompt follows the request: queued, compacting, then what it came to. How Claude Code was used I built it with Claude Code, and it has been compacting its own development sessions since mid-September. In Claude Code 2.1.284+ it ships as a mod (the new in-process plugin hooks), so the session compacts itself and draws the row above the prompt. Without the mod, a Stop hook sends /compact over Remote Control. It also works for ChatGPT Desktop (Codex) through an optional sidecar, and for the Codex CLI through a Stop hook. What I learned You can't send /compact mid-turn. A busy session receives it as plain text and it never runs. So the tool only records the request, and the compaction happens after the turn ends: always after the final answer, and at most once. When you compact matters more than how small. I measured it over 187,978 of my own API calls (12 days with conPACT, 80 before). All 134 conPACT compactions ran on a warm cache, against 30 of the 121 I'd typed by hand. A cold compaction re-reads the whole context at the cache-write price first, so that's roughly $5.67 against $0.20 per compaction at list price. Median peak context per session fell from 501k to 337k. The idle toast does its job: a cold restart now starts from a compacted context. The median re-read on a cold resume fell from 493k to 255k tokens, and cold resumes' share of spend fell from 6.4% to 3.8%. No rework penalty. Claude re-reads some files after a compaction, but the next prompt was a correction 5.5% of the time, against 6.1% in ordinary turns. Net: about 4.7% of spend saved at list price (1.8–13%, depending on what you assume I'd have done otherwise). It's modest, and the "after" period is only 12 active days, but every compaction saves more than it costs. Python 3.11+, standard library only. Windows, Linux and macOS (the test suite runs on all three; most of my live use is on Windows). MIT licensed. GitHub: https://github.com/st0nebridge/conPACT Feedback welcome, especially from anyone on macOS or Linux. submitted by /u/stonebrigade [link] [comments]

