Skip to content
Open
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
10 changes: 6 additions & 4 deletions Releases/v5.0.0/.claude/hooks/RepeatDetection.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,17 @@ function main(): void {

// Threshold: 0.6 (60%) similarity triggers warning
if (similarity >= 0.6) {
// Output warning to stderr — this gets injected into model context
process.stderr.write(
// UserPromptSubmit hook contract: stdout + exit 0 injects the text as
// additionalContext into the model's context (the desired behavior).
// stderr + exit 2 blocks the prompt and surfaces the warning to the
// user instead of injecting it for the model — wrong direction.
process.stdout.write(
`⚠️ REPEAT DETECTION: This message is ${Math.round(similarity * 100)}% similar to the previous message. ` +
`The user is likely REPEATING a request you missed. ` +
`STOP. Re-read their message carefully. Do NOT proceed with what you were doing before. ` +
`Address their ACTUAL request this time.`,
);
// Exit 2 = blocking error, stderr fed to Claude
process.exit(2);
process.exit(0);
}

process.exit(0);
Expand Down