Shell mode (!): retained bang lands after typed text (cursor placed before the ! on sticky re-entry)
Description
Two related problems with shell mode (! prefix) in interactive mode:
1. Bug: cursor/prefix misplacement on sticky re-entry
When shell mode persists from a previous ! command (documented sticky behavior), the retained ! is positioned incorrectly relative to the cursor on the next input: the cursor sits before the ! rather than after it, so newly typed text is inserted ahead of the bang. The result is the ! ending up appended after the command instead of prefixing it.
Observed: after running ! git status on a previous prompt, typing git status again executed as:
git status!
# => git: 'status!' is not a git command. See 'git --help'.
Expected: either the retained ! acts as a proper prefix with the cursor placed after it, or the input starts clean.
2. UX: no way to disable shell-mode persistence
Shell mode persisting between prompts (exit via Escape/Backspace/Ctrl+U per the interactive-mode docs) is easy to trip over — a stray retained ! silently corrupts the next command. A settings.json option to make shell mode one-shot (per-prompt) would avoid the class of error entirely.
Environment
- Claude Code 2.1.203
- macOS (Darwin 25.5.0), zsh
- Terminal session (CLI interactive mode)