Comment by nullbio

2 days ago

One thing I don't understand with all of these, is how they're handling different worktree infrastructure spin-up?

For example, if I have a webapp, I want each of the worktrees to spin up its own infrastructure, and be accessible on its own unique local url, so that I can see the changes locally for each worktree, or I can have agents automate visual checks using something like agent-browser.

Currently I use docker for my infrastructure, each service running in its own container. I have a script that has a ./app worktree create worktreename. That creates a worktree as "worktreename" and spins up all of my docker infrastructure with prefixes for things like "WORKTREENAME", and I can access all my urls at worktreename.myapp.test (or just myapp.test for the main worktree).

This is working fine for now, but it'd be cool if one of these apps was compatible with this concept so I could move over to that.

I have this issue at work, I asked CC to create a very simple bun CLI tool that can be hard to create, destroy and list worktrees. The CLI seeds the .env file with a url, db for that worktree and I use Vercels open source package portless to spin up a dev server with unique ports so I get a url per worktree

Check out emdash.sh - each task spins up its own worktree with a bunch of pre-defined environment variables that are injected. This includes `EMDASH_PORT` a uniquey port for a 10 port range. Very useful for running multiple services from a single monorepo.

  • I ended up trying emdash.sh and superset.sh, both have this feature. I managed to get it to work in superset - for whatever reason the Setup script wouldn't work in emdash. So I'll stick with this for now.

i have shell scripts that create/tear down worktrees. the shell script finds unique unused ports across all existing worktrees and assigns in local .env upon worktree creation. when the worktree gets merged and is torn down the ports get released. secrets that are not worktree-specific i don't keep in local .env i inject via shell.

honestly creating these local scripts for automating the dev work was trivial and they combine well with all other cli tooling. thats why i havent tried any of the GUI apps yet. im not sure they're able to compete with my custom local setup that works exactly the way i want.

Just use direnv? You’ll probably need to adjust the port you are hosting the local page on, but that’s just N=mod(hash based on the worktree name) and then port=default_port+N.

Tell your claude to set this up. Should do it in a single prompt