Skip to content
Skills Library
AI & agents · Tool integration

fork-session

/fork-session

Fork or branch a Claude Code or Codex session at its end or a chosen turn, leaving the original untouched. Use for "fork from before X", "rewind without losing the original", "continue from turn 12", "split this session", or reviving an abandoned branch. Also use when Claude resume lost context or jumped to a compacted branch (repair), or to re-ask a Claude form or Codex prompt from an earlier point. Works when invoked from either Claude Code or Codex.

Repository
devdroid ↗
Licence
Apache-2.0
Last repository change
03.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
7
Scripts
4
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 03.11.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What to check before installing
  • 4 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/claude_fork.py, scripts/codex_fork.py, tests/test_claude_fork.py, tests/test_codex_fork.py

What it does and when to use it

Fork or branch a Claude Code or Codex session at its end or a chosen turn, leaving the original untouched. Use for "fork from before X", "rewind without losing the original", "continue from turn 12", "split this session", or reviving an abandoned branch. Also use when Claude resume lost context or jumped to a compacted branch (repair), or to re-ask a Claude form or Codex prompt from an earlier point. Works when invoked from either Claude Code or Codex.

Triggers from the description

fork from before Xrewind without losing the originalcontinue from turn 12split this session
Original author description

Fork or branch a Claude Code or Codex session at its end or a chosen turn, leaving the original untouched. Use for "fork from before X", "rewind without losing the original", "continue from turn 12", "split this session", or reviving an abandoned branch. Also use when Claude resume lost context or jumped to a compacted branch (repair), or to re-ask a Claude form or Codex prompt from an earlier point. Works when invoked from either Claude Code or Codex.

How it works

  1. Find the boundary
  2. Claude: chosen point
  3. Codex: chosen turn
  4. Repair: Claude resume lost context
  5. Re-ask a Claude form
  6. Failures and limits
Original SKILL.md headings · 133 lines, 976 words
SKILL.md preview
---
name: fork-session
description: Fork or branch a Claude Code or Codex session at its end or a chosen turn, leaving the original untouched. Use for "fork from before X", "rewind without losing the original", "continue from turn 12", "split this session", or reviving an abandoned branch. Also use when Claude resume lost context or jumped to a compacted branch (repair), or to re-ask a Claude form or Codex prompt from an earlier point. Works when invoked from either Claude Code or Codex.
---

# Fork Session

Create a new session ID while preserving the original. Select the source agent
and boundary from the request; the invoking agent can fork either runtime.

| Agent | At the end (leaf) | At a chosen turn |
|---|---|---|
| Claude Code | `claude --resume <id> --fork-session` | `scripts/claude_fork.py` |
| Codex | `codex fork <id>` / `codex exec fork <id> [prompt]` | `scripts/codex_fork.py` |

**Continue a Claude session in another folder (same id, no fork):** `cd <folder> && claude --resume <id>`.
Resume-by-id finds the session from any folder, and its tools run in the new folder.
The interactive picker (`claude --resume` with no id) only lists the current folder's sessions, so after
moving a project folder, find the id with browse-chat-history (`cq list`, `cq search`) and resume by id.
To branch it into another folder under a new id instead, use `claude_fork.py … --target-cwd <folder>`.

Use native leaf commands for ordinary continuation from the end. Use a helper
for a specific earlier boundary; Claude repair and form-reask also use its helper.
Run helpers with `python3` (3.9+), from any cwd. Locate this skill's installed
directory from the loaded SKILL.md; resolve `scripts/` and `references/` relative
to it. No particular agent's skill installation path is required.

## Find the boundary

Use **browse-chat-history** for session and turn discovery:

```text
cq search "distinctive words" --provider claude
cq grep "exact phrase" --provider codex
cq context <session-id> @N
cq branches <claude-session-id>
```

`search` prints `msg[N]`, and `grep` prints line numbers. Use `context @N` to
inspect the containing turn; inspect the raw record to obtain its message UUID.
`branches` shows active and abandoned arms; use its UUIDs or raw-line drills to
choose a point on an abandoned arm. If the discovery skill is unavailable, use
a user-supplied source path/ID and boundary, or explain the missing dependency.

For Codex, translate the discovered text to a persisted **turn ID**:

```bash
python3 <skill-dir>/scripts/codex_fork.py --session <id> --find-text "distinctive words"
```

This reports source turn numbers, IDs, status and previews without creating a
fork. Turn numbers are for inspection; pass the full turn ID to the fork flags.
Explain the chosen inclusive/exclusive boundary when reporting the result.

## Claude: chosen point

```bash
python3 <skill-dir>/scripts/claude_fork.py <session-id-or-jsonl> --cut-at-uuid <message-uuid>
python3 <skill-dir>/scripts/claude_fork.py <session-id-or-jsonl> --truncate-at <source-line>
```

UUID is preferred. Each cut walks `parentUuid` from the chosen leaf to root,
preserving that arm, including abandoned history, and excluding sibling arms.
Line cuts are 1-based and inclusive; the last UUID at or before that line is the
leaf. Choose a completed assistant reply. A dangling tool call is refused;
select its completed result/reply instead. Cuts never silently include later turns.

Backups finish before any fork write, under `~/.devdroid/fork-session/backups/`.
The helper clones available project/subagent, session-env, tasks and file-history
sidecars; backup paths include each sidecar's parent kind to avoid collisions.
It rewrites session IDs in the new transcript, repairs known messageId/parent
corruption, and prints the new ID, JSONL path, checks and exact resume command:

```bash
cd <saved-cwd> && claude --resume <new-id>
```

The saved cwd is read verbatim, including spaces and hyphens. To place the fork
in a different existing absolute cwd, add `--target-cwd <directory>`; only the
new transcript's cwd and project storage change. `--project-dir` overrides the
**source storage directory**. `--label` labels its unique backup directory.

## Codex: chosen turn

```bash
python3 <skill-dir>/scripts/codex_fork.py --session <id> --fork-through <turn-id> --name "label"
python3 <skill-dir>/scripts/codex_fork.py --session <id> --fork-before <turn-id> --name "label"
```

Through includes the completed turn and its answer; before excludes that turn
and everything later, useful for re-asking a prompt. Through refuses interrupted
or in-progress turns. IDs, unique ID prefixes and exact unique names are accepted.
The helper calls the official `thread/fork` API with `lastTurnId` or `beforeTurnId`.
It reads rollouts only for discovery/validation and never rewrites or clones them.
It prints the new ID and a `codex --remote unix:// resume <new-id>` command, and
copies the command when a clipboard is available (`--no-clipboard` disables it).

Requires `codex` on PATH with daemon and boundary-fork support. If the daemon
socket is unreachable, it runs `codex app-server daemon start` once and retries
for a bounded interval. `--socket` selects another control socket; the printed
resume command uses the same socket. `CODEX_HOME` is respected.

## Repair: Claude resume lost context

If resume jumped to a compacted branch or lost earlier context, run
`python3 <skill-dir>/scripts/claude_fork.py <id> --label repair`.
This forks the latest parent chain with snapshot-messageId collision and missing
parent fixes. If the desired context is on an abandoned arm, choose its UUID
explicitly using `cq branches`. It cannot reconstruct deleted history or exceed
the model's context window. See [Claude details](references/claude-details.md).

## Re-ask a Claude form

Run `python3 <skill-dir>/scripts/claude_fork.py <id> --reask-form [tool_use_id]`.
No ID selects the last recorded AskUserQuestion; an ID targets a specific form,
including one on an abandoned arm. It drops the answer and later conversation,
balances pending calls with rejected tool results, then appends an interrupt.
Resume and prompt "re-ask what you just asked". See [form-reask](references/form-reask.md).

## Failures and limits

- Unknown/ambiguous IDs, invalid JSON, cycles, invalid cuts and unbalanced tools:
  stop before creating a fork; inspect the boundary with browse-chat-history.
- Claude "No conversation found": check the printed JSONL project and resume cwd.
  A fork may compact when loaded into a smaller context window.
- Codex socket/start failure: report stderr and the requested socket; fix daemon
  availability. Do not unlink sockets or restart/interrupt other sessions.
- Unsupported API boundaries or a stale/corrupt index: stop and preserve the
  source. Do not work around it by editing rollout files. If naming fails after
  creation, use the already-printed new ID to resume or clean up that fork.
- Report source ID, chosen point, new ID and resume command. Verify the fork
  starts at the intended point before further work.

This skill does not rewind the original, restore working-tree files, merge
conversations, fork Cursor/other formats, or manage pinned forks, presets or
launchers. Backups contain private history; retain or remove them deliberately.
Files in this package (7)
  • SKILL.md 7 KB
  • references/claude-details.md 3 KB
  • references/form-reask.md 1 KB
  • scripts/claude_fork.py 11 KB
  • scripts/codex_fork.py 13 KB
  • tests/test_claude_fork.py 7 KB
  • tests/test_codex_fork.py 4 KB

Versions

RepositoryScoreLicence
This page · inbarajaldrin/devdroid100Apache-2.0
lucas-saldanha-werneck/remote-sessions100MIT

Database snapshot: 13.11.2026 · package version 67277ddd7d85 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100resume-codex-session
    Use when the user asks Claude to continue, resume, or take over work from a Codex session by session name or session id (UUID or UUID prefix). Examples include "continue the codex session called feature-x" or "/resume-codex-session 019dc08e". Do not use for ordinary Claude…
  • 100resume-claude-session
    Use when the user asks Codex to continue, resume, or take over work from a Claude Code session by session name or session id (UUID or UUID prefix). Examples include "continue the claude session called feature-x" or "/resume-claude-session a3b5c9f2". Do not use for ordinary Codex…
  • 100claude-code
    Use when you need to run Claude Code from another agent (Codex or any shell-capable agent): hand it a task headlessly with `claude -p`, pick the model, effort and permission mode, capture its answer and session id as JSON, continue the session with `--resume`, run several Claude…
  • 90continue-claude-code-work
    Continues interrupted Claude Code work after local history is read and reconciled — reconstructs the original outcome, unfulfilled requests, and the next action. Use when given a Claude Code Session ID, asked to pick up prior Claude work, told a run was interrupted or compacted,…
  • 100message-codex
    Queue a message from Claude Code, another agent, or a script to an existing Codex session. Use when Claude needs to report back to Codex or the user asks to "send this to Codex", "tell another Codex session", "notify the Codex session", or "queue a message for Codex". Not for…
  • 86resume-codex
    Continue work from a local Codex session in Muse Code. Use when the user asks to resume, continue, or recover unfinished Codex work, with or without a session ID or log path; call read_skill for bundled:resume-codex before reading its transcript. Explicit /import requests use import.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.