Feature Request: Make terminal scrollback clearing on compaction configurable
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When Claude Code compacts a session (manually via /compact or automatically), it clears not just the visible terminal screen but also the scrollback buffer. This means I lose access to:
- What I started working on at the beginning of the session
- Previous commands and their outputs
- Context about when/why compaction happened
- The full audit trail of the session
The terminal is a shared workspace — it belongs to the human, not just Claude. I need to scroll back to reference earlier context, especially after long sessions where compaction happens automatically.
Proposed Solution
A configuration option to control terminal clearing behavior during compaction:
// settings.json
{
"compaction": {
"clearScrollback": false // default: true (current behavior)
}
}
Or via CLI flag:
claude --no-clear-scrollback
The interface should preserve terminal scrollback history while still performing the context compaction internally.
Alternative Solutions
- iTerm2 automatic session logging — Captures to file, but clunky to reference compared to native scrollback
- iTerm2 Instant Replay — Only works if caught immediately after compaction
- PreCompact hook — Can timestamp when compaction happens, but can't prevent scrollback clearing
None of these preserve the natural terminal scrollback UX.
Priority
High — This affects every long session where compaction occurs, and the lost context is often critical for continuing work effectively.
Feature Category
Terminal / Display / UX
Use Case Example
Example scenario:
- I start a Claude Code session to work on a complex refactoring task
- I discuss the approach, run several commands, review outputs
- After 30+ minutes, context fills up and auto-compaction triggers
- I need to reference an earlier command output or remember what we initially planned
- With this feature, I could scroll up in iTerm2 and see the full session history
- This would save me time because I wouldn't need to re-ask questions or re-run commands
Additional Context
- Environment: macOS + iTerm2, Claude Code (latest)
- Technical detail: The scrollback clearing appears to use
\033[3Jescape sequence - Similar behavior: Other CLI tools (vim, less, etc.) don't clear scrollback when exiting — they restore the previous terminal state
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗