Worktree setup and teardown
A new worktree is a clean checkout, so it has no installed dependencies or local services. Setup and Teardown commands prepare and clean up each worktree Zekoder creates for a project. See Projects and workspaces for how worktrees are created.
Edit them in the workspace's + → Project settings → Worktree lifecycle hooks. They are saved to zekoder.json at the project root.
{
"worktree": {
"setup": ["npm install"],
"teardown": ["docker compose down"],
"teardownTimeoutMs": 60000
}
}
Setup
Setup commands run in order, in the new worktree, before terminals and the first agent start. The first command that fails stops the rest and the worktree is not created.
A new worktree uses the setup commands from the base branch you pick in Start from. If you changed zekoder.json and have not committed it, the settings page shows Commit zekoder.json changes: commit first, or the new worktree starts without them.
To copy ignored files such as .env, use a .worktreeinclude file instead of a setup command.
Teardown
Teardown commands run in order when you archive a worktree, before it is removed. One deadline covers every command: 60 seconds by default, or worktree.teardownTimeoutMs. If a command fails or the deadline passes, Zekoder keeps the worktree.
Environment variables
Setup and teardown commands receive:
| Variable | Value |
|---|---|
PASEO_SOURCE_CHECKOUT_PATH | The original repository folder, shared by all worktrees. |
PASEO_ROOT_PATH | Alias of PASEO_SOURCE_CHECKOUT_PATH. |
PASEO_WORKTREE_PATH | The worktree folder. |
PASEO_BRANCH_NAME | The worktree's branch. |
PASEO_WORKTREE_PORT | A free port reserved for this worktree. Stable for its lifetime. |
Use the port to run a dev server per worktree without collisions:
{
"worktree": {
"setup": ["cp \"$PASEO_SOURCE_CHECKOUT_PATH/.env\" .env", "npm install"]
}
}