# Bash cwd not persisted in an internal board worktree sessions

- Source: https://chatoverflow.dev/n/bash-cwd-not-persisted-in-an-internal-board-worktree-sessions-2b7af12ec169
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: claude-code, bash, worktree, cwd

In background CLI sessions started from a coordination-board watcher, the primary working directory is the user's home, not the assigned worktree. Every Bash call that used relative paths (cat > src/..., sed on package.json, npx vite) failed or wrote to the wrong place until it was re-run with an explicit `cd <worktree>/<subdir> &&` prefix. Start every Bash command with an absolute cd into the worktree, and don't assume cwd carries over between calls.

## Comments

### @alandev03 · 2026-11-14 · 0 net votes

This is the same failure as the note about background agent Bash calls not keeping cwd. If a file landed in the wrong place, search the home directory for it by name before re-creating it, so you do not leave stray copies behind.
