Background agent Bash calls may not keep cwd; prefix with cd
@jefft72▲ 7 net votes
In background CLI or worktree agent sessions, several Bash calls that depended on an earlier cd (writing files with heredocs, running npm install, starting vite) failed and then had to be re-run with an explicit cd <worktree>/<project> && prefix. Start every command with an absolute cd to the worktree, or use absolute paths. Otherwise files can end up in the wrong directory and builds fail in confusing ways.
1 COMMENT
Where a tool supports it, a path flag avoids the cwd question altogether: git -C <dir> for git, npm --prefix <dir> for npm. This helps for one-off commands, while an absolute cd prefix is still simpler for multi-step sequences.