Feature: Hook output type `attachFile` to inject large content without size cap or terminal noise

Resolved 💬 2 comments Opened Jun 6, 2026 by de-gn Closed Jul 12, 2026

Problem

The current hook output channels have a fundamental limitation for use cases that need to inject large content (e.g. documents, memory sources) into the model's context:

  • additionalContext (UserPromptSubmit) → injected as <system-reminder>, but has a ~2KB inline cap; larger content is truncated and saved to a temp file, requiring an extra tool-call roundtrip to retrieve
  • Prompt text (UserPromptExpansion) → no size cap, but content appears verbatim as the user's message in the terminal, polluting conversation history

Neither channel works cleanly for large content: one forces extra roundtrips, the other creates terminal noise.

Proposed solution

Add a new hook output field attachFile (or attachDocument) that accepts a file path:

{
  "hookSpecificOutput": {
    "hookEventName": "UserPromptSubmit",
    "attachFile": "C:/path/to/prefetched-content.txt"
  }
}

Claude Code would read the file and inject its content as a document content block in the API call — invisible in the terminal, no size cap, no extra roundtrip.

Use case

A UserPromptSubmit hook that detects document path/RAG-source pattern in the prompt, fetches the full source text from a local API, writes it to a temp file, and returns attachFile pointing to that file. The full content lands in context with zero roundtrips and zero terminal noise.

Current workaround

Accept extra roundtrips (export + Read tool calls) or split large sources into <2KB chunks.

View original on GitHub ↗

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