claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Feature Request: Session Resumption for Claude Code CLI

Open metaColin opened this issue 8 months ago • 8 comments

Problem

Terminal crashes and disconnections currently result in complete loss of context and work progress in the Claude Code CLI. Unlike the web interface which offers the ability to resume a previous session, CLI users must start from scratch after any interruption, leading to significant productivity loss and frustration. CLAUDE.md is proving to be insufficient for re-teaching claude-code what it needs to know in order to effectively resume a prior session.

Proposed Solution

Implement a session resumption feature for Claude Code CLI that:

  • Automatically saves session state at regular intervals
  • Allows users to resume their most recent session after a crash or disconnection
  • Provides a command to list and select from previous sessions (e.g., claude resume or claude sessions list)
  • Preserves all context, including file reads, searches, and conversation history

User Impact

This would significantly improve the CLI experience by:

  • Preventing loss of complex contextual knowledge about codebases
  • Eliminating repetitive work explaining project requirements
  • Making the CLI version equally resilient to the web version
  • Supporting long-running development tasks that are prone to interruption

Technical Considerations

  • Storage of session data should respect security and privacy constraints
  • Session resumption should be lightweight and quick to initialize
  • Consider offering configurable retention periods for saved sessions

Why This Matters

Power users who prefer CLI interfaces shouldn't have fewer features than web users. Session resumption is especially critical in terminal environments where disconnections and crashes are more common than in browser interfaces. Currently I am so frustrated by this oversight I am looking for a Claude-Code alternative but I wouldn't need one if Anthropic would introduce this feature.

metaColin avatar May 26 '25 23:05 metaColin

I guess this is a hidden feature but there are logs of your convos per project in ~/.claude/projects/-Users-<YOUR-USERNAME>-<PATH>-<TO>-<PROJECT>/ there's a bunch of jsonl files i don't know how much of the history it preserves but if you lose something critical hopefully it helps.

hesreallyhim avatar May 27 '25 02:05 hesreallyhim

Can't you just use continue and resume to do this?

claude --help
Usage: claude [options] [command] [prompt]

Claude Code - starts an interactive session by default, use -p/--print for non-interactive output

Arguments:
  prompt                          Your prompt

Options:
  -d, --debug                     Enable debug mode
  --verbose                       Override verbose mode setting from config
  -p, --print                     Print response and exit (useful for pipes)
  --output-format <format>        Output format (only works with --print): "text" (default), "json" (single result), or "stream-json" (realtime streaming) (choices: "text", "json", "stream-json")
  --mcp-debug                     [DEPRECATED. Use --debug instead] Enable MCP debug mode (shows MCP server errors)
  --dangerously-skip-permissions  Bypass all permission checks. Only works in Docker containers with no internet access.
  --allowedTools <tools...>       Comma or space-separated list of tool names to allow (e.g. "Bash(git:*) Edit Write")
  --disallowedTools <tools...>    Comma or space-separated list of tool names to deny (e.g. "Bash(git:*) Edit Write")
  --mcp-config <file or string>   Load MCP servers from a JSON file or string
  -c, --continue                  Continue the most recent conversation
  -r, --resume [sessionId]        Resume a conversation - provide a session ID or interactively select a conversation to resume
  --model <model>                 Model for the current session. Provide an alias for the latest model (e.g. 'sonnet' or 'opus') or a model's full name (e.g. 'claude-sonnet-4-20250514').
  -v, --version                   Output the version number
  -h, --help                      Display help for command

Commands:
  config                          Manage configuration (eg. claude config set -g theme dark)
  mcp                             Configure and manage MCP servers
  migrate-installer               Migrate from global npm installation to local installation
  doctor                          Check the health of your Claude Code auto-updater
  update                          Check for updates and install if available

StephenBadger avatar May 27 '25 14:05 StephenBadger

oh... yeah, i was assuming OP was talking about some kind of crash that caused the resume-session thing to fail. but if OP doesn't know about -r and -c, yeah that is the way to go.

hesreallyhim avatar May 27 '25 14:05 hesreallyhim

It sounds like maybe this feature is included and I didn't realize it.

Ironically the first time I experienced a session crash, I re-opened my IDE's terminal invoked Claude-code and asked if there was a way we could resume our previous session.

Claude assured me there was not, lamented that the CLI lacked this feature even though it's available via the Web UI, suggested I open an issue, and helped me write this feature request describing what was missing.

So yea it's on me for not RTFM, but it's also on Claude for assuring me this feature did not exist and it would be valuable feedback for me to escalate this issue to the dev team.

metaColin avatar May 27 '25 16:05 metaColin

Same, I remember something about --continue but at this pace I never know if I actually heard it or misremembering.

Also asked Claude for the feature, he assured me no such feature exist and pointed me to various issues with feature requests.

Now here I realize that it is indeed existing, so the actual problem is that Claude should RTFM, and probably have it as a tool call.

adriangalilea avatar May 27 '25 16:05 adriangalilea

It says in the system prompt that Claude is not allowed to visit the Anthropic docs site.

hesreallyhim avatar May 27 '25 16:05 hesreallyhim

I didn't know about this feature until I read it in the CHANGELOG.md file. Why can't this just also be a slash command inside the claude-code app? Like /resume or /load-session maybe?

skerit avatar May 28 '25 09:05 skerit

Maybe because it would take dev time to implement something that's basically already available by ending your session and typing claude -r...? What's the difference?

hesreallyhim avatar May 28 '25 10:05 hesreallyhim

Yep! You want --continue/--resume. Docs: https://docs.anthropic.com/en/docs/claude-code/cli-usage#cli-flags

bcherny avatar May 29 '25 03:05 bcherny

This works well, thanks!

hargup avatar May 31 '25 11:05 hargup

For enhanced session resumption, #2112 proposes adding --session-name functionality that would make it much easier to identify and resume the correct session after crashes or disconnections.

This would work well with the automatic session state saving requested here - named sessions would be instantly recognizable in the resume picker.

Related session management improvements:

  • #1407 - Session ID retrieval
  • #1335 - Session identification challenges
  • #371 - Original resume feature (implemented)
  • #922 - Resume hanging bug (fixed)

gwpl avatar Jun 15 '25 13:06 gwpl

The ability to name a conversation is important so I can quickly select it when I want to continue the conversation. I look forward to adding this feature.

DnkNju avatar Jul 18 '25 07:07 DnkNju

The ability to name a conversation is important so I can quickly select it when I want to continue the conversation. I look forward to adding this feature.

Yes, similar to tmux

adriangalilea avatar Jul 18 '25 07:07 adriangalilea

@DnkNju https://github.com/iannuttall/claude-sessions what do you think? (not my repo i just googled it cuz of your question, has decent star count)

EDIT: Nevermind I don't think this correlates with Claude internal sessions

hesreallyhim avatar Jul 18 '25 21:07 hesreallyhim

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.

github-actions[bot] avatar Jul 29 '25 16:07 github-actions[bot]