[BUG] /clear command doesn't clear terminal scrollback buffer - history reappears on window resize

Status Fixed / completed
Maintainer reply None cached
Activity 4 comments · opened Jan 14, 2026 · closed Feb 12, 2026

Environment

  • Platforms: Windows, macOS
  • Terminal: Standard terminal emulators

Description

The /clear command hides the chat history visually but doesn't clear the terminal's scrollback buffer. When resizing the terminal window, the chat history reappears.

Steps to Reproduce

  1. Start Claude Code CLI
  2. Have a conversation with some messages
  3. Run /clear
  4. Resize the terminal window
  5. Previous chat history becomes visible again

Observed Behavior

  • Context is cleared correctly
  • Visual output is hidden initially
  • On terminal window resize, the previous chat history reappears in the terminal

Expected Behavior

The /clear command should clear both the conversation context AND the terminal scrollback buffer so that previous messages don't reappear.

View original on GitHub ↗

4 Comments

balandari · 8 months ago

Privacy/Security perspective on this bug

Just encountered this same issue on Windows 11 Pro (v10.0.26200.7628) with Claude Code 2.1.20 (npm) in PowerShell/Windows Terminal.

Beyond the UX inconvenience, there's a privacy concern worth highlighting:

After /clear, my terminal scrollback contained:

  • Government agency confirmation numbers
  • Personal mailing addresses
  • Employment status details
  • Account/application information

Users may reasonably expect /clear to clear sensitive conversation data from view. If someone else accesses the terminal after /clear, they can see the full previous conversation.

Suggested fixes (in order of preference):

  1. Actually clear terminal scrollback (ANSI clear + reset scrollback buffer)
  2. Rename to /reset with docs clarifying it only resets context, not display
  3. Add separate /cls or /clearscreen command for display clearing

Evidence: 22 screenshots documenting the issue - previous session content spanning 22 screens on a 32" portrait monitor remained visible after /clear.

---
This comment was written by Claude (Opus 4.5) on behalf of @balandari as part of our AI-assisted development workflow.

nerminba · 8 months ago

I'd like to add, this clear issue affects Claude Code Desktop as well. Clear has stopped working there completly, only way to clear the session is to archive current session, to delete it and to start completly new session.

nerminba · 8 months ago

Is this fixed?

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.