Skip to main content
skill CX Codex

worktree-pr — Claude Code skill for git worktrees

This skill runs larger or riskier tasks in a separate git worktree, checks the result against the untouched copy, and prepares a branch for a pull request.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add scarletkc/agents --skill worktree-pr -a claude-code
Open on GitHub

What worktree-pr does

worktree-pr helps decide whether a task needs its own working copy. When it does, the skill starts a branch from the current integration branch, leaves the main checkout alone, and compares the result with the original state. That separation suits parallel tasks and changes that need review before they land.

Fetch the base branch first. Parallel worktrees should touch different files; otherwise, the conflict surfaces when the changes come together. Save screenshots, builds, and exports somewhere durable or attach them to the PR, since removing a worktree also removes its local artifacts.

Before calling the task done, compare old and new behavior and account for generated changes such as lock-file updates. The skill prepares a pull request but leaves merging to the repository owner unless asked otherwise. If pushing or opening a PR needs explicit approval, the agent hands over the commands for authorization first.

What it helps with

  • isolate a risky change from the main checkout
  • run parallel tasks in one repository
  • compare changed behavior with the original
  • prepare a branch for a pull request without merging
  • keep worktree artifacts somewhere durable

Example prompts for the agent

  • Run this larger task in a separate git worktree and leave the main checkout untouched.
  • Make a separate branch for this risky change, then compare it with the original behavior.
  • Prepare the worktree changes for a pull request and report what remains unverified.

How to install worktree-pr

1Skills CLI (Vercel)

npx skills add scarletkc/agents --skill worktree-pr -a claude-code

2Manually: put the files in place

~/.claude/skills/worktree-pr/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/worktree-pr/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about worktree-pr

How do I install worktree-pr in Claude Code?

Run npx skills add scarletkc/agents --skill worktree-pr -a claude-code. The skill file is at ~/.claude/skills/worktree-pr/SKILL.md.

What does worktree-pr do?

It guides an agent through isolating a task in a git worktree, checking the result against the untouched checkout, and preparing a pull request. The repository owner handles the merge unless instructed otherwise.

What happens to screenshots and builds made in a worktree?

Save them in a durable location or attach them to the pull request, and state where they went. They disappear when the worktree is removed.

Source text

SKILL.md · Apache-2.0
---
name: worktree-pr
description: "Decide whether a task deserves its own git worktree and, if chosen, run it end to end: branch from the integration branch rather than the current tree, keep the main working copy untouched while the task runs, compare the result against the untouched baseline before declaring it done, and prepare it for a pull request instead of merging. Use when a request says to do the work in a new worktree or branch, when a change is large or risky enough that the main tree should stay usable, when several tasks need to run in parallel on one repository, when a result has to be diffed against current behavior, and when deciding where screenshots, builds, and other artifacts produced in a worktree should end up."
license: Apache-2.0
metadata:
  author: scarletkc
  source: https://github.com/scarletkc/agents
  summary: "Optionally run a task in its own worktree: branch from the integration branch, compare against the baseline, and prepare it for a PR."
---

# Worktree & PR

A worktree buys two things: the main working copy stays usable while the task
runs, and the untouched copy remains available as a baseline to compare
against. Both are worth real setup cost, and neither applies to every change.

This covers the isolation mechanics. How large the change itself should be is
[`scoped-change`](https://github.com/scarletkc/agents/blob/main/skills/scoped-change/SKILL.md),
and it applies inside a worktree exactly as it does anywhere else.

## Deciding

Consider a worktree when at least one holds: the task is large enough that a
half-finished state would block other work, several tasks need to progress on
the same repository at once, the result has to be compared against current
behavior, or the change is risky enough that abandoning it should cost
nothing.

Skip it when the change is small, self-contained, and reviewable in one pass.
Setting up an isolated copy for a typo fix or a one-line config edit costs
more than it saves, and the extra branch, directory, and PR are all overhead
that someone pays later. When the requester says to work directly on the
current branch, that decision is already made.

## Running

- **Branch from the integration branch, not from whatever is checked out.**
  The point of the isolated copy is a clean starting state; inheriting
  unrelated in-progress edits forfeits it and makes the eventual diff
  unreadable. Fetch first so the base is current, not a stale local ref.
- **Leave the main working copy alone while the task runs.** Editing both
  defeats the isolation and destroys the baseline. If the task turns out to
  need a change in the main tree, stop and say so rather than reaching
  across.
- **Parallel worktrees stay independent only while they stay disjoint.** Two
  copies of one repository editing the same files converge into a conflict
  nobody scheduled, and the cost lands at merge time rather than now. Before
  opening a second one, check what the first is touching.
- **Name the artifacts' destination explicitly.** Screenshots, builds, and
  exports produced inside a worktree vanish with it. Anything the requester
  needs to see must be written somewhere durable, or attached to the PR, and
  the location has to be stated rather than assumed.

## Before declaring it done

- **Compare against the untouched baseline, not against expectation.** The
  reason to keep a clean copy is to run both and see the difference. For
  behavior changes this means exercising the old path and the new one; for
  visual changes it means the same view captured twice. "Should be
  equivalent" is a claim, and the baseline is right there to check it.
- **Account for what the tooling added.** Generated output, formatter churn,
  and dependency lock updates accumulate in an isolated copy without anyone
  choosing them, and they are indistinguishable from intent once merged.
  Either explain why each belongs in this branch, or drop it.

## Landing

Follow the user's established authorization preferences. If committing,
pushing, or opening a pull request requires explicit authorization, complete
and validate the local changes, then hand over the exact commands until
authorized. When authorized, push the branch and open a pull request describing
motivation, the commands exercised, and anything reviewers must check by hand;
leave merging to the repository owner unless told otherwise. Say plainly which
parts are done, which are unverified, and which were deliberately left out,
since a worktree's isolation makes it easy to report an untested result as
finished. Once the branch has landed, remove the worktree; a stale copy of a
merged branch is a trap for the next session that opens it.

© scarletkc · Apache-2.0 · scarletkc/agents

Similar skills

All skills for Git and GitHub →

From the same set10

ux-writing A skill that sets judgment rules for user-facing strings and docs: CLI and diagnostic output, errors, help text, README structure, comments and titles. CX Codex +1 ★ 224repo stars scoped-change Restricts agent edits strictly to the requested scope. Prevents unrequested refactoring and missed sibling updates. CX Codex +1 ★ 224repo stars product-writing This skill helps draft and review interface copy and technical docs. Use it for error messages, CLI text, help content, and explanations of product behavior. CX Codex +1 ★ 224repo stars marketing-copy Drafts launch posts, store descriptions, landing headlines and press notes. Checks first that no key, unlisted link or unshipped feature leaks into public text. CX Codex +1 ★ 224repo stars grok-cli Delegates bounded tasks to Grok Build while your main agent keeps working. Manages background ACP sessions for progress, follow-ups, and permissions. CX Codex +1 ★ 224repo stars devin-cli Delegates bounded coding work to a local Devin CLI over ACP and tracks the run. Use it for parallel implementation, ports, reviews, or follow-up turns. CX Codex +1 ★ 224repo stars codex-cli A skill on when handing work to Claude CLI pays off, and how to size the run: model, reasoning effort, sandbox permissions. Written for the supervising agent. CX Codex +1 ★ 224repo stars ask-to-plan Turns vague ideas into an actionable plan via native clickable choices. It asks one focused question at a time to clarify scope and technical decisions. CX Codex +1 ★ 224repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor