All Agent Engineering

Claude Code prompt submission: context and blocking

Inspect UserPromptSubmit input, context and blocking output.

AINavWritten / Updated
On this page

At a glance

This page inspects one event contract from official Claude Code hook documentation. Use a reviewed settings copy, inspect event input and output, then observe loading. This run checked synthetic JSON only and enabled no actual hook.

Runtime and applicability

Article type
Spec file
Verified
Applies to
  • Claude Code Applies to the Claude Code hook event documented here.

File locations

PathScopeHow it is read
.claude/settings.jsonProject hooks settings copy; preserve existing configuration.Read by Claude Code under settings loading and the event contract; not enabled in this run.

When to use

  • Inspect UserPromptSubmit input, context and blocking output.

When not to use

  • The event or required fields are unclear, or a local JSON check is expected to replace permission and execution evidence.

Inspect the submitted prompt stage

UserPromptSubmit runs after submission and before Claude processes the prompt, receiving prompt. For a typed skill or custom command such as /deploy staging, it receives the typed line rather than expanded content. Inspect the expansion event for expanded material. Establish the task, event and required fields without inventing missing input.

Add context on exit zero

On exit zero, a command hook can add context through stdout recognized as plain text or JSON hookSpecificOutput.additionalContext with hookEventName=UserPromptSubmit. Documentation describes a named system reminder without a visible transcript entry. Inspect debug logs for delivery; stdout text does not establish successful checking.

Use top-level block and reason

Blocking uses top-level decision=block and reason. The reason is shown to the user and is not added to Claude context; omitting decision allows processing. Exit two also blocks with stderr as the user-facing reason. PreToolUse permissionDecision is not this event contract, and additionalContext is not blocking.

Inspect synthetic output before the event

Local parsing checked one synthetic JSON with event-specific additionalContext and another with block and a nonempty reason. No hook or skill was registered or run. Configure a synchronous command and valid script in a settings copy, then inspect /hooks and debug logs. Stop relying on a check with mismatched fields, event or blocking reason.

Sources

All links are official pages; verification dates are listed per source, and links point to the version checked.

  1. Anthropic · Hooks reference

Found an error? Tell us →