Grok Build CLI: Sessions, Rewind and Compaction
Every conversation with Grok is a session, and every session is saved to disk under ~/.grok/sessions/ the moment it starts. That means you never lose work, you can pick up exactly where you left off, and you can undo a bad turn by restoring real file snapshots. This part covers how to move through sessions like a power user.
New to the series? Start with Grok Build CLI: Zero to Hero (Start Here).
Resume anything
Three ways to get back into a conversation. Continue the most recent one in this directory, resume a specific id, or list everything across all your workspaces.
Inside the TUI, Ctrl+S opens the session picker, and the welcome screen lists recent sessions for the current directory.
The session slash commands
Most session work happens through a handful of commands. Start fresh, open the picker, compress history, check your context budget, or share a read-only snapshot.
Rewind: undo by file snapshot
This is the feature that changes how you do large refactors. Grok records a snapshot of your files at every prompt. /rewind lets you pick an earlier point and restores every file to its state then, while truncating the conversation back to that moment.
It is more reliable than asking the agent to "undo," because it restores actual file contents rather than reasoning backwards. One caveat: rewind writes to disk, so anything it reverts is gone unless it is in git.
Compaction keeps you fast
Long sessions fill the context window. /compact compresses the history and you can tell it what to preserve. Grok also auto-compacts when you approach the limit, configurable with auto_compact_threshold_percent (default 85). Use /context to see exactly how much of the window you are using before it becomes a problem.
Tip: compact proactively at natural breakpoints. A lean context window keeps responses sharp and cheap.
What lives on disk
A session directory holds the conversation log, the raw chat history, the todo or plan state, rewind snapshots, and any subagent child sessions. The snapshots are usually the largest part, which is why heavy-edit sessions grow fast. Compaction trims the history; git keeps your real safety net.
Continue the series
The full series
- Grok Build CLI: Zero to Hero (Start Here)
- Grok Build CLI: Sessions, Rewind and Compaction (you are here)
- Grok Build CLI: Slash Commands and Keyboard Mastery
- Grok Build CLI: Teaching Grok Your Project (AGENTS.md)
- Grok Build CLI: Models and Custom Endpoints
- Grok Build CLI: Extending Grok with MCP, Skills, Plugins and Hooks
- Grok Build CLI: Cross-Session Memory
- Grok Build CLI: Subagents, Plan Mode and Background Work
- Grok Build CLI: Headless Mode and Automation
- Grok Build CLI: Sandbox and Permissions
- Grok Build CLI: IDE Integration with ACP
- Grok Build CLI: The Evolution (Power-User Version History)