claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Confused by `noclobber`

Open brandonbloom opened this issue 5 months ago • 0 comments

Environment

  • Platform (select one):
    • [x] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [ ] Other:
  • Claude CLI version: 1.0.33 (Claude Code)
  • Operating System: macOS 15.5 (24F74)
  • Terminal: Terminal App

Bug Description

Claude is unaware of noclobber settings and then gets confused when trying to write files with bash like echo foo > already-existing.txt. It spins its wheels a bit trying to solve the issue. If told to use >! instead of >, he gets it right, but I have to remind him of this virtually every session.

Steps to Reproduce

  1. Put this in your zshrc: set -o noclobber
  2. Write a file foo
  3. Ask Claude to use bash to write to that file
  4. Notice that you get an "file exists" error.
  5. Notice Claude tries a few things and struggles to figure it out

Expected Behavior

Either Claude is aware of shell configuration and defaults to >! if necessary for the current configuration. Or, minimally, Claude recognizes file exists error and naturally knows about >! and tries again using that.

Actual Behavior

Claude spins his wheels until interrupted.

Additional Context

A workaround that seems to usually work is to add this to your CLAUDE.md:

  • NOCLOBBER is enabled in the zsh config. You must use >! to replace files.

brandonbloom avatar Jun 28 '25 19:06 brandonbloom