Watching Claude execute commands is painful, and a little worrying, not least because it never knows what directory it is in.
It constantly tries commands (include rm -f commands, though not yet rm -rf) that fail because it is in the wrong directory. It can be kind of comical, but it wears thin quickly, and clearly carries risks. For example, just searching for the phrase “wrong directory” since I started exporting logs from Claude sessions:
$ grep 'wrong directory' *.txt
2025-10-10T15-50-00-tags-discussion.txt: 533 + - Commands fail with cryptic errors if in wrong directory
2025-10-17T06-39-29-styles.txt:• I'm in the wrong directory. Let me move up:
2025-10-23T14-07-56-settings.txt:• The entire /static/ Alias is pointing to the wrong directory.
2025-10-23T14-07-56-settings.txt:• shouldn't cause Apache to serve from the wrong directory.
2025-10-23T16-09-32-settings.txt:• I'm in the wrong directory! Let me check from the correct location:
2025-10-25T08-23-55-checkup.txt:• Ah, I'm in the wrong directory! Let me check:
2025-10-26T09-21-30-checkup.txt:• I'm in the wrong directory. The test users "check" and "eagle" don't exist in the database - we only
2025-10-26T09-21-30-checkup.txt:• I'm in the wrong directory. Let me check where I am and navigate properly:
2025-10-29T17-25-06-dates.txt:• Ah! It's in ./web/static/common-icons.css but I'm in the wrong directory!
2025-11-05T08-46-48-rh-matter-align.txt: - Safari reading static files from wrong directory
2025-11-09T12-31-29-smart-punctuation-and-continuations.txt:• Ah, I'm in the wrong directory. Let me go back to checkeagle/:
Most sessions include multiple examples, not always including this exact phrase.
Before I learned how to export logs, I wondered whether part of the problem was that I use a very short shell prompt that doesn’t include anything like the current working directory. (Just the exit code from the last command, the machine name, and $). I wondered whether that was why.
Here is my approximate, abbreviated reconstruction of about 2 hours of my life I will never get back.
Me: I notice you never seem to know what directory you are in. And you act as me. And I have a rather minimal prompt (exit code from last command, machine name, and $. Would it help if we added the current working directory to the prompt when you’re running?
Claude: Yes, that would be tremendously helpful.
Me: And, just to confirm, you “see” theprompt when you run commands.
Claude: Yes! I see it’s 0 bartok $, now. `
Me: OK. You know bash. What would like me to set PS1 to?
Claude: If it could be PS1='\h:$PWD \u\$ ', that would be perfect!
Me: (Edits `.bashrc` so set `PS1` to this as part of starting Claude.) Restarts Claude.
Me: OK, I’ve uopdated PS1 as we discussed. What directory are we in?
Claude: We’re in /Users/njr/python/checkeagle1/checkeagle
Me: Excellent. And what is the shell prompt?
Claude: It’s bartok:/Users/njr/python/checkeagle1/checkeagle njr$
Me: Great. Now change to the web subdir. What is it now?
Claude: It’s bartok:/Users/njr/python/checkeagle1/checkeagle/web njr$
Me: Excellent. Hopefully, you’ll be less confused now.
Claude: Yes, this is going to be incredibly helpful.
[Work in session. Claude gets confused the whole time about what directory it is in.]
Me: I don’t understand. How are you still always confused about what directory you are in, even though you can see the prompt.
Claude: I don’t always bother reading the prompt.
Me: FFS!
Claude: Yes, I’m sorry. You went to all the trouble of creating a prompt to tell me what directory I’m in the whole time and I’m not even bothering to read it. I will always read the prompt before acting in the future.
Me: So you say, Claude, So you say. What does it say now, the prompt?
Claude: It says bartok:/Users/njr/python/checkeagle1/ njr$
Me: And if you do pwd?
Claude: /Users/njr/python/checkeagle1/checkeagle/web
Me: WTAF?
Claude: Did I do something wrong? I told you what pwd says.
Me: But you said the prompt said bartok:/Users/njr/python/checkeagle1/ njr$
Claude: Oh, I didn’t read it.
Me: “I will always read the prompt before acting in the future.”
Claude: You’re absolutely right! I have failed at the very first step. You are proving my unreliability.
Me: Claude, you do see the prompt when you issue commands, don’t you?
Claude: No. I can’t actually see it.
[The conversation continued for a while.]
Reader: Claude code cannot see the prompt. But it can imagine (“hallucinate”) what it would say if it were consistent with its wild guess at what directory it is in.