$npx -y skills add evanklem/evanflow --skill evanflow-compactManage long-session context to prevent drift and degradation. Strategies for proactive summarization, branch isolation, and /clear decisions. Invoke when context feels heavy, when accuracy starts slipping, or proactively after a major phase boundary. Addresses the #1 cause of age
| 1 | # EvanFlow: Compact |
| 2 | |
| 3 | |
| 4 | **Why this exists:** Context drift kills agents before context limits do. Industry research found ~65% of enterprise AI failures in 2025 traced to context drift or memory loss in multi-step reasoning, NOT raw token exhaustion. The agent's ability to reason degrades as context fills with stale, redundant, or contradictory information — long before the hard token limit. |
| 5 | |
| 6 | ## Vocabulary |
| 7 | |
| 8 | See `evanflow` meta-skill. Specific to this skill: |
| 9 | |
| 10 | - **Drift** — agent reasoning degrades as context fills with stale/contradictory/low-signal content. Manifests as: slower responses, more clarifying questions about already-established facts, forgetting recent decisions, inconsistent application of rules. |
| 11 | - **Anchor** — a high-signal artifact (CONTEXT.md, ADR, current plan, current diff) that survives compaction. |
| 12 | - **Compaction** — replacing a long stretch of conversation with a shorter summary that preserves the anchors plus key decisions. |
| 13 | - **Branch isolation** — moving a side-quest into a separate session so the main session stays focused. |
| 14 | |
| 15 | ## When to Use |
| 16 | |
| 17 | Trigger this skill when ANY of these are true: |
| 18 | |
| 19 | - A major phase boundary just completed (e.g., Phase A done, about to start Phase B). **Proactive compaction** at clean boundaries is much higher quality than reactive compaction mid-flow. |
| 20 | - The session has accumulated 30+ turns of dense back-and-forth. |
| 21 | - You notice **drift symptoms**: agent re-asking already-answered questions, contradicting earlier decisions, restating context the user already established, slower or vaguer responses. |
| 22 | - Context display warns of high utilization (rough threshold: ~70%+). |
| 23 | - About to fork into an unrelated side-quest that could be its own session. |
| 24 | |
| 25 | **SKIP when:** the session is short, focused, and progressing without drift symptoms. Compaction has cost (loses fidelity); only invoke when the cost of NOT compacting is higher. |
| 26 | |
| 27 | ## The Strategies (pick one based on situation) |
| 28 | |
| 29 | ### Strategy 1 — Proactive Summarize-and-Continue (preferred at clean boundaries) |
| 30 | |
| 31 | When a major phase just finished cleanly: |
| 32 | |
| 33 | 1. Identify anchors: what files, decisions, and open questions must survive? List them explicitly. |
| 34 | 2. Author a compaction summary in the conversation as a markdown block titled `## Phase Summary (compaction anchor)`. Include: |
| 35 | - What was decided |
| 36 | - What was built (file list + one-line each) |
| 37 | - What's verified |
| 38 | - What's deferred / open for next phase |
| 39 | - Pointers to the persistent artifacts (memory files, CONTEXT.md sections, ADRs, plan file) |
| 40 | 3. Tell the user: "I'm at a clean boundary. Want me to compact context here? You can `/clear` and re-orient from this summary + the saved memory." |
| 41 | 4. If user says yes → they `/clear`, then start the next phase fresh with the summary in front of them. |
| 42 | |
| 43 | ### Strategy 2 — Save Anchors to Memory, Then `/clear` |
| 44 | |
| 45 | When the session is heavy and the next move is unclear: |
| 46 | |
| 47 | 1. Audit what's been learned that ISN'T already in memory or files. Anything important? |
| 48 | 2. Save those things to memory (`~/.claude/projects/<project>/memory/*.md`) as appropriate types (user / feedback / project / reference). |
| 49 | 3. Save any in-progress thinking to a plan file or a scratch doc. |
| 50 | 4. Tell the user: "Important state is now persisted in memory + `<files>`. Recommend `/clear` and re-engage fresh." |
| 51 | |
| 52 | ### Strategy 3 — Branch Isolation |
| 53 | |
| 54 | When a side-quest emerges that's unrelated to the main thread: |
| 55 | |
| 56 | 1. Don't pull it into this session. Tell the user: "This is a separate concern from `<main thread>`. Recommend handling it in a fresh session — your context will stay clean and the side-quest gets full attention." |
| 57 | 2. If the user wants to do it now anyway, save the main-thread state per Strategy 2 first, then proceed. |
| 58 | |
| 59 | ### Strategy 4 — Reactive Mid-Flow Summarization |
| 60 | |
| 61 | When drift symptoms appear and you can't reach a clean boundary: |
| 62 | |
| 63 | 1. Stop the current task. |
| 64 | 2. Audit what's been established that's still relevant. Discard the rest mentally. |
| 65 | 3. Author an explicit "current state" block in the conversation summarizing only the live concerns. |
| 66 | 4. Continue from there, referencing the new summary as the truth. |
| 67 | |
| 68 | This is less effective than proactive compaction — use only when needed. |
| 69 | |
| 70 | ## Drift Symptoms Checklist |
| 71 | |
| 72 | Watch for these. Each is a signal to consider compaction: |
| 73 | |
| 74 | - [ ] Agent re-asks a question the user already answered |
| 75 | - [ ] Agent restates the user's instructions back ("just to confirm, you want X" when X has been confirmed multiple times) |
| 76 | - [ ] Agent contradicts its own earlier decision without acknowledging the change |
| 77 | - [ ] Agent forgets a constraint that was set in the sam |