groove-admin-claude-hooks
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<!-- groove:managed — do not edit; changes will be overwritten by groove update -->
<!-- groove:managed — 请勿编辑;修改内容会被groove更新覆盖 -->
groove-admin-claude-hooks
groove-admin-claude-hooks
Install groove's Claude Code native shell hooks. These run outside the model — deterministic, unconditional — and complement groove's advisory markdown hooks (, ).
.groove/hooks/start.mdend.mdUse to remove a specific hook. Use to show current status.
--disable <hook>--list安装groove的Claude Code原生shell钩子。这些钩子在模型之外运行——具备确定性、无条件执行的特性——是groove的建议式markdown钩子(、)的补充。
.groove/hooks/start.mdend.md使用参数移除指定钩子,使用参数展示当前状态。
--disable <hook>--listOutcome
实现效果
Selected hooks are registered in and shell scripts are written to . Hooks fire automatically on Claude Code lifecycle events without any model involvement.
.claude/settings.json.groove/hooks/claude/选中的钩子会被注册到中,对应的shell脚本会写入目录。钩子会在Claude Code的生命周期事件触发时自动执行,无需模型参与。
.claude/settings.json.groove/hooks/claude/Available hooks
可用钩子
| Name | Event | Matcher | What it does |
|---|---|---|---|
| | — | If hour is 16–21 local time and |
| | | If the Bash command contains |
| | | If |
| 名称 | 触发事件 | 匹配器 | 功能 |
|---|---|---|---|
| | — | 如果本地时间为16-21点且 |
| | | 如果Bash命令包含 |
| | | 如果 |
Steps
操作步骤
--list
--list--list
--listRead if it exists. Report which groove hooks are registered and which scripts exist in . Exit.
.claude/settings.json.groove/hooks/claude/若存在则读取该文件,上报已注册的groove钩子以及目录下存在的脚本,随后退出。
.claude/settings.json.groove/hooks/claude/--disable <hook>
--disable <hook>--disable <hook>
--disable <hook>Remove the named hook's entry from (leave the script in place). Report removed / not found. Exit.
.claude/settings.json从中移除指定名称的钩子条目(保留对应脚本文件),上报移除结果/未找到对应钩子,随后退出。
.claude/settings.jsonDefault (install)
默认操作(安装)
-
Ask which hooks to enable (default: all three):
Which hooks to install? (all / comma-separated: daily-end-reminder, git-activity-buffer, block-managed-paths) Press enter for all. -
Readif it exists; parse as JSON (default
.claude/settings.json). Never discard existing non-groove entries.{} -
Createdirectory if absent. Make each script executable (
.groove/hooks/claude/).chmod +x -
For each selected hook: write the shell script and merge the hook entry into.
.claude/settings.json -
Writewith the merged result.
.claude/settings.json -
Report summary:
✓ daily-end-reminder — Stop hook → .groove/hooks/claude/daily-end-reminder.sh ✓ git-activity-buffer — PostToolUse/Bash hook → .groove/hooks/claude/git-activity-buffer.sh ✓ block-managed-paths — PreToolUse/Write+Edit hook → .groove/hooks/claude/block-managed-paths.sh ✓ .claude/settings.json updated
-
询问用户需要启用哪些钩子(默认:全部三个):
Which hooks to install? (all / comma-separated: daily-end-reminder, git-activity-buffer, block-managed-paths) Press enter for all. -
若存在则读取该文件,解析为JSON格式(默认值为
.claude/settings.json)。绝对不要删除已存在的非groove相关条目。{} -
如果目录不存在则创建该目录,将每个脚本设置为可执行权限(
.groove/hooks/claude/)。chmod +x -
针对每个选中的钩子:写入对应的shell脚本,并将钩子条目合并到中。
.claude/settings.json -
将合并后的结果写入。
.claude/settings.json -
上报安装总结:
✓ daily-end-reminder — Stop hook → .groove/hooks/claude/daily-end-reminder.sh ✓ git-activity-buffer — PostToolUse/Bash hook → .groove/hooks/claude/git-activity-buffer.sh ✓ block-managed-paths — PreToolUse/Write+Edit hook → .groove/hooks/claude/block-managed-paths.sh ✓ .claude/settings.json updated
Shell script templates
Shell脚本模板
Write these verbatim to . Never overwrite an existing script without showing a diff and confirming.
.groove/hooks/claude/将以下脚本原封不动写入目录。在未展示差异并获得用户确认的情况下,绝对不要覆盖已存在的脚本。
.groove/hooks/claude/daily-end-reminder.sh
daily-end-reminder.shdaily-end-reminder.sh
daily-end-reminder.shbash
#!/usr/bin/env bashbash
#!/usr/bin/env bashgroove: Stop hook — remind about /groove-daily-end during work hours
groove: Stop hook — remind about /groove-daily-end during work hours
hour=$(date +%H)
if [ -f ".groove/index.md" ] && [ "$hour" -ge 16 ] && [ "$hour" -le 21 ]; then
echo "groove: end of work hours — consider running /groove-daily-end"
fi
undefinedhour=$(date +%H)
if [ -f ".groove/index.md" ] && [ "$hour" -ge 16 ] && [ "$hour" -le 21 ]; then
echo "groove: end of work hours — consider running /groove-daily-end"
fi
undefinedgit-activity-buffer.sh
git-activity-buffer.shgit-activity-buffer.sh
git-activity-buffer.shbash
#!/usr/bin/env bashbash
#!/usr/bin/env bashgroove: PostToolUse/Bash hook — buffer git commits for memory log
groove: PostToolUse/Bash hook — buffer git commits for memory log
input=$(cat)
command=$(echo "$input" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('tool_input',{}).get('command',''))" 2>/dev/null)
if echo "$command" | grep -q "git commit"; then
msg=$(echo "$command" | grep -oP '(?<=-m ")[^"]+' | head -1)
mkdir -p .groove/.cache
echo "$(date '+%Y-%m-%d %H:%M') | ${msg:-<no message>}" >> .groove/.cache/git-activity-buffer.txt
fi
undefinedinput=$(cat)
command=$(echo "$input" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('tool_input',{}).get('command',''))" 2>/dev/null)
if echo "$command" | grep -q "git commit"; then
msg=$(echo "$command" | grep -oP '(?<=-m ")[^"]+' | head -1)
mkdir -p .groove/.cache
echo "$(date '+%Y-%m-%d %H:%M') | ${msg:-<no message>}" >> .groove/.cache/git-activity-buffer.txt
fi
undefinedblock-managed-paths.sh
block-managed-paths.shblock-managed-paths.sh
block-managed-paths.shbash
#!/usr/bin/env bashbash
#!/usr/bin/env bashgroove: PreToolUse/Write+Edit hook — block edits to managed groove paths
groove: PreToolUse/Write+Edit hook — block edits to managed groove paths
input=$(cat)
path=$(echo "$input" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('tool_input',{}).get('file_path',''))" 2>/dev/null)
if echo "$path" | grep -qE '^(.agents/skills/groove|skills/groove)'; then
echo "groove: blocked — '$path' is managed by groove update. Edit under skills/ and rsync to .agents/skills/." >&2
exit 1
fi
undefinedinput=$(cat)
path=$(echo "$input" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('tool_input',{}).get('file_path',''))" 2>/dev/null)
if echo "$path" | grep -qE '^(.agents/skills/groove|skills/groove)'; then
echo "groove: blocked — '$path' is managed by groove update. Edit under skills/ and rsync to .agents/skills/." >&2
exit 1
fi
undefined.claude/settings.json
entries
.claude/settings.json.claude/settings.json
条目
.claude/settings.jsonMerge these into the key. Preserve all other keys.
hooksjson
{
"hooks": {
"Stop": [
{
"hooks": [
{ "type": "command", "command": "bash .groove/hooks/claude/daily-end-reminder.sh" }
]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "command": "bash .groove/hooks/claude/git-activity-buffer.sh" }
]
}
],
"PreToolUse": [
{
"matcher": "Write",
"hooks": [
{ "type": "command", "command": "bash .groove/hooks/claude/block-managed-paths.sh" }
]
},
{
"matcher": "Edit",
"hooks": [
{ "type": "command", "command": "bash .groove/hooks/claude/block-managed-paths.sh" }
]
}
]
}
}When merging: if a key already exists, append groove entries to the relevant event arrays. Do not create duplicates — check if a groove command entry already exists before appending.
hooks将以下内容合并到键下,保留所有其他键的内容。
hooksjson
{
"hooks": {
"Stop": [
{
"hooks": [
{ "type": "command", "command": "bash .groove/hooks/claude/daily-end-reminder.sh" }
]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "command": "bash .groove/hooks/claude/git-activity-buffer.sh" }
]
}
],
"PreToolUse": [
{
"matcher": "Write",
"hooks": [
{ "type": "command", "command": "bash .groove/hooks/claude/block-managed-paths.sh" }
]
},
{
"matcher": "Edit",
"hooks": [
{ "type": "command", "command": "bash .groove/hooks/claude/block-managed-paths.sh" }
]
}
]
}
}合并规则:如果键已存在,将groove相关条目追加到对应事件的数组中。不要创建重复条目——追加前先检查groove命令条目是否已经存在。
hooksConstraints
约束条件
- Never overwrite non-groove entries in
.claude/settings.json - Never overwrite an existing script without diff + confirmation
- Scripts use to parse JSON stdin — if python3 is absent, skip that hook and warn
python3 - is aggressive: if it causes false positives the user can disable it with
block-managed-paths--disable block-managed-paths - After install: remind the user that hooks take effect on the next Claude Code session restart
- follows the
.groove/hooks/claude/git strategy fromgit.hooks.groove/index.md
- 绝对不要覆盖中的非groove相关条目
.claude/settings.json - 未展示差异并获得用户确认的情况下,绝对不要覆盖已存在的脚本
- 脚本使用解析标准输入的JSON——如果没有安装python3,跳过该钩子并发出警告
python3 - 的拦截逻辑较为严格:如果出现误拦截,用户可以通过
block-managed-paths参数禁用该钩子--disable block-managed-paths - 安装完成后:提醒用户钩子需要重启下一次Claude Code会话才会生效
- 目录遵循
.groove/hooks/claude/中定义的.groove/index.mdgit策略git.hooks