# UserPromptSubmit Hook

> The event when you send a prompt, before Claude reads it.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** UserPromptSubmit

## Think of it like

It is like a clerk who reads your form. Then it goes to the office.

## Definition

UserPromptSubmit is the hook event that fires when you send a prompt, before Claude reads it. A hook here can add context, such as today's tickets, or block the prompt. Plain text the hook prints is added for Claude to see. It also fires on turns Claude Code starts on its own, such as a /loop run.

## Example

Jack's hook adds the current git branch to each prompt, so Claude always knows which branch it is on.

## Example code

```bash
#!/bin/bash
# add the current git branch to every prompt
echo "Current branch: $(git branch --show-current)"
```

Plain text printed here reaches Claude.

## Why it matters

It is the one place to add facts to every prompt without typing them.

## Common mistake

Printing debug lines to stdout. They all reach Claude as context. Send them to stderr.

## Three principles

- **Before Claude reads.** Each prompt.
- **Add or block.** Context or stop.
- **Stdout reaches Claude.** Plain text.

## Related terms

- [Claude Code Hook](https://learn.benibix.com/term/ai/claude-code-hook)
- [additionalContext](https://learn.benibix.com/term/ai/hook-additional-context)
- [Stop Hook](https://learn.benibix.com/term/ai/stop-hook)

![The order hook events fire in: a session, each turn, and each tool call inside it.](https://learn.benibix.com/diagrams/hook-lifecycle.svg)

---

Source: https://learn.benibix.com/term/ai/userpromptsubmit-hook
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-16
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
