[Bug] Normal CLI session misclassified as background job, blocking Edit/Write tools
Bug Description
Title: Normal CLI session misclassified as background job — Edit/Write tools blocked by worktree isolation guard
Environment:
- Claude Code v2.1.159
- Opus 4.6 (from .claude/settings.json)
- macOS Darwin 21.6.0
- Launched from terminal (
claudeCLI), not/chat, not scheduled, not a background job
What happened:
A regular interactive CLI session was tagged as a background session by the system. This activated the bgIsolation worktree guard, which blocks all Edit and Write tool calls unless EnterWorktree is called first.
The system prompt injected into the session contains:
# Background Session
This session runs as a background job.
This is incorrect — the session was launched interactively from the terminal.
Impact:
- The Edit tool refuses all file modifications with: "This background session hasn't isolated its changes yet. Call EnterWorktree first..."
- EnterWorktree creates an unwanted branch, violating the user's branch strategy (direct commits to main)
- The workaround (
"worktree": {"bgIsolation": "none"}in settings.json) cannot be applied by the assistant because the Edit tool is blocked — catch-22 - The user must manually edit settings.json to restore normal functionality
Expected behavior:
An interactive CLI session should not be classified as a background job. The bgIsolation guard should only activate for actual background jobs (scheduled tasks, /chat background runs).
Reproduction:
Unclear what triggers the misclassification. The session started normally:
claude (from ~/Projects/teacherforge)
→ /admin:stats
→ follow-up questions and code edits
→ Edit tool blocked on every attempt
Workaround:
Add to .claude/settings.json:
"worktree": { "bgIsolation": "none" }
But this must be done manually since the assistant can't edit the file.
Environment Info
- Platform: darwin
- Terminal: xterm-256color
- Version: 2.1.159
- Feedback ID: 733e4341-99ee-4830-9b42-1dfcb07dbb17
Errors
[]This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗