Claude Code CLI erases terminal scrollback history during long sessions
Bug Description
During Claude Code sessions, the terminal scrollback history is erased. Messages from the beginning of the conversation disappear and cannot be scrolled back to. Only recent messages remain visible. This happens even in relatively short sessions (~1 hour or less).
Reproduction
- Start a Claude Code session (Opus 4.6, 1M context, Claude Max)
- Have hooks configured (PreToolUse, PostToolUse, Stop) that trigger on most tool calls
- Work normally with tool calls (file reads, writes, subagents, Chrome MCP, etc.)
- After some time, try to scroll up to the beginning of the conversation
- The early messages are gone — scroll only reaches a recent message
Possible Cause: Hooks Output
The project has multiple hooks configured in settings.local.json:
- PreToolUse hooks: CSS origin warning, damage-control, memory injection — fire on most Write/Edit/Agent calls
- PostToolUse hooks: formatter (fires after every edit)
- Stop hooks: delivery-gate check (fires at end of each response)
Each hook invocation generates additional terminal output (the hook command, its result, system-reminder injection). This may be causing Claude Code to clear or overwrite the terminal scrollback buffer much faster than normal usage without hooks.
This does NOT happen with Codex CLI or Gemini CLI on the same terminal, same machine, same session — even after longer sessions. Those tools do not have a hooks system.
Expected Behavior
The full conversation history should remain in the terminal scrollback buffer regardless of hooks activity.
Evidence This Is Claude Code Specific
On the same machine, same terminal (macOS Terminal.app), same session:
- Codex CLI: Full conversation history preserved — can scroll back to previous day's sessions
- Gemini CLI: Full conversation history preserved
- Claude Code CLI: History erased, sometimes within 1 hour
Terminal scrollback buffer is set to default (large enough for Codex/Gemini). This is not a terminal settings issue.
Impact
- Users lose access to earlier conversation context, making it impossible to copy/paste results
- Users cannot review what happened earlier in the session
- Combined with context compression, this creates a double loss: the model loses internal context AND the user loses visible history
Environment
- Claude Code v2.1.91 / v2.1.92
- macOS Darwin 24.6.0 (Mac mini M-series)
- Terminal.app (default macOS terminal)
- Model: Opus 4.6 (1M context), Claude Max subscription
- Hooks: 4 PreToolUse + 2 PostToolUse + 1 Stop configured
- Context usage at time of bug: ~160K tokens (well under 1M limit)
- Observed across multiple sessions and multiple simultaneous Claude Code instances
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗