Skip to main content

Overview

The /clear command clears the current conversation history, frees up context space, and starts a fresh session. This is useful when you want to begin a new topic or when your conversation history becomes too long.

Usage

In Interactive Mode

Alternative Names

The following aliases are available:
  • /clear
  • /reset
  • /new

What It Does

When you run /clear, the command:
  1. Clears Terminal: Removes all messages from the display
  2. Resets Chat History: Clears the conversation context sent to the AI
  3. Starts New Session: Generates a new session ID
  4. Resets Metrics: Clears token usage and statistics
  5. Preserves Settings: Keeps your authentication and configuration

When to Use

Starting a New Topic

Clear when switching to an unrelated topic:

Context Window Full

If you’re approaching token limits:
Consider using /compress instead if you want to preserve some context while reducing token usage.

Privacy Concerns

Clear sensitive information from context:

Fresh Start

After completing a task:

Behavior Details

What Gets Cleared

  • ✅ Conversation messages
  • ✅ Terminal display
  • ✅ Chat history context
  • ✅ Token usage metrics
  • ✅ Session statistics

What Gets Preserved

  • ✅ Authentication credentials
  • ✅ Model selection
  • ✅ Configuration settings
  • ✅ Custom themes
  • ✅ Extension settings

Session IDs

Each /clear generates a new session ID:

Clear vs Compress

Use /clear when:

  • Starting a completely new topic
  • Conversation is too long and unrelated
  • You want a fresh start
  • Clearing sensitive data

Use /compress when:

  • Continuing the same topic
  • Preserving important context
  • Optimizing token usage
  • Maintaining conversation flow

Command Output

After running /clear:

Resuming Cleared Sessions

Cleared sessions are still saved and can be resumed:
View available sessions:
This opens a session picker where you can select any previous session, including cleared ones.

Automation Examples

Clear After Each Task

Each invocation starts a fresh session automatically in headless mode.

Conditional Clear

Chat Recording

By default, cleared sessions are saved to disk. To disable recording:
With recording disabled:
  • No session history is saved
  • Cannot resume sessions
  • /clear still works but nothing is stored

/compress

Compress context while preserving information

/stats

View session statistics before clearing

--resume

Resume a previous session

--session-id

Use a custom session identifier

Troubleshooting

Clear Not Working

If /clear doesn’t seem to work:
  1. Verify you’re in interactive mode
  2. Check if there’s a pending operation
  3. Try force-quitting and restarting:

Terminal Not Clearing

If the terminal display isn’t clearing:

Context Still Preserved

If the AI seems to remember cleared context:
  1. Wait a moment for the reset to complete
  2. Verify the new session ID changed: /stats
  3. Try restarting Qwen Code completely

Best Practices

Don’t clear too often - each clear loses valuable context:
  • Clear when switching major topics
  • Use /compress for minor topic shifts
  • Let conversations flow naturally
Before clearing, check your usage:
You might not need to clear yet.
Note session IDs of important conversations before clearing:
Export before clearing if you want to keep a record:

See Also

Context Management

Learn about context and token management

Session Management

Understanding sessions and history

Interactive Mode

Full guide to interactive mode

CLI Overview

All CLI commands and options