Evanflow compact

From evanklem/evanflow · View interactive version

Evanflow compact is an AI agent skill from the GitHub repository evanklem/evanflow. Manage 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 agent failure (context

How to use this skill

Skill file

EvanFlow: Compact

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.

Vocabulary

See evanflow meta-skill. Specific to this skill:

When to Use

Trigger this skill when ANY of these are true:

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.

The Strategies (pick one based on situation)

Strategy 1 — Proactive Summarize-and-Continue (preferred at clean boundaries)

When a major phase just finished cleanly:

  1. Identify anchors: what files, decisions, and open questions must survive? List them explicitly.
  2. Author a compaction summary in the conversation as a markdown block titled ## Phase Summary (compaction anchor). Include:
  1. 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."
  2. If user says yes → they /clear, then start the next phase fresh with the summary in front of them.

Strategy 2 — Save Anchors to Memory, Then `/clear`

When the session is heavy and the next move is unclear:

  1. Audit what's been learned that ISN'T already in memory or files. Anything important?
  2. Save those things to memory (~/.claude/projects/<project>/memory/*.md) as appropriate types (user / feedback / project / reference).
  3. Save any in-progress thinking to a plan file or a scratch doc.
  4. Tell the user: "Important state is now persisted in memory + <files>. Recommend /clear and re-engage fresh."

Strategy 3 — Branch Isolation

When a side-quest emerges that's unrelated to the main thread:

  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."
  2. If the user wants to do it now anyway, save the main-thread state per Strategy 2 first, then proceed.

Strategy 4 — Reactive Mid-Flow Summarization

When drift symptoms appear and you can't reach a clean boundary:

  1. Stop the current task.
  2. Audit what's been established that's still relevant. Discard the rest mentally.
  3. Author an explicit "current state" block in the conversation summarizing only the live concerns.
  4. Continue from there, referencing the new summary as the truth.

This is less effective than proactive compaction — use only when needed.

Drift Symptoms Checklist

Watch for these. Each is a signal to consider compaction:

If 2+ symptoms in the last few turns, invoke this skill.

Hard Rules

Hand-offs

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.