-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpost_commit_remind.sh
More file actions
executable file
·64 lines (58 loc) · 2.01 KB
/
Copy pathpost_commit_remind.sh
File metadata and controls
executable file
·64 lines (58 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
# scripts/post_commit_remind.sh
#
# PostToolUse hook for Bash. When `git commit` just ran, re-inject the
# autonomous-loop continuation reminder from CLAUDE.md § The only stop
# + § Autonomous Workflow "Loop: Step 0 → 7 → next task's Step 0".
#
# Why this exists: CLAUDE.md is loaded once per session; long sessions
# accumulate momentum drift where the loop's "only stop is user
# explicit stop" rule fades from active recall. Re-injecting the rule
# at every commit lands it at the exact moment the drift is most
# likely (just after Step 6, before the next task's Step 0).
#
# Inputs: stdin JSON from Claude Code (PostToolUse hook payload).
# stdout: reminder text fed back to Claude as tool result feedback.
set -u
INPUT=$(cat)
CMD=$(printf '%s' "$INPUT" | python3 -c '
import sys, json
try:
d = json.load(sys.stdin)
print(d.get("tool_input", {}).get("command", ""))
except Exception:
pass
' 2>/dev/null || true)
case "$CMD" in
*"git commit"*)
;;
*)
exit 0
;;
esac
REMINDER=$(cat <<'EOF'
[post-commit reminder]
A commit landed. Recall the project's fully-autonomous principle:
return to the head of the autonomous loop in CLAUDE.md
§ Autonomous Workflow and continue the next unit of work
immediately. Intermediate artefacts — per-task notes, status
summaries, planning text — are fine to produce on the way, but
must never become a reason to stop. Smell triggers are in-flight
interrupts; build / test failures are Active-task items; neither
halts the loop. Only the user's explicit stop directive halts
the loop (CLAUDE.md § The only stop).
EOF
)
# PostToolUse: stdout must be JSON with hookSpecificOutput.additionalContext
# for the text to be injected into Claude's next-turn context. Bare-text
# stdout is shown only in transcript mode (Ctrl-R), not to Claude.
export REMINDER
python3 -c '
import json, os
print(json.dumps({
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": os.environ.get("REMINDER", ""),
}
}))
'