claude-code - 💡(How to fix) Fix claude should resume the last session by default; add --new for fresh sessions [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52556Fetched 2026-04-24 06:04:01
View on GitHub
Comments
2
Participants
2
Timeline
4
Reactions
0
Timeline (top)
commented ×2labeled ×2

Fix Action

Fix / Workaround

Workaround (until fixed)

Code Example

claude-resume () {
    local prev_session=$(jq -r 'select(.project == env.PWD) | .sessionId' ~/.claude/history.jsonl | uniq | tail -2 | head -1)
    if [[ -z "$prev_session" ]]; then
        print -ru2 "claude-resume: no previous session found for $PWD"
        return 1
    fi
    echo "Resuming session: $prev_session"
    claude --resume "$prev_session"
}
RAW_BUFFERClick to expand / collapse

When a user opens Claude Code in a project directory, they almost always want continuity with their last session there. The current design inverts this: every session starts fresh, and resuming requires an explicit --resume <uuid> flag. This treats continuity as exceptional when it should be the default.

Proposed change

  • claude with no flags resumes the most recent session for the current working directory
  • claude --new starts a fresh session explicitly

This mirrors the behavior of editors (restore last open files), terminals (restore history), and IDEs (restore workspace state). Claude Code is currently the odd one out by defaulting to amnesia.

The UUID friction illustrates the problem

When Claude Code quits, it displays a --resume <uuid> suggestion. If the user closes the terminal or starts a new session without noting that UUID, there is no obvious way to recover it — even though it is already persisted in local files:

  • ~/.claude/history.jsonl — contains sessionId per entry with project path
  • ~/.claude/projects/<project-path>/<uuid>.jsonl — the UUID is the filename itself

A user who wants to resume must have manually recorded a value the tooling already knows. This is avoidable friction that penalizes the common case.

Workaround (until fixed)

claude-resume () {
    local prev_session=$(jq -r 'select(.project == env.PWD) | .sessionId' ~/.claude/history.jsonl | uniq | tail -2 | head -1)
    if [[ -z "$prev_session" ]]; then
        print -ru2 "claude-resume: no previous session found for $PWD"
        return 1
    fi
    echo "Resuming session: $prev_session"
    claude --resume "$prev_session"
}

extent analysis

TL;DR

To fix the issue, modify the claude command to resume the most recent session by default when run without flags in a project directory.

Guidance

  • The proposed change suggests using claude with no flags to resume the most recent session for the current working directory, and claude --new to start a fresh session explicitly.
  • The current design can be improved by leveraging the existing session data stored in ~/.claude/history.jsonl and ~/.claude/projects/<project-path>/<uuid>.jsonl.
  • The provided claude-resume function can be used as a temporary workaround to automate the process of resuming the previous session.
  • To implement the proposed change, the claude command needs to be modified to read the session data from the local files and resume the most recent session by default.

Example

The provided claude-resume function demonstrates how to parse the session data from ~/.claude/history.jsonl and resume the previous session using the claude --resume flag.

Notes

The proposed change aims to align the behavior of Claude Code with other editors, terminals, and IDEs, which restore their previous state by default.

Recommendation

Apply the proposed change to modify the claude command to resume the most recent session by default, as it provides a more intuitive and user-friendly experience.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix claude should resume the last session by default; add --new for fresh sessions [2 comments, 2 participants]