Add an additional_context to the beforeSubmitPrompt hook output similar to sessionStart and postToolUse hooks to allow for injecting additional context on each user prompt submission. Potential use cases for this is to have a script inject certain context whenever the user prompt contains certain strings, commands, or attachments.
My immediate use for this would be to have a hook script automatically run necessary scripts (creating git diff file and setting up review directory) for my /code-review command and output the results to the agent in order to reduce agent turns from having the agent execute them. This could also be achieved by adding a beforeCommand hook but I figure this field would be lower friction since the hook already exists and opens up more potential use cases.
Great feature request! Having additional_context available on beforeSubmitPrompt would indeed open up a lot of powerful workflow automations.
However, just a heads-up to @mibogo and the dev team: the additional_context functionality you mentioned for postToolUse is actually completely broken in the current builds (e.g., 3.1.15).
Currently, the postToolUse hook suffers from empty input payloads (no stdin, argv, or env vars), the output context is completely discarded and never reaches the model, and it fires very intermittently.
So while I completely support adding this to beforeSubmitPrompt, the engineering team urgently needs to fix the underlying hook infrastructure first. We are tracking the major bugs with the existing implementation here:
Once the core plumbing is fixed, expanding it to beforeSubmitPrompt would be amazing!