feat(stop): surface end-of-turn reminders via additionalContext stdout#55
Open
JarrodAI wants to merge 1 commit into
Open
feat(stop): surface end-of-turn reminders via additionalContext stdout#55JarrodAI wants to merge 1 commit into
JarrodAI wants to merge 1 commit into
Conversation
The Stop hook's checkForMissingBugLogs and checkCerebrumFreshness
previously wrote reminders to process.stderr. In Claude Code, stderr
output from Stop hooks goes to the terminal only — it does NOT appear
in Claude's next context window.
Claude Code's hook system provides a dedicated mechanism for injecting
content into the AI's context: the `additionalContext` field in JSON
stdout. This commit switches to that approach:
- checkForMissingBugLogs: return string | null instead of void
- checkCerebrumFreshness: return string | null instead of void
- New checkSemanticSummaries: warns if files were modified but no
semantic summary was written to memory.md today
- Collect all reminder strings, filter nulls, then emit a single
process.stdout.write(JSON.stringify({ hookSpecificOutput:
{ hookEventName: "Stop", additionalContext } })) call
Also adds countSemanticEntries() to shared.ts to support the new check.
This change makes reminders actionable — Claude sees them at the top
of the next turn and can immediately log bugs or update cerebrum.md
rather than the reminder silently disappearing in terminal output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
Stophook'scheckForMissingBugLogsandcheckCerebrumFreshnessfunctions currently write reminders toprocess.stderr. In Claude Code, stderr output fromStophooks goes to the terminal only — it does not appear in Claude's next context window. This means the reminders are invisible to Claude and have no effect on its behaviour.Solution
Claude Code provides a dedicated mechanism for
Stophooks to inject content into the AI's context: theadditionalContextfield in JSON stdout:This PR switches the reminder functions from
void(write to stderr) tostring | null(return the message), collects all non-null reminders, and emits them as a singleadditionalContextpayload. Claude sees them at the top of its next turn and can act on them immediately.Changes
src/hooks/stop.tscheckForMissingBugLogs:void→string | nullcheckCerebrumFreshness:void→string | nullcheckSemanticSummaries: warns if files were modified but no semantic summary entry was written tomemory.mdtoday (requirescountSemanticEntriesbelow)additionalContextJSON stdoutsrc/hooks/shared.tscountSemanticEntries(wolfDir): readsmemory.mdand counts non-mechanical rows dated today — used bycheckSemanticSummariesto detect whether Claude wrote a meaningful session summaryWhy this matters
Before this change, reminders fired silently into the void. After this change, Claude receives something like:
…at the top of its very next turn, making it actually comply with the OpenWolf protocol.
Tested in production use on a large Next.js monorepo with Claude Code (Sonnet 4.6). Build passes cleanly:
npm run build✓🤖 Contributed by JarrodAI via Claude Code