Know when Claude Code needs you: Windows notifications from WSL
On this page
- Know when Claude Code needs you: Windows notifications from WSL
- What you get
- What you need
- How Claude Code hooks fit in
- Step 1: a toast per session that clears itself
- Step 2: say what it wants
- Step 3: questions, plans, "finished" and errors
- The complete script
- Things to keep in mind
- What about the built-in notifications?
- Wrapping up
I give Claude Code a task, switch to the browser while it works, and come back ten minutes later to find it has been waiting for nine of them: "Allow this command?" Or it finished long ago and I didn't notice.
Claude Code can tell you when it needs you, but in WSL under Windows Terminal nothing reaches the Windows desktop by default. In the toastback post I showed a toast that says a coding agent is waiting. This post explains the setup behind it: a Claude Code hook that shows a Windows notification when a session needs you, says what it needs, and removes it again once you've answered.

What you get
One toast per session, and it says what the session is waiting for:

- Permission requests: which tool, and the command, file or URL. For a plan, the start of the plan.
- Questions: the question and its options, when Claude asks you to choose.
- Finished: the start of the reply after a long turn, with how long it took.
- Waiting: a reminder when a short turn ended a minute ago and you haven't typed.
- Errors: when a turn stopped on a rate limit or another API error.
The source line names the project, so with three sessions open you know which terminal tab to go to. When you answer in the terminal, the toast disappears from the screen and from the notification center, so there are no stale reminders left behind.
What you need
- Claude Code in WSL. Windows Terminal, the VS Code terminal or any other: hooks don't depend on the terminal.
- toastback. The toastback post and the README on GitHub cover the install. Check that
toastback -t "Hello" -m "World"shows a toast. jq, from your distro's packages.
How Claude Code hooks fit in
A hook is a command Claude Code runs at a given point in a session. It receives a JSON object on stdin with the session_id, the working directory (cwd), the event name and the event's own fields. You register hooks in ~/.claude/settings.json, so they apply to every project.
These are the events this setup uses:
| Event | When it fires | What the hook does |
|---|---|---|
Notification |
permission_prompt: a permission prompt has been waiting about 6 seconds. idle_prompt: Claude finished about 60 seconds ago and you haven't typed since. elicitation_dialog: an MCP server asks for input |
shows the toast |
PermissionRequest |
the moment Claude asks for a permission | remembers what was asked |
PreToolUse for AskUserQuestion |
Claude is about to ask you a multiple-choice question | shows the question after a few seconds |
Stop / StopFailure |
a turn ended / ended on an API error | "finished" or error toast |
UserPromptSubmit, PostToolUse, PostToolUseFailure, SessionEnd |
you answered, a tool ran, the session ended | removes the toast |
The delays are what make this pleasant. permission_prompt only fires when the prompt has gone unanswered for about six seconds, and each keystroke in the terminal pushes it back, so you get no toast while you're sitting at the terminal and approving things.
Step 1: a toast per session that clears itself
The first version only needs Claude Code's own notification text. Save it as ~/.claude/hooks/claude-notify and make it executable:
#!/bin/bash
# Claude Code hook: a toast while a session waits for you, removed once you answer.
input=$(cat)
toastback=$HOME/.local/bin/toastback
sid=$(jq -r '.session_id // ""' <<<"$input")
[[ $sid =~ ^[A-Za-z0-9_-]{1,56}$ ]] || exit 0
state=${XDG_RUNTIME_DIR:-/tmp}/claude-notify
mkdir -p "$state"
shown=$state/shown-$sid
case $(jq -r '.hook_event_name' <<<"$input") in
Notification)
jq --arg id "claude-$sid" '{
id: $id,
title: (.title // "Claude Code"),
body: (.message // "Claude Code needs you"),
attribution: ("Claude Code · " + (.cwd // "" | split("/") | last)),
icon: "question",
expires: "1h"
}' <<<"$input" | "$toastback" - >/dev/null 2>&1 && touch "$shown"
;;
UserPromptSubmit | PostToolUse | PostToolUseFailure | Stop | SessionEnd)
# PostToolUse runs after every tool call: only call Windows when a toast is shown
if [[ -e $shown ]]; then
rm -f "$shown"
"$toastback" remove "claude-$sid" >/dev/null 2>&1
fi
;;
esac
exit 0Three things make this work:
- The toast id comes from the session id. A newer toast from the same session replaces the older one instead of stacking up, and
toastback removecan take it away when you answer. - A marker file.
PostToolUsefires after every tool call. Starting a Windows exe takes a moment, so the hook only callstoastback removewhen it knows a toast is on screen. - Untrusted text stays data. Messages and commands come from the model, and the model can be steered by whatever it read.
jqturns them into JSON and toastback shows them as text, so nothing from the hook input is ever run by a shell. The toast has no buttons, so a click can't run anything either.
expires: "1h" lets Windows drop toasts you never looked at, and the script calls toastback by its full path so the hook also works where ~/.local/bin isn't on PATH.
Then register it:
{
"hooks": {
"Notification": [
{
"matcher": "permission_prompt|idle_prompt|elicitation_dialog",
"hooks": [{ "type": "command", "command": "~/.claude/hooks/claude-notify", "timeout": 15 }]
}
],
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "~/.claude/hooks/claude-notify", "timeout": 15 }] }],
"PostToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "~/.claude/hooks/claude-notify", "timeout": 15 }] }],
"PostToolUseFailure": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "~/.claude/hooks/claude-notify", "timeout": 15 }] }],
"Stop": [{ "hooks": [{ "type": "command", "command": "~/.claude/hooks/claude-notify", "timeout": 15 }] }],
"SessionEnd": [{ "hooks": [{ "type": "command", "command": "~/.claude/hooks/claude-notify", "timeout": 15 }] }]
}
}If you already have hooks, merge these entries into your existing hooks object. Start a new session, ask for something that needs a permission, and look away for ten seconds.
Step 2: say what it wants
"Claude needs your permission to use Bash" tells you to go back, but not what you'd be saying yes to. The Notification event doesn't include the command. PermissionRequest does, and it fires as soon as the prompt appears. Toasting there would also pop up toasts while you're looking at the terminal, so the hook only remembers the request, and the permission_prompt notification six seconds later shows it:
PermissionRequest)
# Fires as soon as Claude asks. Don't toast yet (you may be watching): remember what it wants.
jq '{title: "Allow \(.tool_name)?",
body: (.tool_input.command // .tool_input.file_path // .tool_input.url // "" | .[:200]),
details: (.tool_input.command // (.tool_input | tojson))}' <<<"$input" >"$state/perm-$sid"
;;In the Notification branch, merge that file into the toast when the type is permission_prompt (jq --argjson extra "$(cat "$state/perm-$sid")" '{…} + $extra'), and delete it there and when the session moves on. Register the event with "PermissionRequest": [{ "hooks": [ … ] }].
The details field is the toastback feature that makes long commands readable: click the toast's text and a dialog shows the whole thing.

One rule matters for this event: never print anything to stdout. For PermissionRequest and PreToolUse, Claude Code reads JSON on stdout as a decision, which is how a hook can allow or deny a request. A notification hook should stay out of that, which is why every toastback call in it ends in >/dev/null. Exit codes are no shortcut either: exit 2 doesn't deny a PermissionRequest; it's ignored.
Step 3: questions, plans, "finished" and errors
The complete script adds the remaining cases. Each needs only a few lines:
Questions. When Claude asks a multiple-choice question, PreToolUse for AskUserQuestion carries the questions and options. The hook starts a detached background job that shows them after five seconds unless you answer first, so it can return at once:

Plans. In plan mode, the approval goes through PermissionRequest for the ExitPlanMode tool, whose input is the plan. The toast says "Approve the plan?" with the plan's first lines, and the details dialog has all of it.
Finished. Stop carries last_assistant_message, the text of Claude's final reply. The hook notes the time on UserPromptSubmit, and on Stop it toasts only if the turn took at least 30 seconds. Quick answers that you're waiting for don't need a toast, and the idle_prompt notification covers them after a minute anyway, with the start of the reply as its text.

Errors. StopFailure fires when a turn ends on an API error, with an error type such as rate_limit or server_error and an error_details text.

Only one toast per session is ever on screen. The newest one replaces the previous one, and a reminder isn't shown when a more specific toast is already up.
The complete script
The script I use every day is about 200 lines of bash and jq. Download the script (download, opens in a new tab) and its settings entries (download, opens in a new tab), both as text files. Save the script as ~/.claude/hooks/claude-notify, make it executable (chmod +x) and merge the JSON into your ~/.claude/settings.json. Compared with the steps above it adds:
- the question, plan, finished and error toasts, with icons;
- useful text for each tool: the command and its description for Bash, the relative path for file edits, the URL for web fetches, the server and tool name for MCP tools;
- Markdown stripped from replies and plans, and long text cut to fit the toast;
- a
--dry-runmode that prints the toast instead of showing it, for testing with a hand-written event:
echo '{"hook_event_name":"Notification","session_id":"test","cwd":"/work/my-app",
"notification_type":"idle_prompt","message":"Claude is waiting for your input"}' \
| ~/.claude/hooks/claude-notify --dry-runEnvironment variables tune it. Set them in your shell or in the env block of settings.json:
| Variable | Default | Effect |
|---|---|---|
CLAUDE_NOTIFY |
1 |
0 turns it off, for a screen share or a demo |
CLAUDE_NOTIFY_MIN_TURN |
30 |
seconds a turn must take before "finished" shows a toast |
CLAUDE_NOTIFY_QUESTION_DELAY |
5 |
seconds before a question shows a toast |
TOASTBACK |
~/.local/bin/toastback |
where toastback is |
Things to keep in mind
- Toasts show what your agent is doing. Commands, file paths and the start of replies appear on the desktop and in the notification center for up to an hour. If a command can contain a secret, or you share your screen, set
CLAUDE_NOTIFY=0for that session. - Keep the hook fast. It runs on every tool call. The first thing the full script does on
PostToolUseis check whether it has anything to remove, and it does nothing else when the answer is no. - Do Not Disturb hides toast banners. They still land in the notification center. If you want the "waiting" toast to break through, toastback's
"mode": "dialog"shows a dialog instead, which Do Not Disturb doesn't hide. - Hook events change. Claude Code is moving fast. Event names, fields and timings above match the hooks documentation as of November 2026, so check the hooks reference if something stops working.
What about the built-in notifications?
Claude Code has its own notifications, set with preferredNotifChannel in ~/.claude/settings.json. By default it sends desktop notifications in iTerm2, Kitty and Ghostty. In other terminals, Windows Terminal among them, nothing happens unless you choose terminal_bell.
On Windows Terminal, the bell is a cheap first step. Set the channel in ~/.claude/settings.json:
{
"preferredNotifChannel": "terminal_bell"
}Then, in Windows Terminal's settings, give your WSL profile "bellStyle": ["window", "taskbar"]. Claude Code now rings the bell whenever it would send a notification, and Windows Terminal's taskbar button turns red until you switch back to it. It tells you something happened, but not which session or what it wants, and you only see it when Windows Terminal isn't the window in front.
A hook can also return a terminalSequence with a terminal notification escape sequence (OSC 9 or OSC 777), which Claude Code writes to your terminal, so you can make terminals that support it show a notification. That's still only one line of text, without the project, the command or a way to remove it.
The toastback hook does more, and it doesn't care which terminal the session runs in.
Wrapping up
It took me a few iterations to get here. The first version toasted on every event and was more annoying than useful. The delays, the single toast per session and the removal on answer are what made it something I leave on all day.
The script and the settings snippet are linked above. toastback is free and open source, on GitHub, and the toastback post shows what else it can do: buttons that run commands, dialogs and reminders.
Read it online: https://gergodrazsdik.com/blog/claude-code-notifications-with-toastback
Comments
No comments yet.
Leave a comment