Source: https://illuminate.atlassian.net/wiki/spaces/TECH/pages/18466734504/git+worktree+for+parallel+CC+sessions Last Modified: Aug 14, 2025 Author: Ethan Stark Space: Nearpod Product and Technology (TECH)
git worktree add ../MY-SERVICE-feature-a -b feature-a
git worktree add ../MY-SERVICE-bugfix bugfix-123
cd ../MY-SERVICE-feature-a
claude open Claude Code here
cd ../MY-SERVICE-bugfix
claude open Claude Code here
git worktree list
git worktree remove ../MY-SERVICE-feature-a
git worktree prune
Using git worktrees with nptools
Create worktrees wherever / however you want if you are just investigating, planning, or don't need to run the code in your worktree. Everything that follows is if you need to run the code in the worktree
nptools discovers services by recursively scanning the your `localenv` directory (the directory containing `.nptools.json`) for `nptools.config.json`. If you create a worktree inside your `localenv`, nptools will treat both the original repo and the worktree as separate service directories. This leads to duplicate service discovery and likely Docker Compose conflicts, because both will try to run the same compose service names within the same compose project (`-p docker_nearpod`).
Therefore, avoid placing worktrees inside your `localenv`. Use one of the safe patterns below.
- Keep worktrees outside your `localenv` so nptools doesn't discover them automatically.
- When you need to run the worktree's code with nptools, temporarily "swap in" the worktree via a symlink at the canonical service path, so only one copy is discovered.
Example for a service at `~/dev/localenv/microservices/MY-SERVICE` and a worktree at ~/worktrees/MY-SERVICE-feature-a
nptools stop MY-SERVICE
cd ~/dev/localenv/microservices
mv MY-SERVICE MY-SERVICE.orig
ln -s ~/worktrees/MY-SERVICE-feature-a MY-SERVICE
nptools start -w MY-SERVICE -d
rm MY-SERVICE
mv MY-SERVICE.orig MY-SERVICE
```
- Discovery is cached per nptools process; each command invocation recomputes from disk, so swaps take effect immediately in new runs.
- Do not keep both the original directory and the worktree present under your `localenv` with `nptools.config.json` files, or nptools will attempt to operate on both.
If you want a fully isolated environment pointing only at a worktree, create a small "scoped" your `localenv` by placing a `.nptools.json` file in a parent directory that contains just the worktree (and any required dependencies), then run nptools from somewhere under that directory. nptools will use the nearest `.nptools.json` it finds upward from the current working directory as the root for service discovery.
Pros: total isolation. Cons: you must ensure any required sibling repos or shared directories (e.g., data/aux repos) are present under that scoped root.
- Don't create worktrees as siblings inside
~/dev/localenv/...alongside the original repo. That will cause duplicate discovery and container conflicts. - Don't try to hide duplicates by removing
nptools.config.jsonfrom a repo you still build/run. That will break nptools behavior.