I avoided worktrees for months because they seemed unnecessarily complex.
Turns out I was wrong.
Now I can test 3 different product flows at once without touching my main codebase.
Here's how I got worktrees working with
@convex in codex. (works with claude code too)
I started by asking codex to research the setup. Told it to check both codex and convex docs and come up with a plan.
Codex created a script for setting up the worktree, and copying over the relevant env vars.
First hiccup: codex was using outdated convex cli commands. I had to manually copy the new commands from convex's changelog and ask codex to use that.
Without this, it created overly complicated scripts.
Second hiccup: I didn't realize I had to manually select the new environment for each worktree. Once I figured that out, the setup script ran automatically.
For convex specifically, I needed to set a specific node version for it to run locally. But that was it.
I also set up portless by
@ctatedev and Vercel Labs so that each worktree has its own website.
It works beautifully. Just need to create a branch in the worktree, and portless will create a URL with that branch name.
Another reason worktrees worked for me is using
@better_auth .
Because each worktree can run fully isolated, each one keeping its own login state in the local convex. Itβs beautiful.
Now I can test different product concepts without touching my main deployment.
Everything runs locally. No extra costs.
Worth the setup time.