Summary
After exiting an autoskillit cook or autoskillit order session, the terminal exhibits input garbling — typed commands mix with remnant output, Ctrl-C prints 9;5u instead of sending SIGINT, and bracketed paste markers appear in pasted text.
Root Cause
Claude Code enables DEC private terminal modes (bracketed paste, Kitty keyboard protocol) during its session but fails to disable them on exit. The terminal_guard() in _terminal.py correctly restores kernel TTY discipline (termios) but is missing reset sequences for two critical modes.
What to Change
Expand the VT100 reset sequence in src/autoskillit/cli/_terminal.py:65.
Current:
sys.stdout.write("\033[?1049l\033[?1l\033>\033[0m\033[?25h")
Proposed:
sys.stdout.write(
"\033[?1049l" # exit alternate screen buffer (defensive)
"\033[?2004l" # disable bracketed paste mode
"\033[?1000l" # disable normal mouse tracking
"\033[?1002l" # disable button-event mouse tracking
"\033[?1003l" # disable any-event mouse tracking
"\033[?1006l" # disable SGR extended mouse protocol
"\033[?1004l" # disable focus in/out events
"\033[?1l" # disable application cursor keys (DECCKM)
"\033>" # numeric keypad mode (DECKPNM)
"\033[!p" # DECSTR soft reset (18 DEC attributes, no screen clear)
"\033[0m" # reset SGR attributes
"\033[?25h" # show cursor (DECTCEM)
"\033[=0u" # hard-disable Kitty keyboard protocol
"\033[<99u" # drain Kitty keyboard protocol push stack
)
All added sequences are idempotent no-ops on terminals that don't support them. Verified safe on Terminal.app, iTerm2, Ghostty, Kitty, WezTerm, VS Code terminal, and Alacritty (Linux + macOS).
Tests
Update tests/cli/test_terminal.py to assert the new sequences are present in the emitted string:
- Assert
\033[?2004l (bracketed paste)
- Assert
\033[=0u (Kitty keyboard protocol hard-disable)
- Assert
\033[<99u (KKP stack drain)
- Assert
\033[!p (DECSTR)
- Assert mouse tracking sequences
Investigation Report
.autoskillit/temp/investigate/investigation_terminal-state-corruption-after-cook-exit_2026-04-08_183000.md
References
Summary
After exiting an
autoskillit cookorautoskillit ordersession, the terminal exhibits input garbling — typed commands mix with remnant output, Ctrl-C prints9;5uinstead of sending SIGINT, and bracketed paste markers appear in pasted text.Root Cause
Claude Code enables DEC private terminal modes (bracketed paste, Kitty keyboard protocol) during its session but fails to disable them on exit. The
terminal_guard()in_terminal.pycorrectly restores kernel TTY discipline (termios) but is missing reset sequences for two critical modes.What to Change
Expand the VT100 reset sequence in
src/autoskillit/cli/_terminal.py:65.Current:
Proposed:
All added sequences are idempotent no-ops on terminals that don't support them. Verified safe on Terminal.app, iTerm2, Ghostty, Kitty, WezTerm, VS Code terminal, and Alacritty (Linux + macOS).
Tests
Update
tests/cli/test_terminal.pyto assert the new sequences are present in the emitted string:\033[?2004l(bracketed paste)\033[=0u(Kitty keyboard protocol hard-disable)\033[<99u(KKP stack drain)\033[!p(DECSTR)Investigation Report
.autoskillit/temp/investigate/investigation_terminal-state-corruption-after-cook-exit_2026-04-08_183000.mdReferences