Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion documentation/docs/guides/context-engineering/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,18 @@ The matcher is a regular expression matched against the most relevant string for

## Hook Payload

When a hook runs, goose writes a JSON payload to the command's stdin. The payload always includes the event name and session ID, and may include fields such as the tool name, tool input, user message, last assistant message, or working directory.
When a hook runs, goose writes a JSON payload to the command's stdin. Every payload includes the event name and session ID. The remaining fields are only present when they apply to the event, so a hook should treat them as optional.

| Field | Description |
|---|---|
| `event` | Name of the event that fired, such as `PostToolUse` or `UserPromptSubmit`. |
| `session_id` | ID of the current goose session. |
| `matcher_context` | String the rule's `matcher` is tested against (for example, the tool name on tool events or the prompt text on `UserPromptSubmit`). |
| `tool_name` | Name of the tool, on tool events. |
| `tool_input` | Input arguments passed to the tool, on tool events. |
| `message` | Prompt text the user submitted, on `UserPromptSubmit`. |
| `last_assistant_message` | Final assistant text for the turn, on `Stop` when there is assistant output. |
| `working_dir` | Working directory of the session, on tool events. |

Example payload for a tool event:

Expand All @@ -166,6 +177,17 @@ Example payload for a tool event:
}
```

Example payload for a prompt event, where the submitted prompt is in `message`:

```json
{
"event": "UserPromptSubmit",
"session_id": "abc-123",
"matcher_context": "summarize this file",
"message": "summarize this file"
}
```

Example payload for a `Stop` event after an assistant reply:

```json
Expand Down