home / skills / ykdojo / claude-code-tips / clone

clone skill

/skills/clone

This skill clones the current conversation to let you branch off and test alternative approaches without losing context.

npx playbooks add skill ykdojo/claude-code-tips --skill clone

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
904 B
---
name: clone
description: Clone the current conversation so the user can branch off and try a different approach.
---

Clone the current conversation so the user can branch off and try a different approach.

Steps:
1. Get the current session ID and project path: `tail -1 ~/.claude/history.jsonl | jq -r '[.sessionId, .project] | @tsv'`
2. Find clone-conversation.sh with bash: `find ~/.claude -name "clone-conversation.sh" 2>/dev/null | sort -V | tail -1`
   - This finds the script whether installed via plugin or manual symlink
   - Uses version sort to prefer the latest version if multiple exist
3. Run: `<script-path> <session-id> <project-path>`
   - Always pass the project path from the history entry, not the current working directory
4. Tell the user they can access the cloned conversation with `claude -r` and look for the one marked `[CLONED <timestamp>]` (e.g., `[CLONED Jan 7 14:30]`)

Overview

This skill clones the current Claude conversation so you can branch off and try a different approach without losing the original thread. It uses your local Claude history to locate the session and a helper script to create a timestamped cloned conversation you can reopen with the CLI. The result is a separate session labeled with a [CLONED <timestamp>] tag for easy discovery.

How this skill works

The skill reads the latest history entry to extract the session ID and project path, then finds the helper script clone-conversation.sh in your Claude configuration directory. It runs the script with the session ID and the recorded project path (not your current working directory). The script creates a cloned conversation and timestamps it; you reopen clones using claude -r and look for the [CLONED <timestamp>] marker.

When to use it

  • You want to experiment with a different line of questioning without losing the original conversation.
  • You need a safe copy before trying risky edits or automated transformations.
  • You want to compare multiple approaches or prompts side-by-side.
  • You are debugging prompt variations and need reproducible branches.
  • You want to preserve a stable baseline before applying new tools or plugins.

Best practices

  • Always use the project path taken from the history record, not your current directory, to ensure the clone references the correct context.
  • Prefer the latest clone-conversation.sh by locating it with version-sorted find to avoid running outdated scripts.
  • Confirm the cloned session appears in claude -r and check the [CLONED <timestamp>] label before proceeding.
  • Keep a convention for naming or tagging clones in your notes so you can track experiments across sessions.
  • Run clones before making bulk edits or running agentic workflows that change state.

Example use cases

  • Branching off an architecture discussion to test a different design pattern while keeping the original thread intact.
  • Creating a copy of a debugging session before running experimental patches or automated refactors.
  • Testing multiple prompt strategies for a coding task and comparing outputs without losing any history.
  • Safely handing a cloned session to a teammate for parallel work without affecting your active conversation.
  • Preserving a conversational baseline before integrating new plugins or automations.

FAQ

How do I get the session ID and project path?

Run tail -1 ~/.claude/history.jsonl | jq -r '[.sessionId, .project] | @tsv' to extract the latest session ID and project path.

How do I find the clone-conversation.sh script?

Use find ~/.claude -name "clone-conversation.sh" 2>/dev/null | sort -V | tail -1 to locate the most recent script installation.

How do I open the cloned conversation?

Run claude -r and look for the conversation labeled [CLONED <timestamp>] to reopen the cloned session.