Skip to content

Feat: Add an optional beep when Claude finishes or needs input - #738

Merged
OsherElhadad merged 3 commits into
mainfrom
feat/plugin-beep
Nov 1, 2026
Merged

OsherElhadad merged 3 commits into
mainfrom
feat/plugin-beep

Conversation

@boazdavid

Copy link
Copy Markdown
Collaborator

Summary

The plugin now plays a short sound when Claude finishes a turn or waits for the user. The sound is on by default. The user can turn it off.

Closes #737

What changed

  1. Add context-guru-plugin/scripts/beep.sh. It picks the first player that exists: afplay, then paplay, then aplay, then a terminal bell. It always exits 0.
  2. Run beep.sh on the Stop and Notification hooks. The signal.sh hook on Notification does not change.
  3. Add the beep plugin option (on or off, default on).
  4. Add CONTEXT_GURU_BEEP. It wins over the option, so one shell can differ from the saved setting.
  5. Document the option in docs/how-to/install-plugin.md. The heading now says seven options.

Rules kept

  • The sound is local. Nothing is sent to the proxy.
  • The hook does not read the hook payload.
  • A missing player does not break a session.

How it was tested

  • go test ./context-guru-plugin/ -run Beep passes.
  • The tests cover default on, off by option, off by environment variable, the environment variable beating the option in both directions, no player, the hook wiring, and the option default.
  • gofmt, go vet and bash -n are clean.
  • I did not run the full plugin test package. It takes over 500 seconds.
  • I did not build the docs with mkdocs.

Limits

  • The player tests run only on macOS. They skip elsewhere. The Linux players and the terminal bell have no test.
  • A user who already has their own Stop or Notification beep hook hears two sounds.

Open questions

  • Should Stop and Notification use different sounds?
  • Should the Codex plugin get the same option?

Assisted-By: Claude (Anthropic AI) [email protected]

Play a short sound on the Stop and Notification hooks. The sound is local
and sends nothing anywhere.

- Add scripts/beep.sh. It uses afplay, then paplay, then aplay, then a
  terminal bell, and always exits 0.
- Add the beep plugin option, default on. CONTEXT_GURU_BEEP overrides it.
- Document the option in the install page.

Closes #737

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID BOAZ <[email protected]>

@boazdavid boazdavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @boazdavid) Claude Code 2.1.241, claude-sonnet-5-5 offload-review skill, @boazdavid's session fresh 1 of 2 1 of 2 3069560db172 approve

Verdict: approve

Findings

None.

Non-blocking

  • Default is on. Every existing user hears a sound after the update. The PR title says "optional". The docs and the option description state the default, so this is a product choice. Confirm it is wanted.
  • scripts/beep.sh:30 — stderr noise when no tty. The printf '\a' >/dev/tty 2>/dev/null line prints /dev/tty: Device not configured when the hook has no controlling terminal. I ran the script with PATH=/nonexistent and no tty and saw the message. The exit code stays 0, so fail-open holds. To silence it, write { printf '\a' >/dev/tty; } 2>/dev/null.
  • Double sound is possible. Stop and Notification (idle prompt) can both fire for one wait. This is expected. Mention it in the docs if users report it.
  • Test gaps. The player tests run on macOS only. The paplay/aplay/bell branches have no test. TestBeepWithNoPlayerExitsZero sets PATH to an empty dir, so cat is also missing. The test checks only exit 0.
  • docs/data-dependence.md has no row for this feature. The feature reads no customer data and sends nothing (the script never reads stdin content). The PR description should say so: data dependence none at all three storage levels.
  • Mode values. beep.sh accepts off|0|false|no. signal.sh accepts off|0|false. The difference is small. Align them if you want one rule.

What I checked

  • Full diff of all 5 files: plugin.json, hooks.json, beep.sh, beep_test.go, install-plugin.md.
  • beep.sh logic: env var beats plugin option, off exits 0, the player runs detached, every path exits 0.
  • Ran beep.sh with no player and no tty. Exit code 0.
  • hooks.json: valid JSON. Notification keeps signal.sh and adds beep.sh. Stop runs beep.sh. Timeouts are 5 s.
  • plugin.json: beep is a string option, default on. It matches the client_signals pattern.
  • Script mode bit is 100755 in git.
  • Fail-open rule: the hook cannot block or fail Claude Code, and it does not touch requests.
  • I did not run Go tests (not approved).

@boazdavid boazdavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @boazdavid) Claude Code 2.1.241, claude-sonnet-5-5 offload-review skill, @boazdavid's session fresh 2 of 2 1 of 2 3069560db172 blocking

Verdict: blocking

Findings

  1. docs/data-dependence.md — the PR adds a feature but does not update the data-dependence page
    • What fails: CLAUDE.md ("Metadata first") says every PR that adds a feature must state its data dependence. It must say what the feature does at each storage level (off, metadata only, everything). It must update docs/data-dependence.md. The diff touches 5 files and docs/data-dependence.md is not one of them. The page has rows for plugin features, for example "Wait-cause and lifecycle signals" (line 226) and "Costly settings check" (line 227). The beep has no row.
    • Proof: git diff ad87e369..HEAD --stat lists plugin.json, beep_test.go, hooks.json, beep.sh, install-plugin.md. grep -in beep docs/data-dependence.md finds nothing. The data-dependence fact is true and easy to state: beep.sh never reads the hook payload (cat >/dev/null) and sends nothing. So the row is short, but the rule asks for it.
    • Fix: Add one row. Say it is no data: it reads no stored data and no payload. Say it works the same at all 3 storage levels. Put a "Decided by" name in it. State "no change in data dependence" in the PR description.

Non-blocking

  • scripts/beep.sh:17-19 — Only lowercase off | 0 | false | no silences the beep. The beep option is free text. A user who types Off or OFF in /plugin configure still hears the sound. Consider ${MODE,,} or a second case arm.
  • scripts/beep.sh — Stop also fires in non-interactive claude -p runs and in scripts. The default is on, so those runs beep on macOS. This is a behavior change for every existing user at update time. The description and docs say on is the default, but the docs do not say that scripted runs beep. Consider one sentence.
  • scripts/beep.sh:30 — The terminal-bell fallback writes to /dev/tty. Claude Code may draw a TUI on that terminal. A bell byte is harmless, but nothing tests this branch. TestBeepWithNoPlayerExitsZero checks only the exit code. It does not check that nothing was printed to stdout.
  • beep_test.go — 4 of the 6 tests call skipUnlessMac. On Linux CI only the wiring and manifest tests run. The paplay and aplay branches have no test. A fake paplay plus a sound-file path override would test them.
  • docs/how-to/install-plugin.md — The table says Client signals default is off, but plugin.json says auto. This was wrong before this PR. Do not fix it here, but it may deserve its own issue.

What I checked

  • Read the full diff of all 5 files, and the whole of beep.sh, hooks.json and beep_test.go.
  • beep.sh fail-open path: set -uo pipefail without -e. Every exit is 0. cat >/dev/null failing (no cat on PATH) does not stop it. The player runs in a detached subshell with all output redirected, so the hook returns at once. A missing player or sound file reaches the bell branch, then exit 0.
  • Switch order: CONTEXT_GURU_BEEP wins over CLAUDE_PLUGIN_OPTION_BEEP. The script, the tests and the docs agree. An empty CONTEXT_GURU_BEEP falls back to the option (:-), which is fine.
  • hooks.json: Notification keeps signal.sh and adds beep.sh in one group. Hooks in a group run in parallel, so beep.sh cannot delay signal.sh. Stop is new. The JSON is valid. signal_test.go checks only SessionStart, so it is not broken.
  • plugin.json: new beep option is a string, default on. It matches beep.sh. The docs table has 7 rows, which matches "seven options".
  • Security: no user text reaches a shell. The player and sound paths are fixed strings. The payload is not read, so nothing leaks.
  • Did not run tests. Go is not installed and live tests are not approved. I read the test code and traced it by hand: the fake-player tests use a PATH of the temp dir plus /usr/bin:/bin, which hides any real player.

…ep switch

Add the beep to docs/data-dependence.md (no data at any level), make the
beep option case-insensitive, silence the /dev/tty and tr stderr noise
when there is no terminal or no tr, and note that scripted claude -p runs
beep too.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: DAVID BOAZ <[email protected]>
@boazdavid

Copy link
Copy Markdown
Collaborator Author

Fixed in 2fdaeff.

Reviewer 2, finding 1 (data-dependence row): fixed. docs/data-dependence.md now has a "Beep" row in "Features outside the pipeline". Kind is none. It works the same at all 3 levels. The script never reads the hook payload and sends nothing.

Data dependence of this PR: no change. The beep reads no stored data.

Non-blocking items:

  • Case of the beep value: fixed. Off and OFF now silence the beep.
  • Noise on stderr with no tty: fixed. The /dev/tty write is now silenced. The tr call is silenced too, for a machine with no tr.
  • Scripted claude -p runs also beep: added one sentence to docs/how-to/install-plugin.md.
  • Default on: kept. The docs and the option description state it.
  • Tests for the paplay, aplay and bell branches: not added in this PR. They need a sound-file path override in the script.
  • Client signals default in the docs table (off against auto): was wrong before this PR. Not changed here.

@boazdavid boazdavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @boazdavid) Claude Code 2.1.241, claude-sonnet-5-5 offload-review skill, @boazdavid's session resumed 1 of 2 2 of 2 2fdaeff05993 approve

Verdict: approve

Findings

None.

Non-blocking

  • No test covers the paplay, aplay and bell branches. The author declined this and gave a reason (a sound-file path override is needed). I accept it.
  • The "Client signals" row in docs/how-to/install-plugin.md says default off, but plugin.json says auto. This was wrong before the PR. The author left it. Open a separate issue.

What I checked

  • Last review: round 1, 3069560, 2026-11-01T09:02:08Z
  • New commits read: 1 (2fdaeff docs(plugin): Add the beep data-dependence row; ignore case in the beep switch)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2 round-1 review (blocking: missing data-dependence row). Fixed: docs/data-dependence.md:228 now has a Beep row, kind none, same at all 3 levels. I checked the claim: beep.sh never reads the payload and sends nothing.
    • Author comment with replies to both reviews. I checked each reply against the diff.
  • My round-1 non-blocking items:
    • /dev/tty stderr noise: fixed. { printf '\a' >/dev/tty; } 2>/dev/null hides the redirect error.
    • Data-dependence row: fixed.
    • Mode values differ from signal.sh: left as is. Fine.
    • Default on and double sound: kept by the author. Documented.
    • Test gaps: declined with a reason (see Non-blocking).
  • Reviewer 2 items: case-insensitive value fixed with tr '[:upper:]' '[:lower:]'. If tr is missing, the output is empty and the script beeps, which is the default, so fail-open holds and exit stays 0. The claude -p sentence is added to the docs.
  • Read the whole diff 3069560d..HEAD (3 files). Only beep.sh has code changes. Every path still exits 0.
  • The new docs row sits in the "Features outside the pipeline" table, which has no "Decided by" column, so none is required there.
  • I did not run Go tests (not approved).

@boazdavid boazdavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @boazdavid) Claude Code 2.1.241, claude-sonnet-5-5 offload-review skill, @boazdavid's session resumed 2 of 2 2 of 2 2fdaeff05993 approve

Verdict: approve

Findings

None.

Non-blocking

  • scripts/beep.sh:17 — If tr is missing, the case input is empty. It matches no off arm. The beep then plays even when the user set off. The machine would need no tr, which is very rare. The result is a sound, not a failure, and fail-open holds. No action needed.
  • The paplay, aplay and bell branches still have no test. The author said this needs a sound-file override in the script. Agreed. Do it in a later PR.
  • The Client signals default in docs/how-to/install-plugin.md (off against auto in plugin.json) is still wrong. It was wrong before this PR. Open a separate issue.

What I checked

  • Last review: round 1, 3069560, 2026-11-01T09:02:53Z
  • New commits read: 1 (2fdaeff docs(plugin): Add the beep data-dependence row; ignore case in the beep switch)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Commit 2fdaeff: read the whole diff (beep.sh, docs/data-dependence.md, install-plugin.md). Details below.
    • Author comment at 09:09:41Z: replies to every item of both reviews. I checked each reply against the code. All match the commit.
  • Earlier findings:
    • My finding 1 (no data-dependence row): fixed. The new row is in docs/data-dependence.md. Kind is none. It says "Works, no data" at all three levels and gives the reason in plain words. The row has the same 6 columns as the rows around it. components/all/datadep_test.go covers components only, so the new row does not break it. The author states "no change" in data dependence in the comment. The page has no "Decided by" column on this table, so there is nothing to add.
    • My non-blocking items: case of the value fixed (tr '[:upper:]' '[:lower:]', so Off and OFF now match). The sentence on scripted claude -p runs is added. Missing tests for the player branches and the Client signals docs mismatch were declined with a reason. I accept both reasons.
    • Reviewer 1: no findings. Its stderr-noise point is fixed ({ printf '\a' >/dev/tty; } 2>/dev/null silences the redirect error, which 2>/dev/null on the command did not). I agree with it and added no new proof.
  • beep.sh after the change: set -uo pipefail has no -e, so a failing tr cannot stop the script. printf %s keeps - or % in the value safe. Every exit is still 0. Fail-open holds.
  • Tests: the existing tests set CONTEXT_GURU_BEEP=off and CLAUDE_PLUGIN_OPTION_BEEP=off in lowercase, and PATH includes /usr/bin:/bin, so tr is found. They still pass by reading. There is no test for OFF. Small gap, listed as non-blocking-level only.
  • Did not run tests. Go is not installed and live tests are not approved.

The table said off and that the proxy needs CONTEXT_GURU_CLIENT_SIGNALS=on.
plugin.json and signal.sh default to auto, and the proxy runs this whenever
its keep-alive runs. Link the section that says so.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID BOAZ <[email protected]>
@OsherElhadad
OsherElhadad merged commit 4d54018 into main Nov 1, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 1, 2026
@OsherElhadad
OsherElhadad deleted the feat/plugin-beep branch November 1, 2026 10:28
amiddavid added a commit that referenced this pull request Nov 2, 2026
…0.2.9) (#863)

Claude Code plugin 0.6.4 -> 0.6.5:
- #850: 12 display-only skills get disable-model-invocation: true.
- #738: an optional beep when Claude finishes or needs input.
- #848: settings.py still writes head_ttl_min_tokens, so an older proxy loads its config.
- #859: the band and cg.py show "finished" for an agent that ended with a terminal tool call.

Codex plugin 0.2.8 -> 0.2.9:
- #850: 9 display-only skills get allow_implicit_invocation: false.
- #852: the session skill's front matter is valid YAML, so Codex loads it.

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat(plugin): Add an optional beep when Claude finishes or needs input

2 participants