strategic-compact
하는 일
이 도구는 AI의 대화 메모리가 과부하되지 않도록 언제 '정리'할지 제안합니다. 길거나 복잡한 작업에서 AI가 중요한 것을 기억하도록 돕습니다.
사용하는 경우
- ✓AI와의 대화가 아주 길어져 느려질 때.
- ✓한 주요 작업 단계에서 다른 단계로 넘어갈 때(예: 조사에서 계획으로).
- ✓중요한 작업 부분을 마치고 새로운 것을 시작한 뒤.
스킬 링크
https://github.com/affaan-m/ECC/blob/main/skills/strategic-compact/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“AI, 대화가 점점 헷갈리고 있어요. 메모리를 정리할까요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
도구는 AI가 대화를 얼마나 '기억'하고 있는지 확인합니다. 한계에 가까우면 메모리를 정리하는 명령을 쓰도록 제안하며, 가장 중요한 정보가 유지되도록 합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Strategic Compact Skill
Suggests manual /compact at strategic points in your workflow rather than relying on arbitrary auto-compaction.
When to Activate
- Running long sessions that approach context limits (200K+ tokens)
- Working on multi-phase tasks (research → plan → implement → test)
- Switching between unrelated tasks within the same session
- After completing a major milestone and starting new work
- When responses slow down or become less coherent (context pressure)
Why Strategic Compaction?
Auto-compaction triggers at arbitrary points:
- Often mid-task, losing important context
- No awareness of logical task boundaries
- Can interrupt complex multi-step operations
Strategic compaction at logical boundaries:
- After exploration, before execution — Compact research context, keep implementation plan
- After completing a milestone — Fresh start for next phase
- Before major context shifts — Clear exploration context before different task
How It Works
The suggest-compact.js script runs on PreToolUse (Edit/Write) and combines two signals:
- Context size (primary) — Reads the latest
usagerecord from the session transcript (transcript_pathin the hook payload) and sumsinput_tokens + cache_read_input_tokens + cache_creation_input_tokens(the true context size of the turn). Suggests/compactat a window-scaled threshold — 160k tokens on a 200k window, 250k on a 1M window (detected from a[1m]model marker, or inferred when observed tokens already exceed 200k) — and re-reminds after every additional 60k tokens of context growth - Tool-call count (secondary) — Counts tool invocations in session; suggests at a configurable threshold (default: 50 calls), then every 25 calls after
Tool count alone is a weak proxy for window pressure: a few large file reads or MCP responses can fill the window in very few calls, while many tiny calls can cross 50 with a near-empty window. The context-size signal fires when it actually matters.
Hook Setup
Installed as a plugin? No setup is needed. The plugin's hooks/hooks.json already registers suggest-compact.js (hook id pre:edit-write:suggest-compact, active in the standard and strict hook profiles). Do not copy the block below into ~/.claude/settings.json — ~/.claude/scripts/ does not exist on plugin installs, and duplicating a plugin hook causes double execution.
If installed manually (./install.sh), add to your ~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit",
"hooks": [{ "type": "command", "command": "node ~/.claude/scripts/hooks/suggest-compact.js" }]
},
{
"matcher": "Write",
"hooks": [{ "type": "command", "command": "node ~/.claude/scripts/hooks/suggest-compact.js" }]
}
]
}
}
Configuration
Environment variables:
COMPACT_THRESHOLD— Tool calls before first suggestion (default: 50)COMPACT_CONTEXT_THRESHOLD— Context tokens before the context-size suggestion (default: 160000 on a 200k window, 250000 on a 1M window;0disables the context signal)COMPACT_CONTEXT_INTERVAL— Additional context tokens before the suggestion repeats (default: 60000)COMPACT_STATE_TTL_DAYS— Days before stale per-session state files in the temp dir are swept (default: 14)ECC_CONTEXT_WINDOW_TOKENS— Explicit context-window size, in tokens, overriding auto-detection. Set this for large-window models whose reported id lacks a[1m]marker (e.g. 400k Opus 4.x, or a new 1M-window model family) so the threshold scales to the real window instead of defaulting to 200k and overstating context usage.CLAUDE_CODE_AUTO_COMPACT_WINDOW— Claude Code's native window-size override, in tokens; honored as a fallback whenECC_CONTEXT_WINDOW_TOKENSis unset.
The context window is otherwise auto-detected from a
[1m]model marker or inferred when observed tokens already exceed 200k. On a large-window model that carries neither signal, set one of the overrides above so the/compactsuggestion fires at the right point.
Compaction Decision Guide
Use this table to decide when to compact:
| Phase Transition | Compact? | Why |
|---|---|---|
| Research → Planning | Yes | Research context is bulky; plan is the distilled output |
| Planning → Implementation | Yes | Plan is written down (a file, or the task list if you have one); free up context for code |
…
자주 묻는 질문
'메모리 정리'는 무엇을 뜻하나요?
AI에게 요약을 주고, 필수 정보만 남기고 나머지는 버려서 계속 잘 작동하게 하는 것과 같습니다.
AI가 메모리를 자동으로 정리하면 안 되나요?
AI가 작업 중간의 나쁜 시점에 메모리를 정리해서 중요한 정보를 잃을 수 있습니다. 이 도구는 단계가 끝나는 것처럼 논리적인 지점에서 정리하도록 제안합니다.
메모리를 정리하면 정보는 어떻게 되나요?
핵심 지침과 중요한 파일은 유지됩니다. 중간 정보나 오래된 대화는 새로운 내용을 위한 공간을 만들기 위해 사라질 수 있습니다.
상세 정보
작성자의 원본 설명
Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction. Use when a session is approaching a context limit and a task phase is a natural place to compact.
repo: affaan-m/ECC
인기도
- GitHub 스타
- 280k
- 순위
- #415
- 라이선스
- MIT
- 업데이트
- 2026. 10. 15.
댓글
- …
이 저장소의 다른 스킬
accessibility
280k에이전트가 모든 사람이 쓸 수 있는 인터페이스를 만들도록 돕습니다. 시각 장애나 운동 장애가 있는 사람도 쓸 수 있게 합니다.
agent-architecture-audit
280k에이전트가 모든 것이 올바르게 작동하는지 점검하도록 돕습니다. AI 시스템의 문제를 찾아 고쳐서 기대대로 작동하게 합니다.
agent-eval
280k에이전트가 서로 다른 AI 코딩 도구를 비교하도록 돕습니다. 특정 작업에서 어느 도구가 더 빠르고, 저렴하고, 믿을 만한지 측정합니다.
agent-harness-construction
280k에이전트가 작업을 더 잘 이해하도록 돕습니다. 에이전트가 쓰는 도구와 지시문을 최적화해 성공 가능성을 높입니다.
비슷한 스킬
knowledge-capture
394k에이전트가 결정, 선호, 핵심 사실을 출처 표시와 함께 짧은 메모로 Knowledge 볼트에 저장하도록 가르칩니다.
knowledge-claim-consolidation
394k에이전트가 중복 주장을 합치고, 올바른 주제 페이지로 옮기고, 오래된 주장을 폐기해 Knowledge 볼트를 정리하도록 돕습니다.
knowledge-correct
394k에이전트가 요청에 따라 특정 Knowledge 주장이나 페이지를 고치거나 철회하고, 무엇이 바뀌었는지 기록을 남기도록 돕습니다.