/compact — Context Compaction
The/compact command reduces conversation history size so it fits within the model’s context window, preserving the most important information.
Usage Modes
- Automatic
- Guided
Without arguments, runs the 3-level compaction pipeline:The automatic pipeline follows this order:
- Level 1 — Trimming (near-lossless): strips
<reasoning>tags, compacts XML, removes duplicates - Level 2 — Structured summarization: extracts facts (files read, modified, commands executed, decisions) in bullet point format
- Level 3 — Emergency truncation: drops middle messages, keeping system prompt and recent messages
How It Works
Message Preservation
In both modes:- System messages are always fully preserved
- Recent messages (4 in guided, 10 in automatic) are kept verbatim
- Only the middle block is summarized or removed
- Metadata indicates the message is a summary (
IsSummary: true)
Example Output
After compaction, a summary message replaces the middle messages:/rewind — Go Back in Time
/rewind lets you restore the conversation to an earlier point, undoing unwanted messages and responses.
How It Works
ChatCLI automatically saves checkpoints of the conversation before each LLM call. You can revert to any of those points.Keyboard Shortcut: Esc+Esc
Press Esc twice quickly (less than 500ms between presses) to open the rewind menu directly from the prompt, without typing/rewind.
Limits
- A maximum of 20 checkpoints are kept (oldest ones are discarded)
- Checkpoints exist only in the current session (not persisted to disk)
- When rewinding, checkpoints after the restored point are removed
Unified History
ChatCLI uses a single history array shared across all modes (chat, agent, coder). This means:- Switching between
/agent,/coder, and chat preserves all context - The AI doesn’t “forget” what was done in another mode
/compactand/rewindoperate on the complete history, regardless of mode
Sessions saved with older ChatCLI versions that used separate per-mode histories are automatically converted when loaded — histories are merged in chronological order.
When to Use
/compact (automatic)
When ChatCLI warns that the context is large, or when you notice degraded responses.
/compact <instruction>
When you know exactly which information is critical and must not be lost during compaction.
/rewind
When the AI took a wrong path, generated incorrect code, or you want to try a different approach.
Esc+Esc
Quick shortcut for rewind without leaving your typing flow.