Skip to content

Commit a578548

Browse files
feat: add notification hook for user input prompts (#1415)
* feat: add notification hook for user input prompts Add Linux desktop notification hook that triggers when Claude Code is awaiting user input. This is the first hook implementation in the project and establishes the pattern for future hooks. The hook uses notify-send to display system notifications in two scenarios: - When Claude requests tool usage permission - When the prompt input remains idle for 60+ seconds Configuration added to .claude/settings.json (version-controlled) to make notifications available project-wide. Closes #1414 * docs: add comprehensive hooks configuration documentation Add detailed hooks section to claude-code-settings.md explaining: - Hook structure and syntax - Available hook events and their purposes - Matcher field behavior with comparison table - Important distinction between empty string and wildcard matchers - Current notification hook configuration and prerequisites - Security best practices for hook implementation This documentation establishes the pattern for future hook implementations and clarifies the non-intuitive empty string matcher for Notification hooks. * refactor: simplify hooks documentation to link official docs Replace detailed hook documentation with links to authoritative sources: - https://docs.claude.com/en/docs/claude-code/hooks - https://docs.claude.com/en/docs/claude-code/hooks-guide Keep only project-specific information about implemented hooks. Avoids duplicating official docs that may change over time. * Update .claude/settings.json Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com> --------- Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com>
1 parent fed54d0 commit a578548

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

.claude/settings.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,18 @@
6464
"dotfiles-commands@dotfiles-marketplace": true
6565
},
6666
"forceLoginMethod": "claudeai",
67-
"alwaysThinkingEnabled": true
67+
"alwaysThinkingEnabled": true,
68+
"hooks": {
69+
"Notification": [
70+
{
71+
"matcher": "",
72+
"hooks": [
73+
{
74+
"type": "command",
75+
"command": "notify-send 'Claude Code' 'Awaiting your input - please check the terminal'"
76+
}
77+
]
78+
}
79+
]
80+
}
6881
}

docs/claude-code-settings.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,44 @@ Environment variables configured:
5555
- `MCP_TOOL_TIMEOUT`: 60000 - MCP tool execution timeout
5656
- `MAX_MCP_OUTPUT_TOKENS`: 25000 - Maximum tokens in MCP responses
5757

58+
## Hooks Configuration
59+
60+
Hooks allow you to execute custom commands in response to Claude Code events. They are configured in `.claude/settings.json` under the `"hooks"` key.
61+
62+
**Official Documentation:**
63+
- [Hooks Reference](https://docs.claude.com/en/docs/claude-code/hooks) - Available events, matcher syntax, and configuration structure
64+
- [Hooks Guide](https://docs.claude.com/en/docs/claude-code/hooks-guide) - Examples and best practices
65+
66+
### Hooks Implemented in This Project
67+
68+
#### Notification Hook (Issue #1414)
69+
Displays Linux desktop notifications when Claude Code is awaiting user input.
70+
71+
**Triggers:**
72+
- When Claude requests tool usage permission
73+
- When the prompt input remains idle for 60+ seconds
74+
75+
**Configuration:**
76+
```json
77+
"Notification": [
78+
{
79+
"matcher": "",
80+
"hooks": [
81+
{
82+
"type": "command",
83+
"command": "notify-send 'Claude Code' 'Awaiting your input'"
84+
}
85+
]
86+
}
87+
]
88+
```
89+
90+
**Prerequisites:**
91+
- Linux: `libnotify-bin` package (installed via `sudo apt install libnotify-bin`)
92+
- macOS: Native notification system (no additional packages required)
93+
94+
**Note:** For `Notification` hooks, the matcher is an empty string (`""`), not `"*"`, since notification events are not tool-specific.
95+
5896
## Adding New Settings
5997

6098
1. Add the setting to `.claude/settings/claude-code-defaults.json`

0 commit comments

Comments
 (0)