cjmellor/mella-marketplace/tree/main/plugins/worktree-ready
worktree-ready
Laravel git worktree를 자동으로 준비하고 정리하며, copy-on-write로 의존성을 복제하고 Valet 또는 Herd로 사이트를 연결하는 Claude Code mod입니다.
이 mod 소개
worktree-ready는 EnterWorktree 및 ExitWorktree 도구 호출에 훅을 거는 Claude Code mod입니다. Laravel worktree에 들어가면 vendor, node_modules, 빌드된 자산을 copy-on-write 방식으로 복제하고 .env를 복사합니다. 잠금 파일이 다를 때만 composer/JS 설치를 실행하고 소스가 바뀌면 자산을 다시 빌드하며, Laravel Valet 또는 Herd를 통해 worktree를 독립된 HTTPS 사이트로 연결하고 APP_URL을 갱신합니다. 나갈 때 잃을 것이 없으면 사이트 연결을 해제하고 폴더와 브랜치를 제거합니다. 테스트된 hooks/lib.ts 순수 헬퍼와 hooks/register.ts의 진입/종료 흐름을 포함합니다. macOS APFS와 플러그인 모듈을 지원하는 Claude Code 빌드가 필요합니다.
설치
먼저 작성자의 README에서 marketplace와 플러그인 이름을 확인하세요. 저장소 구조에 따라 명령어가 달라질 수 있습니다.
claude plugin marketplace add cjmellor/mella-marketplace claude plugin install worktree-ready
원문 / README
worktree-ready
Make a new git worktree of a Laravel app ready to use with no hands, and tidy it away when you are done.
worktree-ready is a Claude Code mod. When Claude enters a worktree of a Laravel app, it brings the worktree up to the same state as your main checkout, links it as its own .test site over HTTPS, and shows you the URL. When the worktree is exited, it unlinks the site and removes the folder if the work is finished.
Requirements
- A Claude Code build that loads plugin modules (mods).
- macOS on APFS. Dependencies are cloned with
cp -c, a copy-on-write clone, so the worktree must be on the same volume as the main checkout (worktrees under.claude/worktrees/always are). - Laravel Valet or Herd. Without one the worktree is still set up, it just is not linked.
composer, and your JS package manager, on the PATH.
What happens when a worktree is entered
The mod only acts in a linked worktree that has an artisan file. Each step is skipped when it has nothing to do.
- Clone
vendor,node_modulesandpublic/buildfrom the main checkout with copy-on-write. This takes seconds and shares disk blocks until a file changes.public/hotandbootstrap/cacheare never cloned. - Copy
.envfrom the main checkout, if the worktree has none. The worktree shares main's database. A sqlite database is shared by pointingDB_DATABASEat main's file. - Install only what changed.
composer installruns whencomposer.lockdiffers from main's, and the JS install runs when its lockfile differs. The package manager is picked from the lockfile (bun.lock,pnpm-lock.yaml,yarn.lockorpackage-lock.json). - Build assets only when needed. The
buildscript runs when the worktree'sresources/,package.jsonor Vite, Tailwind, PostCSS or TypeScript config differ from main's working tree, or when main has nopublic/build. - Link and secure. The site is linked as
<project>-<worktree>(for examplekandu-purring-crafting.test), secured, and checked againstlinks. The wordworktreeis never part of the name. A name that already points at a different folder is left alone and reported.APP_URLin the worktree's.envis set to the new URL.
Claude does not get control back until this finishes, as with a SessionStart hook, so its first command in the worktree already has what it needs. Progress shows under the prompt.
A worktree that a session starts in (claude --worktree) is set up the same way.
What happens when it is exited
Whether the exit keeps or removes the worktree, the site is unsecured and unlinked, and the mod checks that it is gone from links.
If the exit kept the worktree, the mod then removes the folder and its branch when there is nothing to lose: no uncommitted changes, and the branch has commits of its own that are merged into the default branch. A worktree you entered and left without committing is kept. Anything else is kept, and you are told why once. The same check runs for leftovers at the start of the next session, along with the links of worktrees whose folder no longer exists. Only worktrees under the project's .claude/worktrees/ that the mod set up are ever removed.
Options
| Option | Default | What it does |
|--------|---------|--------------|
| Site tool | auto | valet, herd or auto. Auto uses whichever is installed and does nothing when both are, with a toast asking you to choose. |
Limits
- A worktree whose branch was squash-merged is reported as not merged, because its commits are not in the default branch's history. It stays until you remove it.
- A session that ends without exiting the worktree leaves it marked active, so it is kept.
- Herd's
linksoutput is assumed to match Valet's table. It has not been tried. - The whole flow was tested against a faked machine. It has not run against a real Herd.
Development
The pure helpers (link names, .env edits, the links table, lockfile and asset checks) are in hooks/lib.ts, and the enter and exit flows in hooks/register.ts. Both are covered by tests that fake the file system, git, composer, the package manager and Valet:
claude plugin validate plugins/worktree-ready
claude plugin test plugins/worktree-ready
License
MIT
