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:
- Clears Terminal: Removes all messages from the display
- Resets Chat History: Clears the conversation context sent to the AI
- Starts New Session: Generates a new session ID
- Resets Metrics: Clears token usage and statistics
- 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:Automation Examples
Clear After Each Task
Conditional Clear
Chat Recording
By default, cleared sessions are saved to disk. To disable recording:- No session history is saved
- Cannot resume sessions
/clearstill works but nothing is stored
Related Commands
/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:
- Verify you’re in interactive mode
- Check if there’s a pending operation
- 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:- Wait a moment for the reset to complete
- Verify the new session ID changed:
/stats - Try restarting Qwen Code completely
Best Practices
Clear Strategically
Clear Strategically
Don’t clear too often - each clear loses valuable context:
- Clear when switching major topics
- Use
/compressfor minor topic shifts - Let conversations flow naturally
Check Stats First
Check Stats First
Before clearing, check your usage:You might not need to clear yet.
Save Important Sessions
Save Important Sessions
Note session IDs of important conversations before clearing:
Combine with Export
Combine with Export
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
