agent-fork
Forking a session is easy; forking your files isn't. This Claude Code /
Codex skill gives the forked session its own branch and worktree with every
uncommitted file copied and verified.

You are deep in a Claude Code, Codex, Muse, OpenCode, or borg1 session. The agent has context you do not
want to rebuild, and your working tree is full of uncommitted work. Now you want
to try a second approach — without stashing, without losing the first one, and
without starting the conversation over.
The agent-fork skill does that without leaving the conversation. Type
/agent-fork try-redis (Claude Code) or $agent-fork try-redis (Codex) and it
creates a new branch and a linked Git worktree, copies your current staged,
unstaged, and untracked files into it, verifies the copy matched, and prints
the exact command that continues this conversation in that new worktree. Your
original worktree and session are never touched.
Underneath the skill is a standalone agent-fork CLI that does the same work
from any terminal. Outside an agent session it prints a cd command instead of
a session-continuation command, so the same tool covers plain Git workflows.
Demo
From inside your Claude Code or Codex session (the skill installs into those two; inside OpenCode, run the agent-fork CLI):
/agent-fork try-redis # fork without leaving the conversation
Don't have the skill yet? One command installs it for both agents:
npx skills@latest add smorinlabs/agent-fork
The skill previews the fork — target branch, destination worktree, the files it
would carry — and asks for confirmation before creating anything. It drives the
CLI below, which works directly from a terminal too:
$ agent-fork fork try-redis --dry-run
branch: create fork/try-redis
worktree: create /Users/you/code/myapp-fork-try-redis
files-to-carry: staged=3 unstaged=7 untracked=2 ignored=0
setup-hook: none
paste command: cd /Users/you/code/myapp-fork-try-redis && claude --session-id 9b74b9f2-f3d2-4060-b233-0121ac17ed7c --resume c854b79c-16b2-4863-a095-03d35d195ec9 --fork-session -n try-redis
validation: local-only; no mutation performed
Drop --dry-run and the fork is created. Paste the final line into a fresh
terminal and the agent picks up where it left off — same context, new branch,
your uncommitted work already there.
The skill
The full set of skill invocations:
/agent-fork try-redis # explicit fork name
/agent-fork try-redis --now # fork immediately, no confirmation
/agent-fork # fork with context-aware naming
/agent-fork --session # inspect this agent session
/agent-fork --session-only # print only the native session-fork command
Codex invokes the same skill as $agent-fork; every form above is otherwise
identical.
The skill delegates operations to the CLI. It first validates a session
inspection, then uses the selected runner for the operation's command:
| Skill form | CLI call | Result |
|---|
| The fork forms | agent-fork fork ... --require-agent --json | The branch, the worktree, and the paste command |
--session | agent-fork session --json | The session inspection plus its transcript path and its native fork and resume commands |
--session-only | agent-fork session --json | Only that native fork command |
The fork's name comes from one of three places:
- A name hint you typed is normalized to lowercase kebab-case
(
"Review Auth" becomes review-auth).
- With no hint on a topic branch — an ordinary feature branch — the CLI
derives the name automatically (dated, with a suffix if it collides).
- With no hint on the default branch, a detached HEAD, or an unclassifiable
branch, the skill proposes a name from the conversation.
Every fork is confirmed before it exists: the skill runs a dry run, shows you
the target branch, the destination worktree, and the files it would carry,
and creates the fork only after you approve. --now skips that confirmation;
the name is still chosen the same way.
The skill uses the installed agent-fork CLI when its output supports the
requested operation. If the CLI is missing or lacks a required field, the
assistant runs the operation through uvx from the official Git repository.
It uses uv tool run when only uv is available. Fetching the tool does not
add a confirmation question; the environment's execution permissions apply.