Working Around Auto-Compaction in Claude Code - Writing

Working Around Auto-Compaction in Claude Code

Working Around Auto-Compaction in Claude Code

Auto-compaction in Claude Code (CC) is a useful feature. It allows long-running sessions to continue by compressing past context when the window fills up. For small or exploratory workflows, this works well.

For complex, multi-step engineering work, it often doesn’t.

This post describes a skill set we built to retain control over context, avoid destructive compaction, and keep long-running sessions productive—without constantly restarting from scratch.

Problems with auto-compaction

In practice, auto-compaction introduces several issues once task complexity increases.

1. It triggers at the wrong time Auto-compaction is metric-driven, not workflow-aware. It can interrupt a session in the middle of a carefully constructed task, when continuity matters most.

2. It’s a hard interrupt Compaction can take minutes. During that time, work is blocked. In longer sessions, this happens repeatedly.

3. The compression is lossy Empirically, work that functioned before compaction often degrades afterward. Important assumptions, constraints, or intermediate reasoning can disappear. The more complex the task, the higher the damage.

4. It optimizes for history, not relevance Auto-compaction may attempt to summarize everything. In reality, most ongoing work only depends on:

  • the current task
  • future tasks
  • a narrow slice of derived context

Treating the entire session history as equally valuable is inefficient.

5. Reserved context shrinks your usable window Auto-compaction itself requires reserved context. Over a few releases the amount reserved has also grown, leaving less usable context even after compaction completes. As sessions progress, relevance decreases while capacity continues to shrink.

This is why the common advice is “just start a new session per task.” It works—but it’s operationally awkward when tasks are related and iterative.

The core idea: explicit structure beats implicit memory

The solution we settled on has two parts:

  1. Structured execution discipline
  2. Explicit save/load skills for session state

The goal is to preserve only what matters for task execution continuity.

Part 1: Make the todo list the spine of the workflow

CC handles complex requests by breaking them into a logical set of todos and keeps track of progress. CC uses ToDo tool for this.

We embrace this todo based approach to task execution explicitly.

  • Collaborate with CC to manage execution through todo list
  • Keep the active todo list visible
  • Treat it as the authoritative source of “what matters next”

CC may sometimes not use or expose the todo list, and you should ask it to when that happens.

This matters because once work is structured:

  • you know what context must survive
  • you know what can be discarded
  • you stop relying on long conversational memory

Part 2: Save only what the future needs

With this clear task structure, the problem becomes manageable.

We built a small set of Claude Code skills to:

  • extract:
    • the active to-do list
    • context required to complete the current task
    • context required for upcoming tasks
  • write that state to disk
  • clear the entire session context (/clear manually to allow intervention)
  • reload only the saved state into a fresh session

Effectively, sesssave => /clear => sessload

This improves available context space, allows staying in session with optimal contexts, and improves context performance over auto-compact in many cases.

Remember to disable auto-compact using /config.

Supporting mechanics (briefly)

A few supporting details make this practical at scale:

  • We run multiple Claude Code sessions per workspace
  • Each session is explicitly named (with timestamps)
  • Saved state is written to a predictable local folder
  • Reload always selects the most recent state for that session

These are implementation details, not requirements. The pattern works even without them.

github goclaude