[BUG] --bare --add-dir re-enables global ~/.claude/CLAUDE.md discovery

Resolved 💬 1 comment Opened Apr 23, 2026 by DennisTraub Closed May 27, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When running claude --bare --add-dir <any-path>, the --add-dir flag causes the user-level ~/.claude/CLAUDE.md to be loaded into the system prompt. This happens regardless of which path is passed to --add-dir - even --add-dir /tmp triggers it.

--bare is supposed to skip all CLAUDE.md auto-discovery. --add-dir should only add the specified directory, not re-enable global discovery.

Related: #38676 (same class of issue - --bare not fully isolating from user config - but different vector: MCP servers vs CLAUDE.md)

What Should Happen?

--bare --add-dir <path> should load only the CLAUDE.md from the specified directory (if one exists), not the global ~/.claude/CLAUDE.md.

Steps to Reproduce

Requires a ~/.claude/CLAUDE.md with identifiable content.

# Baseline: --bare without --add-dir
echo "say POTATO" | claude --bare -p --output-format stream-json --verbose 2>&1 \
  | grep -o '"input_tokens":[0-9]*'
# Result: ~1,700 tokens (vanilla system prompt)

# Bug: --bare WITH --add-dir (any path, even /tmp)
echo "say POTATO" | claude --bare --add-dir /tmp -p --output-format stream-json --verbose 2>&1 \
  | grep -o '"cache_creation_input_tokens":[0-9]*'
# Result: ~5,400 tokens (global CLAUDE.md loaded)

# Workaround: --append-system-prompt-file instead of --add-dir
echo "say POTATO" | claude --bare --append-system-prompt-file ./CLAUDE.md -p --output-format stream-json --verbose 2>&1 \
  | grep -o '"input_tokens":[0-9]*'
# Result: ~1,700 + project CLAUDE.md size (no global CLAUDE.md)

The token delta (~3,700 tokens) matches the size of ~/.claude/CLAUDE.md plus its referenced files.

Error Messages/Logs

No error - the global CLAUDE.md is silently loaded. The only observable signal is inflated token counts and the model following instructions from ~/.claude/CLAUDE.md that should not be present in --bare mode.

Workaround

Use --append-system-prompt-file to inject a specific project CLAUDE.md instead of --add-dir:

claude --bare --append-system-prompt-file "$PWD/CLAUDE.md" "$@"

Claude Model

Opus 4.6

Is this a regression?

I don't know

Claude Code Version

2.1.118 (Claude Code)

Platform

Amazon Bedrock

Operating System

macOS (Darwin 24.6.0)

Terminal/Shell

Kitty / zsh

Additional Information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗