본문으로 건너뛰기
Skillpedia
작업 및 프로젝트280k · #415

strategic-compact

하는 일

이 도구는 AI의 대화 메모리가 과부하되지 않도록 언제 '정리'할지 제안합니다. 길거나 복잡한 작업에서 AI가 중요한 것을 기억하도록 돕습니다.

사용하는 경우

  • ✓AI와의 대화가 아주 길어져 느려질 때.
  • ✓한 주요 작업 단계에서 다른 단계로 넘어갈 때(예: 조사에서 계획으로).
  • ✓중요한 작업 부분을 마치고 새로운 것을 시작한 뒤.

스킬 링크

https://github.com/affaan-m/ECC/blob/main/skills/strategic-compact/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/affaan-m/ECC/blob/main/skills/strategic-compact/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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:

  1. Context size (primary) — Reads the latest usage record from the session transcript (transcript_path in the hook payload) and sums input_tokens + cache_read_input_tokens + cache_creation_input_tokens (the true context size of the turn). Suggests /compact at 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
  2. 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; 0 disables 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 when ECC_CONTEXT_WINDOW_TOKENS is 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 /compact suggestion 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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬