Codonic

hopsesh guide · Claude Code

Claude Code history gone after moving a project folder? How to get it back

Nothing is deleted: the sessions are filed under the old path. How to find them, rename the project folder, where Claude Code’s own /cd stops, and the same for Codex.

What you see after moving or renaming a project folder

You renamed ~/git/app to ~/git/app-new, or moved it into another folder, and opened Claude Code there. Then:

  • claude --continue prints No conversation found to continue;
  • claude --resume opens a picker with none of your old sessions;
  • the session you were in last week seems gone.

The sessions are still on disk. They are filed under the old path.

Why: sessions belong to the folder’s path, not the folder

Claude Code stores each session at ~/.claude/projects/<project>/<session-id>.jsonl, where <project> is the working directory’s absolute path with every character that isn’t a letter or digit replaced by -. A session from /Users/kim/git/app lives in:

~/.claude/projects/-Users-kim-git-app/

After the rename, Claude Code in /Users/kim/git/app-new looks in -Users-kim-git-app-new/, which is empty or doesn’t exist. claude --continue only reopens the newest session of the current directory, and the picker starts with the current worktree, so neither shows the old ones.

The same folder holds the project’s auto memory (memory/), so Claude’s notes about the project seem to vanish too. And Claude Code’s per-project state in ~/.claude.json, which holds the folder’s trust answer and its local-scope MCP servers, is keyed by the old path: the new folder asks for trust again.

Find the old sessions first

Before fixing anything, check they are there:

ls ~/.claude/projects/ | grep app
ls -t ~/.claude/projects/-Users-kim-git-app/

Or, from inside Claude Code, open the picker with claude --resume and press Ctrl+A to show sessions from every project on this computer. A session’s id is its file name without .jsonl.

The manual fix: rename the project folder

To bring every session of the old folder along at once, give its project folder the new path’s name:

cd ~/.claude/projects
mv -- -Users-kim-git-app -Users-kim-git-app-new

The -- matters: the names start with a dash, which mv would otherwise read as options. If -Users-kim-git-app-new already exists because you started a session in the new folder, move the contents in instead: mv -- -Users-kim-git-app/* -Users-kim-git-app-new/.

Things to know:

  • Do it with Claude Code closed in both folders, so nothing is writing to the files as they move.
  • Paths inside the transcripts are still the old ones. Each tool call recorded /Users/kim/git/app/.... The resumed session reads them as history; tell Claude where the project is now if it reaches for an old path.
  • Long paths are hashed. When the converted name passes 200 characters, Claude Code cuts it and adds a hash of the full path, which you can’t work out by hand. Start one session in the new folder and use the folder name it creates.
  • Moving a worktree? Each worktree is its own working directory, so it has its own project folder.

Claude Code’s own /cd, and where it stops

Claude Code has a command for this: inside a session, /cd <path> moves the session to a new working directory and keeps the conversation. Claude Code relocates it to the new directory’s project storage, so it appears in that directory’s picker afterwards, loads the new folder’s CLAUDE.md, settings, hooks and MCP servers, and asks you to trust the folder if it’s new.

To use it on a session from the old folder:

  1. Open it by id from anywhere: claude --resume <id>. Since Claude Code 2.1.223 the id is looked up in every project folder on this computer, as long as only one holds it; earlier versions only look in the current directory’s.
  2. Type /cd ~/git/app-new in the session.

Where it stops:

  • One open session at a time. /cd works from inside a running session. Ten sessions of the old folder take ten resumes.
  • This computer only. It can’t move a session on your other computer.
  • Claude Code only. Codex keeps its sessions differently (below).
  • No undo beyond running /cd back.

For a single session you are about to keep working in, /cd is the right tool. To move everything at once, rename the project folder.

Codex: the folder is recorded inside the session

Codex files its sessions by date, as rollouts under ~/.codex/sessions/YYYY/MM/DD/, and records the working directory inside each one. Moving a project doesn’t strand the files, but codex resume only lists sessions from the current directory, and codex resume --last picks the newest one there. After a rename:

codex resume --all                       # show sessions from every directory
codex resume <id> -C ~/git/app-new       # resume one in the new folder

When the current directory differs from the session’s saved one, Codex asks which to use; tui.resume_cwd in config.toml ("current" or "session") remembers the answer. Codex also has a /cd command for an idle, open session.

Move a session to another folder with hopsesh cd

hopsesh is a free, open-source command-line tool, terminal UI and app for macOS and Windows that moves Claude Code and Codex sessions between folders, computers and agents. hopsesh cd continues a session in another folder and keeps it the same session: the same id, every message, tool call and reasoning block as the agent wrote them.

hopsesh cd 7f3c2a1e ~/git/app-new --dry-run   # the plan; changes nothing
hopsesh cd 7f3c2a1e ~/git/app-new             # do it
hopsesh undo                                  # and back

In the app, it is Change folder… in a session’s ⋯ menu. Each agent’s way:

  • Claude Code: what its own /cd does. The transcript and its side folder move to the new folder’s project folder and get the same relocated record. If the session is open, hopsesh tells you to type /cd <dir> in it and waits until Claude Code has moved it.
  • Codex: Codex itself resumes the thread in the new folder, as codex resume -C does, with no turn and no model call, and records it. hopsesh doesn’t use Codex’s /cd, which starts a new thread.

The new folder must be a checkout of the session’s repository, another worktree or clone, so the conversation still matches the files. When the old folder is gone after a rename, hopsesh can’t compare the two and says so: pass --other-repo to move it anyway. On another of your computers, hopsesh cd studio:7f3c2a1e ~/git/app-new has hopsesh there make the change (set it up first with hopsesh hosts setup studio), and hopsesh undo here reverses it there.

hopsesh moves one session per command, like /cd, but closed or open, on any of your computers, for both agents, with undo. To take a session to another computer rather than another folder, see how to move a Claude Code session to another computer and how to resume a Codex session on another machine.

hopsesh is alpha software. It has no server and no telemetry, and it never calls the Anthropic or OpenAI API. It is an independent project, not affiliated with Anthropic or OpenAI.

Sessions after moving a project

Did renaming my project folder delete my Claude Code sessions?

No. They are still in ~/.claude/projects, in the folder named after the old path, such as -Users-kim-git-app. Claude Code in the renamed folder looks in a folder named after the new path, so it doesn’t see them. Press Ctrl+A in the claude --resume picker to list them.

How do I move all of a project’s sessions to its new folder?

With Claude Code closed, rename the project folder under ~/.claude/projects to the new path’s name: mv -- -Users-kim-git-app -Users-kim-git-app-new. That brings the project’s auto memory along too. The paths recorded inside the old sessions stay as they were.

What does /cd do in Claude Code?

/cd <path> moves the open session to a new working directory and keeps the conversation. Claude Code relocates it to that directory’s project storage, loads its CLAUDE.md, settings, hooks and MCP servers, and asks you to trust the folder if it’s new. It moves one open session at a time.

Can I resume a session from a folder that no longer exists?

Yes. claude --resume <id> works from any directory: Claude Code looks for the id in every project folder on the computer, as long as only one holds it. Then /cd moves it to the new folder. In Codex, codex resume --all lists sessions from every directory.

Does Codex lose sessions when I move a project folder?

Codex files sessions by date, not by folder, so the files stay where they are. But codex resume only lists sessions from the current directory, so use codex resume --all, or codex resume <id> -C <new folder>.

Use the method

Try it with hopsesh

Open-source CLI and desktop app: move a Claude Code or Codex session to another computer, into the other agent, or to the cloud, with undo built in.

See everything hopsesh does →
Install the CLI Terminal macOS and Linux · Command line and terminal UI curl -fsSL https://raw.githubusercontent.com/roeehrl/hopsesh/main/scripts/install.sh | sh Checks the download against the release’s checksums.txt and its signature. hopsesh update installs later releases with the same checks.
Install the CLI Terminal Windows, in PowerShell · Command line and terminal UI irm https://raw.githubusercontent.com/roeehrl/hopsesh/main/scripts/install.ps1 | iex Same checks as the macOS and Linux script. The Windows app installs this command as well.
hopsesh for Mac .dmg macOS app · macOS 13 or later · Apple silicon and Intel Download Signed and notarized by BlueGuru LLC. The same engine as the CLI, with a plan sheet for each move. Updates itself from Settings → Updates.
hopsesh for Windows .exe Windows app · Windows 10 or 11 · x64 Download Not code-signed yet, so SmartScreen says “Windows protected your PC”: click More info, then Run anyway. With Smart App Control on, Windows 11 blocks it. Installs for your user only, no administrator rights, and puts the hopsesh command on your PATH.
More ways to install
  • Installer for Arm64 Windows 10 or 11 on Arm
  • Portable .zip x64 or Arm64, no install, on the release page
  • Command line only in PowerShell, without the app irm https://raw.githubusercontent.com/roeehrl/hopsesh/main/scripts/install.ps1 | iex
Linux packages and all files GitHub Latest release · .deb, .rpm and .apk for amd64 and arm64, a portable Windows app .zip, plus archives Open on GitHub Release notes, checksums and every build of the current version. Source on GitHub GitHub Apache-2.0 · Go 1.26 or later to build Open on GitHub From source: go install github.com/roeehrl/hopsesh/cmd/hopsesh@latest