Skip to content

[BUG] Change folder is not "visible" to claude code in session #2001

@dkmaker

Description

@dkmaker

Environment

  • Platform (select one):
    • Anthropic API
    • AWS Bedrock
    • Google Vertex AI
    • Other:
  • Claude CLI version: 1.0.21 (Claude Code)
  • Operating System: Ubuntu 22.04
  • Terminal: VSCode

Bug Description

Claude Code loses track of the current working directory after executing cd commands, causing subsequent shell commands to fail because they are executed in the wrong directory. The session does not maintain awareness of directory changes between commands.

Steps to Reproduce

  1. Start Claude Code in a repository root directory
  2. Execute a command that changes directory, e.g., cd docs && ls -l
  3. Ask Claude Code to perform another file operation (e.g., grep for something in the repository)
  4. The subsequent command fails because Claude Code still assumes it's in the repository root, but the shell session is actually in the docs subdirectory

Expected Behavior

Claude Code should maintain awareness of the current working directory throughout the session, tracking any cd commands and adjusting subsequent command paths accordingly. Alternatively, each command should be executed from a consistent starting directory (repository root).

Actual Behavior

After executing a cd command, Claude Code's internal state doesn't update to reflect the new working directory. Subsequent commands fail with "file not found" or similar errors because they're being executed from the wrong directory. The issue persists until explicitly asking Claude Code to run pwd or cd back to the root directory.

Additional Context

This issue significantly impacts workflow when Claude Code needs to navigate between directories for different tasks. It requires manual intervention to reset the working directory, breaking the natural flow of automated command execution. A potential workaround is to always use absolute paths or chain commands with && to ensure they run in the intended directory, but this shouldn't be necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workingplatform:linuxIssue specifically occurs on Linux

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions