Claude Code periodically deletes project-root `config/` directory (path confusion with .git internals)

Resolved 💬 5 comments Opened Mar 29, 2026 by timothy-20 Closed Mar 29, 2026

Bug Description

Claude Code (v2.1.87) periodically deletes the config/ directory from the project root. Investigation via fs_usage shows that Claude Code is attempting to delete .git-internal entry names (HEAD, objects, refs, hooks, config) at the project root instead of inside .git/. Only config/ succeeds because the others don't exist at the project root.

Environment

  • Claude Code version: 2.1.87
  • OS: macOS (Darwin 25.3.0)
  • Project: Elixir/Phoenix project with a standard config/ directory

Steps to Reproduce

  1. Open a project that has a config/ directory at the project root
  2. Run Claude Code and execute several tool calls
  3. Observe that config/ is deleted between tool calls

Evidence from fs_usage

Monitored filesystem syscalls with sudo fs_usage -w -f filesys | grep -E "(unlink|rmdir)" | grep -E "(config|mamaris-api)":

21:06:43.821015  unlinkat  [  2]  [-2]//Users/.../mamaris-api/HEAD       2.1.87.736478
21:06:43.821036  unlinkat  [  2]  [-2]//Users/.../mamaris-api/objects    2.1.87.736478
21:06:43.821041  unlinkat  [  2]  [-2]//Users/.../mamaris-api/refs       2.1.87.736478
21:06:43.821044  unlinkat  [  2]  [-2]//Users/.../mamaris-api/hooks      2.1.87.736478
21:06:43.821046  unlinkat  [  1]  [-2]//Users/.../mamaris-api/config     2.1.87.736478
21:06:43.821475  unlinkat         [17]/config.exs                        2.1.87.736478
21:06:43.821598  unlinkat         [-2]//Users/.../mamaris-api/config     2.1.87.736478

Key observations:

| Target | Errno | Result |
|--------|-------|--------|
| HEAD | [2] ENOENT | Failed — doesn't exist at project root |
| objects | [2] ENOENT | Failed |
| refs | [2] ENOENT | Failed |
| hooks | [2] ENOENT | Failed |
| config | [1] EPERM → then success | Deleted — exists as Elixir config dir |

The process ID 2.1.87.736478 is Claude Code itself (version 2.1.87).

Controlled Tests

| Location | config/ persists? |
|----------|-------------------|
| Project root ./config/ | No — deleted periodically |
| Subdirectory ./subdir/config/ | Yes |
| Separate git repo in $TMPDIR | Yes |
| Other dir names at project root (myconfig/, testdir/) | Yes |

This confirms:

  • Only project root config/ is affected
  • The name config is specifically targeted (matching .git/config)
  • It is not a general filesystem or sandbox issue

Behavior Pattern

  • The deletion happens between tool calls, not during them
  • Files survive 10+ seconds within a single Bash invocation
  • The deletion recurs periodically (every ~10-20 seconds)
  • The issue persists across sessions (observed in at least 2 consecutive sessions)
  • git checkout HEAD -- config/ restores files, but they are deleted again on the next cycle

Analysis

The names HEAD, objects, refs, hooks, config are all top-level entries of a .git/ directory. This suggests a Claude Code internal process (possibly git maintenance, worktree cleanup, or sandbox management) is operating on the project root path instead of the .git/ path, causing any project directory that shares a name with a .git entry to be deleted.

Impact

Any project with a top-level directory named config/, hooks/, objects/, or refs/ will have that directory silently deleted. This particularly affects:

  • Elixir/Phoenix projects (config/)
  • Ruby on Rails projects (config/)
  • Any framework using a top-level config/ directory

Workaround

None found. git checkout HEAD -- config/ restores files temporarily, but they are deleted again within seconds.

View original on GitHub ↗

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