Custom statusLine command resets shell CWD between Bash tool calls

Resolved 💬 2 comments Opened Mar 6, 2026 by vertexnick Closed Apr 4, 2026

Problem

When a custom statusLine command is configured in ~/.claude/settings.json, the shell's current working directory (CWD) no longer persists between Bash tool calls. Every cd command's effect is lost — the CWD resets to the project's primary working directory after each Bash invocation.

This makes it impossible to cd into a git worktree (or any subdirectory) and have subsequent Bash calls execute there.

Reproduction

  1. Add a statusLine to ~/.claude/settings.json:

``json
"statusLine": {
"type": "command",
"command": "bash ~/.claude/statusline-command.sh"
}
``

  1. The script itself can be trivial (reads JSON from stdin, prints a formatted line).
  2. In a Claude Code session, run:
  • cd /some/other/directory → succeeds
  • pwd → reports /some/other/directory during that call, but the next Bash call reverts to the project root

Without the statusLine config, cd persists correctly across Bash calls as documented.

Investigation

  • The status line script (statusline-command.sh) does NOT itself run cd — it only reads stdin JSON and prints output via printf.
  • The issue appears to be that Claude Code executes the status line command in the same shell context between Bash tool calls, and this execution resets the shell's CWD to the project root.
  • This may be an artifact of how the shell subprocess is managed — possibly re-spawning or resetting the shell environment when invoking the status line command.

Expected Behavior

The status line command should not interfere with shell state (CWD, environment variables, etc.) between Bash tool calls. The status line command should either:

  • Run in an isolated subprocess/subshell that doesn't affect the main shell's state
  • Preserve and restore the CWD after executing the status line command
  • Run in a completely separate shell instance

Workaround

Remove the statusLine config from settings. Alternatively, use git -C <path> for git commands and absolute paths for file operations, but this defeats the purpose of cd persistence.

Environment

  • Platform: Windows 10 (git-bash shell)
  • Claude Code: latest

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗