[FEATURE] Preserve input buffer on Ctrl+C for recovery

Resolved 💬 3 comments Opened Mar 17, 2026 by thibhoz23 Closed Mar 21, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

When composing a prompt in the CLI input field, pressing Ctrl+C (whether intentionally to cancel or
accidentally) permanently discards all typed text with no way to recover it. This is particularly painful
when writing long, detailed prompts.

Proposed Solution

Automatically persist the current input buffer so it can be recovered after Ctrl+C. Possible implementations:

  1. Auto-save on Ctrl+C: Before clearing the input, write the buffer contents to a recovery file (e.g.

~/.claude/last_input_draft.txt). On next prompt focus, offer to restore it (or make it available via Up arrow
/ a /recover command).

  1. Hook event: Expose a new InputCancel or CtrlC hook event that fires before the buffer is cleared,

passing the current input text via stdin. This would let users implement their own recovery logic.

  1. Draft persistence: Periodically auto-save the input buffer (e.g. on every keystroke or debounced) so that

even a hard kill preserves the draft.

Alternative Solutions

Current workarounds and why they fall short

| Workaround | Limitation |
|---|---|
| Ctrl+G (open editor) | Must remember to use it before typing — doesn't help after the fact |
| Up arrow (input history) | Only recalls submitted prompts, not discarded drafts |
| Ctrl+S (stash) | Requires manual action before the accidental Ctrl+C |

Priority

Medium - Would be very helpful

Feature Category

CLI commands and flags

Use Case Example

_No response_

Additional Context

There is currently no hook event that fires during typing or on Ctrl+C — only UserPromptSubmit (which requires
Enter). The input buffer is internal to the terminal UI with no external access, making it impossible to solve
this in userland today.

View original on GitHub ↗

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