Set up a repo's worktrees
Make every new worktree of a repo runnable on its own, with its dependencies, gitignored inputs, databases and port.
In a Claude session in the repo's main checkout, run:
/kebbie:make-worktree-safeIt audits the repo for what breaks across worktrees: fixed ports, shared databases and services, gitignored inputs, absolute paths and shared caches.
Say yes to its plan. It writes
bin/setup-worktree, the port fix and a## Working in a worktreesection, in a worktree for you to review.Review the worktree and run the script yourself. Claude never starts it on its own.
Check each worktree's setup:
kebbie listEach worktree shows the first line of its setup note. The full note is at
$(git rev-parse --git-dir)/kebbie-setup.mdinside the worktree.
The setup skill runs bin/setup-worktree whenever a repo has one.
- If you write
bin/setup-worktreeyourself, make it executable, take no arguments, make it safe to run again, and run it from inside a worktree. See the example below. - If your script has another name, set
setup_commandunder[worktree]in the repo config. See below. - If several repos share the script name, set
setup_commandonce inconfig.toml. A command that names a path applies only in repos that have that file; the others keep the default setup. - If you want your own setup skill, set
setup_skillunder[worktree], for examplesetup_skill = "my-tools:set-up-worktree", or name a Markdown file of steps by its path, such assetup_skill = "~/code/app/SETUP.md".
A setup script for a Rails app
#!/bin/sh
set -eu
main=$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")
for f in config/master.key .env; do [ -e "$f" ] || cp "$main/$f" "$f"; done
bundle check >/dev/null || bundle install
bin/rails db:prepare
A script with another name
# ~/.config/kebbie/repos/app.toml
[worktree]
setup_command = "script/prepare_worktree"
Give back what the setup made
When the setup makes something outside the worktree, such as a database copy for each worktree, set the command that removes it. kebbie runs it in the worktree when the task is done, dropped or reset, and when the keeper closes a landed task:
# ~/.config/kebbie/repos/app.toml
[worktree]
release_command = "dev worktree-db remove"
The result shows in the freed: line. A failure is named there and the worktree is freed all the same.
See also: The worktree pool.