Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save odysseus0/2af394c233178ed9f3b29166e330d72c to your computer and use it in GitHub Desktop.
Save odysseus0/2af394c233178ed9f3b29166e330d72c to your computer and use it in GitHub Desktop.
Selective Context Compaction for Claude Code - Feature Proposal

Selective Context Compaction for Claude Code

The Problem

Effective AI agent performance depends on maintaining high signal-to-noise ratio in the context window. Even with large contexts, noise degrades performance.

Claude Code currently offers only "Compact" - a nuclear option that rebuilds the entire conversation from scratch. This is like having only git rebase -i --root when you often just need git rebase -i HEAD~5.

The Git Analogy

Think of context management like git without files - just the commit messages:

  • Conversation messages = Commits
  • Context compaction = Interactive rebase (squashing commits)
  • Sub-agents = Feature branches that squash merge back

Current tools:

  • ✓ Compact entire conversation (git rebase -i --root)
  • ✓ Sub-agents with compressed returns (branch + squash merge)
  • ✗ Compact recent section (git rebase -i HEAD~5)

The Missing Feature: Selective Context Rebasing

Allow compacting from any conversation point, not just from the beginning.

Example: Just spent an hour debugging with 50 back-and-forth messages? Compact just that section into "Fixed auth bug" while preserving the context before it.

This is exactly what developers do with git - clean up recent messy commits without touching the rest of history.

Impact

Selective rebasing enables:

  • Surgical cleanup after verbose tasks
  • Maintained context - keep relevant history, compress only the noise
  • Familiar workflow - developers already think this way with git

Instead of losing everything with nuclear Compact, we get precise control over our conversation history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment