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

half-clone skill

/skills/half-clone

This skill helps you quickly clone only the latest half of a conversation to save tokens while preserving recent work.

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

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

Files (1)
SKILL.md
1.3 KB
---
name: half-clone
description: Clone the later half of the current conversation, discarding earlier context to reduce token usage while preserving recent work.
---

Clone the later half of the current conversation, discarding earlier context to reduce token usage while preserving recent work.

Steps:
1. Get the current session ID and project path: `tail -1 ~/.claude/history.jsonl | jq -r '[.sessionId, .project] | @tsv'`
2. Find half-clone-conversation.sh with bash: `find ~/.claude -name "half-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. Preview the conversation to verify the session ID: `<script-path> --preview <session-id> <project-path>`
   - Check that the first and last messages match the current conversation
4. Run the clone: `<script-path> <session-id> <project-path>`
   - Always pass the project path from the history entry, not the current working directory
5. Tell the user they can access the half-cloned conversation with `claude -r` and look for the one marked `[HALF-CLONE <timestamp>]` (e.g., `[HALF-CLONE Jan 7 14:30]`). The script automatically appends a reference to the original conversation at the end of the cloned file.

Overview

This skill clones the later half of the current Claude conversation, discarding earlier messages to save tokens while preserving recent work. It locates the latest helper script, previews the target session, and creates a new conversation file containing only the second half of the history with a reference to the original. Use it to continue a thread without carrying full context.

How this skill works

The tool reads your most recent session ID and project path from the local Claude history file. It finds the latest half-clone script installed in ~/.claude, verifies the session by previewing messages, and then writes a new conversation file that contains only the later messages. The cloned file is marked with a timestamped [HALF-CLONE ...] tag and includes a reference to the original conversation.

When to use it

  • You need to reduce token usage but keep recent context for ongoing work.
  • A conversation has grown large and earlier messages are no longer relevant.
  • You want a clean continuation to share or run as a fresh session.
  • You prefer preserving a link back to the original history for traceability.
  • You are managing multiple projects and want per-project trimmed conversations.

Best practices

  • Always run the preview step before cloning to confirm session ID and message range.
  • Pass the project path extracted from history, not the present working directory.
  • Keep backups if you rely on full history for audits before discarding earlier context.
  • Use the version-sorted script path to ensure you run the latest installed helper.
  • Check the cloned file with claude -r and verify the [HALF-CLONE <timestamp>] tag.

Example use cases

  • Trim a long coding conversation to continue debugging without paying for tokens tied to old design discussion.
  • Create a fresh conversation snapshot to hand off to a teammate focusing only on recent tasks.
  • Reduce prompt length before running a cost-sensitive batch job with Claude.
  • Extract the latest half of a planning thread for inclusion in a new project branch.
  • Preserve a short, shareable conversation for documentation while keeping the original archived.

FAQ

How do I find the correct session ID and project path?

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

What if multiple versions of the script exist?

The installer uses find with version sort and tail -1 to pick the latest half-clone-conversation.sh automatically.

How do I verify the clone before committing?

Use the script's --preview <session-id> <project-path> option to inspect the first and last messages of the planned cloned file.

Where do I find the cloned conversation?

Open claude -r and look for the entry marked [HALF-CLONE <timestamp>]; the cloned file includes a reference to the original conversation at the end.