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
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- archive-issueSkill
- create-issueSkill
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
- Distinctive: line 20
No arguments — it operates on the branch currently checked out.
- Very specific: line 46
When the PR has squash-merged, /finish-worktree <issue#> (run back in the primary) does the teardown.
- Distinctive: line 51
Run the underlying git commands yourself — the script owns all mutation.
- Distinctive: line 54
Create the worktree while the primary is still on the feature branch.
≈ “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.
Files
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.shNo arguments — it operates on the branch currently checked out. The script:
- Hard-stops unless run in the primary checkout, on a task branch
(
{type}/{issue#}/{slug}), with a clean tree and its matchingorigin/upstream set — i.e. exactly the state/start-taskleaves behind. - 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). git worktree add .worktrees/<issue#> <branch>— nested inside the repo root (gitignored), never a../sibling. The context filespecs/context/<issue#>.mdtravels with the branch (it's committed).- 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. - Runs
npm ciin the worktree (per-worktreenode_modules; also wires the Husky pre-push hook sonpm run verifygates 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.
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
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.

