agentleFS
foyzulkarimfoyzulkarim/claude-lens/.claude/skills/move-to-worktree/SKILL.md

move-to-worktree

Skill250 starsChanged 4 months agoMITView on GitHub

After /start-task: park the current clean, pushed feature branch in its own issue-numbered nested worktree (.worktrees/<issue#>) and return the primary checkout to current main, so the next parallel lane can start. Writes the lane's port base and runs npm ci in the worktree. Use when the user says to move the branch or task to a worktree or open a parallel lane.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No arguments — it operates on the branch currently checked out.

    line 20
  2. Very specific:

    When the PR has squash-merged, /finish-worktree <issue#> (run back in the primary) does the teardown.

    line 46
  3. Distinctive:

    Run the underlying git commands yourself — the script owns all mutation.

    line 51
  4. Distinctive:

    Create the worktree while the primary is still on the feature branch.

    line 54

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Move-to-Worktree

Companion to /start-task for parallel Phase 4 lanes (see specs/claude-lens-phase4-parallelization.md). /start-task leaves the primary checkout on the new feature branch; this skill moves that branch into its own worktree and puts the primary back on main — one worktree + one branch + one Claude session per in-flight issue.

Run (1 bash call)

bash {base_directory}/move-to-worktree.sh

No arguments — it operates on the branch currently checked out. The script:

  1. Hard-stops unless run in the primary checkout, on a task branch ({type}/{issue#}/{slug}), with a clean tree and its matching origin/ upstream set — i.e. exactly the state /start-task leaves behind.
  2. Pushes any local-only commits, checks out and fast-forwards main (this must happen before the worktree is created — git refuses to check out a branch in two places).
  3. git worktree add .worktrees/<issue#> <branch> — nested inside the repo root (gitignored), never a ../ sibling. The context file specs/context/<issue#>.md travels with the branch (it's committed).
  4. Writes the lane's port block to <worktree>/.env.local (gitignored): CLAUDE_LENS_PORT_BASE = 4128 + 10 × issue# — backend = base, Vite = base+1, E2E = base+2, Storybook = base+3. Issue-derived, so lanes cannot collide.
  5. Runs npm ci in the worktree (per-worktree node_modules; also wires the Husky pre-push hook so npm run verify gates pushes from this lane).

Non-zero exit → hard-stop, print stderr verbatim.

Report

The script's summary block (worktree path, branch, ports), plus: "Open a new Claude session in the worktree and continue the pipeline there (/plan-architecture / /implement → /review → /commit → PR with Closes #N)."

When the PR has squash-merged, /finish-worktree <issue#> (run back in the primary) does the teardown.

You Must NOT

  • Run the underlying git commands yourself — the script owns all mutation.
  • Stash, discard, or commit anything to satisfy the clean-tree check — hard-stop instead.
  • Move a branch whose upstream is ahead or does not match origin/<branch>.
  • Create the worktree while the primary is still on the feature branch.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.