[FEATURE] Option to disable cross-session command history in up-arrow
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 I press up-arrow to recall previous prompts, I see history from all my Claude Code sessions — not just the current one.
I run multiple sessions simultaneously. This global history pool is actively hostile. I want to disable it.
Real-World Example
Started a session at 2:01 PM (session b2d3b7bf). Later started a new session at 5:38 PM (session 9d0f6155).
When I press up-arrow in the new session, I see dozens of repetitions of:
/resume b2d3b7bf-c89b-46d1-91fc-186b0e721556
⎿ Session b2d3b7bf-c89b-46d1-91fc-186b0e721556 was not found.
This is a dead session that no longer exists. It pollutes my up-arrow history in every subsequent session. I have to press up-arrow 50+ times to get past the garbage to find anything useful.
Current Behavior
Up-arrow shows prompts from every session I've ever run, mixed together, including:
- Commands for sessions that no longer exist
- Slash commands (
/) from other projects - Prompts meant for completely different codebases
Requested Behavior
Add a setting to disable global command history:
// ~/.claude/settings.json
{
"commandHistoryScope": "session" // only current session
}
Or simply:
{
"disableGlobalHistory": true
}
When enabled, up-arrow shows nothing from previous sessions. Fresh start every time.
Why This Matters
- Dead session IDs pollute history indefinitely
- Multi-project workflows become unusable
- No way to clear this garbage without manually editing files
- Current behavior adds cognitive load with zero opt-out
Environment
- Platform: macOS
- Claude CLI version: v2.0.76
- Terminal: iTerm2
---
I'm not asking to change the default. Just give me a flag to turn it off.
17 Comments
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Technical note:
~/.claude/history.jsonlalready storessessionIdper entry:The data model already supports per-session history. The CLI just is not filtering by current
sessionIdwhen populating up-arrow results. Should be a straightforward fix—filter on read, not a schema change.Additional context:
--fork-sessioncreates a newsessionId, but the forked session still sees the parent's history (and sibling sessions' history) via up-arrow. This defeats the purpose of forking for users running multiple concurrent sessions.Confirmed on Linux, Claude CLI v2.1.19.
This is a recurring issue. Related tickets that have been closed as duplicates:
The core argument: The entire point of
--fork-sessionis to create an independent branch. If I fork a session, I expect:A fork that shares input history with its parent and siblings is not a true fork—it's a fork with entangled state. When I press up-arrow in a forked session, I should see that session's commands, not commands from the session I forked from or parallel sessions running in other terminals.
The fix is simple: The
sessionIdfield already exists inhistory.jsonl. Just filter by it when populating readline history. This has been requested for months across multiple issues.+1 for this
+1
+1
@claude propose a fix
Workaround: per-session history search via tmux + fzf
While waiting for a native fix, I built a small open-source tool that solves this:
claude-session-history — press
prefix + Hin tmux to search input history scoped to your current Claude Code session.How it works:
SessionStarthook saves the session's start timestamp + project path to tmux env varsprefix + Htriggers a script that matches thesessionIdin~/.claude/history.jsonlusing those valuesRequirements: tmux, Python 3, fzf
Not a replacement for native per-session ↑ arrow, but it makes multi-session workflows usable today.
+1, this breaks running multiple sessions under screen or tmux
+1, I thought I was going mad running similar prompts in two sessions that seemed be doing the wrong things. FFS
+1 this is really annoying and seems like a simple fix.
The history file (~/.claude/history.jsonl) already stores a sessionId field per entry — the infrastructure to support this exists. Please ether change the default or add a setting (env var or settings.json option) to filter up-arrow history by the current sessionId instead of just by project directory.
This is urgently needed! It's chaos with multiple concurrent sessions!
Seeing this again today. And also getting permission prompts from one session in a different session.
Along with
/cleardeleting session history now, it seems like someone really fubared the session handling./clear has always done that (or at least, has since I started using claude). Got bit by that once, never used it again.
I use
/clear,/rename, and/forkconstantly to manage context. It's never done this for me before. At least for several months. I stay on 'stable', though.Adding a more severe case: conversation context bleeding between concurrent sessions
I experienced a more serious variant of this issue that goes beyond up-arrow history mixing.
Setup: Two Claude Code chat windows open simultaneously in VS Code, same project directory.
What happened:
I opened Chat A fresh to work on a specific task (Raspberry Pi setup)
I opened Chat B separately to investigate an unrelated issue (project file path resolution), intentionally keeping it separate to avoid contaminating Chat A
After finishing work in Chat B and returning to Chat A, the model in Chat A had detailed knowledge of the conversation that happened in Chat B — including reasoning, decisions made, and the full conversation flow — without me ever sharing that information in Chat A
Chat A's visual history showed a clear gap (none of those messages appeared there), yet the model responded as if it had been present in Chat B's conversation the whole time
This is not just up-arrow history. The model's active context was contaminated with content from a parallel session. I deliberately isolated my investigation to Chat B to keep Chat A clean — that isolation was completely defeated.
This matches what @Reithan reported: "Also getting permission prompts from one session in a different session" — session boundaries are leaking at multiple levels.
Platform: macOS, VS Code extension, claude-code
+10
critical feature