Auto-copy Claude Code Resume Command to Clipboard on Session End

Auto-copy Claude Code Resume Command to Clipboard on Session End

Sometimes you need to exit and restart a Claude Code session. When you do, it prints a claude --resume {session_id} command to pick up where you left off. Dragging to copy it every time got old, so I automated it.

Claude Code hooks can automate this.

Setup

Add a SessionEnd hook to ~/.claude/settings.json:


"hooks": {
  "SessionEnd": [
    {
      "hooks": [
        {
          "type": "command",
          "command": "jq -r '\"claude --resume \" + .session_id' | pbcopy"
        }
      ]
    }
  ]
}

On session end, the hook receives session info as JSON. jq extracts the session_id, assembles the resume command, and pbcopy puts it on your clipboard.

Usage

Exit a session, hit Cmd+V in your terminal. That's it.