[BUG] Sonnet 4.6 agent misspells .claude as .claire in file path, creating stray directory
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?
A Sonnet 4.6 subagent running in an isolated worktree (via isolation: worktree) misspelled .claude as .claire when constructing a file path for a Write tool call. This created a stray .claire/ directory tree in the main repository root.
The agent was writing files to .claude/worktrees/agent-XXXX/src/api/ — a series of batch writes in the same model response. The first Write used the correct path, but the second drifted from .claude to .claire:
Correct (first write in the batch):
.claude/worktrees/agent-XXXX/src/api/comments.ts ✅
Incorrect (second write, same model response):
.claire/worktrees/agent-XXXX/src/api/notifications.ts ❌
The model self-corrected on the next turn:
{
"type": "text",
"text": "I wrote notifications.ts to the wrong path (`.claire` instead of `.claude`). Let me fix that and also write the service files."
}
It then re-wrote the file to the correct .claude/worktrees/... path, but never cleaned up the .claire/ directory it accidentally created.
Relevant log excerpts
The incorrect Write tool call (abbreviated):
{
"role": "assistant",
"content": [{
"type": "tool_use",
"id": "toolu_013Kdaf3VaBMUmkzTxyayaPU",
"name": "Write",
"input": {
"file_path": "/path/to/repo/.claire/worktrees/agent-XXXX/src/api/notifications.ts",
"content": "..."
}
}]
}
The tool result confirming the stray file was created:
{
"type": "tool_result",
"content": "File created successfully at: /path/to/repo/.claire/worktrees/agent-XXXX/src/api/notifications.ts"
}
The model's self-correction on the next turn:
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "I wrote notifications.ts to the wrong path (`.claire` instead of `.claude`). Let me fix that and also write the service files."
},
{
"type": "tool_use",
"name": "Write",
"input": {
"file_path": "/path/to/repo/.claude/worktrees/agent-XXXX/src/api/notifications.ts",
"content": "..."
}
}
]
}
Impact
- A
.claire/worktrees/agent-XXXX/src/api/directory tree was created in the main repo root (outside the worktree) - The stray directory was never cleaned up despite the model self-correcting
- The
guard-files.shPreToolUse hook only checks for sensitive files — it doesn't validate that the path is within the worktree boundary, so the write was not blocked
Related issues
This is the same class of bug as:
- #10580 — Sonnet misspells
/home/tbekolayas/home/tbekolag - #25402 — Opus misspells
rcorreasrconte - #17893 — Username
jdpruettcorrupted tojdprueet
The difference here is that the misspelling hit a directory name (.claude → .claire) rather than a username, and because the Write tool creates intermediate directories, it silently produced a stray directory tree instead of failing with a "not found" error.
What Should Happen?
- The model should not misspell well-known path components like
.claude - When running in a worktree, writes outside the worktree root could be blocked or warned about at the tool level (not just via user hooks)
- When the model self-corrects a wrong-path write, it should clean up the stray file/directory
Steps to Reproduce
Not reliably reproducible — this is a stochastic model generation error. It occurred during a batch of Write tool calls in a single model response where the agent was constructing long absolute paths from memory.
Claude Model
Sonnet 4.6 (claude-sonnet-4-6)
Claude Code Version
2.1.70
Platform
macOS (Darwin 25.3.0)
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗