[BUG] Command files execute from current working directory instead of project root

Resolved 💬 3 comments Opened Jul 24, 2025 by agentofreality Closed Aug 19, 2025

Environment

  • Platform (select one):
  • [ X] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.59 (Claude Code)
  • Operating System: macOS
  • Terminal: Terminal App

Bug Description

Commands defined in .claude/commands/ execute using the user's current working directory rather than the project root directory. This causes commands with project-relative paths to fail when users are working in subdirectories.

Steps to Reproduce

  1. Create a project with a .claude/commands/ directory containing a command that references a project-relative path (e.g.,.claude/notify.sh)
  2. Navigate to a subdirectory within the project: cd subdirectory/
  3. Execute the command that references the relative path
  4. Observe that the command fails with "No such file or directory" error

Expected Behavior

Commands should execute with the working directory set to the project root (the directory containing the .claude folder), making project-relative paths work consistently regardless of the user's current location within the project.

Actual Behavior

Commands execute from the user's current working directory, causing failures.

Error output:
(eval):1: no such file or directory: .claude/notify.sh
Stop [.claude/notify.sh] failed with non-blocking status code 127: /bin/sh: .claude/notify.sh: No such file or directory

Additional Context

This makes command files fragile and location-dependent. Users must remember to navigate to the project root before using Claude commands, which reduces the utility of reusable command configurations.

Project structure example:
test-project/ # Project root
├── .claude/
│ ├── commands/
│ └── notify.sh
└── test-framework/ # User's current location when error occurred

View original on GitHub ↗

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