[FEATURE] Expose pasted text content/boundaries to UserPromptSubmit hook (mirror imagePasteIds)

Open 💬 0 comments Opened Jul 16, 2026 by abreufilho

Problem

When a user pastes a large block of text into the TUI, it collapses to a [Pasted text #N +M lines] placeholder. On submit, that placeholder is expanded into the full content, and the UserPromptSubmit hook receives a single flat prompt string in which the pasted content is indistinguishable from the text the user actually typed. There is no boundary marker and no metadata field.

This is asymmetric with how images are handled: a pasted image leaves an [Image #N] marker in the prompt text and the transcript records an imagePasteIds field on the user message. There is no equivalent for pasted text.

I verified this empirically by scanning ~2,500 stored prompts from a UserPromptSubmit hook: only 1 contained the literal string [Pasted text, and messages that were clearly large pastes stored the fully-expanded content, confirming the placeholder is resolved before the hook sees it. I also scanned transcript JSONL under ~/.claude/projects/ — the only paste-related field present is imagePasteIds (images only); there is no field tracking text-paste boundaries.

Why this matters

Hooks/plugins that log, classify, redact, or route user input cannot tell which portion of a prompt was pasted vs typed. Concrete use cases:

  • Prompt memory / analytics that classify "typed instruction" vs "pasted artifact" (logs, code, error dumps) to build better session summaries.
  • Redaction/DLP hooks that want to treat pasted blobs differently from typed instructions.
  • Tools that want to persist pasted artifacts separately (e.g. save a pasted log to a file and keep the typed instruction inline).

Today the only workaround is a length/heuristic guess over the whole blob, which is unreliable.

Proposal

Expose text-paste boundaries to the UserPromptSubmit hook, mirroring the existing imagePasteIds precedent. For example, add a field to the hook payload:

{
  "hook_event_name": "UserPromptSubmit",
  "prompt": "here is the log [Pasted text #1] please analyze it",
  "pastedContents": [
    { "id": 1, "content": "...full pasted text...", "lines": 240 }
  ]
}

Two equally acceptable shapes:

  1. Keep prompt as the expanded string (current behavior) but add a pastedContents array mapping each paste id to its raw content and offset/line count, so a hook can reconstruct which spans were pasted.
  2. Alternatively, keep the [Pasted text #N] placeholders in the prompt field delivered to the hook and provide the resolved contents via pastedContents, letting the hook decide how to expand them.

Either resolves the asymmetry with images and closes the gap.

Related

Existing issues cover the UI side of the paste placeholder (expanding/viewing/editing before submission): #3412, #11033, #29375, #56722, #76801, and the team-boundary data-loss bug #49944. None of them cover exposing paste boundaries/content to the hook layer — this request is specifically about the programmatic (hook/plugin) surface.

Environment

  • Observed on Claude Code v2.1.x (CLI, Linux).

View original on GitHub ↗