Loading...
Loading...
Detect whether Claude Code evolution hooks are installed/enabled, and print a copy-paste fix. Use when you expect runs/evolution artifacts but nothing is being written. Triggers: hooks, evolution, runs/evolution, settings.json, PreToolUse, PostToolUse.
npx skill4agent add heyvhuang/ship-faster tool-hooks-doctorskill-evolution~/.claude/skills/skill-evolution/hooks/<repo_root>/.claude/settings.json~/.claude/settings.json<project_root>/runs/evolution/<run_id>/...ls -la ~/.claude/skills/skill-evolution/hooks/ 2>/dev/null || truepre-tool.shpost-bash.shpost-tool.shsession-end.shskill-evolutiontest -f .claude/settings.json && echo "project settings: .claude/settings.json" || true
test -f ~/.claude/settings.json && echo "global settings: ~/.claude/settings.json" || true
grep -n "skill-evolution/hooks/pre-tool.sh" .claude/settings.json ~/.claude/settings.json 2>/dev/null || true
grep -n "skill-evolution/hooks/post-bash.sh" .claude/settings.json ~/.claude/settings.json 2>/dev/null || true
grep -n "skill-evolution/hooks/post-tool.sh" .claude/settings.json ~/.claude/settings.json 2>/dev/null || true
grep -n "skill-evolution/hooks/session-end.sh" .claude/settings.json ~/.claude/settings.json 2>/dev/null || truels -la runs/evolution 2>/dev/null || true<repo_root>/.claude/settings.json~/.claude/settings.jsonpython3 - <<'PY'
import json
from pathlib import Path
settings = Path('.claude') / 'settings.json'
settings.parent.mkdir(parents=True, exist_ok=True)
data = {}
if settings.exists():
data = json.loads(settings.read_text() or '{}')
if not isinstance(data, dict):
data = {}
hooks = data.get('hooks')
if not isinstance(hooks, dict):
hooks = {}
desired = {
'PreToolUse': [{
'matcher': 'Bash|Write|Edit',
'hooks': [{'type':'command','command':'bash ~/.claude/skills/skill-evolution/hooks/pre-tool.sh'}]
}],
'PostToolUse': [
{
'matcher': 'Bash',
'hooks': [{'type':'command','command':'bash ~/.claude/skills/skill-evolution/hooks/post-bash.sh "$TOOL_OUTPUT" "$EXIT_CODE"'}]
},
{
'matcher': 'Write|Edit',
'hooks': [{'type':'command','command':'bash ~/.claude/skills/skill-evolution/hooks/post-tool.sh "$TOOL_OUTPUT" "$EXIT_CODE"'}]
}
],
'Stop': [{
'matcher': '',
'hooks': [{'type':'command','command':'bash ~/.claude/skills/skill-evolution/hooks/session-end.sh'}]
}]
}
def has_command(arr, matcher, command):
for item in arr:
if not isinstance(item, dict):
continue
if item.get('matcher') != matcher:
continue
hs = item.get('hooks')
if not isinstance(hs, list):
continue
for h in hs:
if isinstance(h, dict) and h.get('command') == command:
return True
return False
for event, items in desired.items():
arr = hooks.get(event)
if not isinstance(arr, list):
arr = []
for it in items:
cmd = it['hooks'][0]['command']
if not has_command(arr, it['matcher'], cmd):
arr.append(it)
hooks[event] = arr
data['hooks'] = hooks
if settings.exists():
backup = settings.with_suffix(settings.suffix + '.bak')
backup.write_text(settings.read_text())
settings.write_text(json.dumps(data, indent=2, ensure_ascii=True) + '\n')
print('Installed hooks into:', settings)
PY~/.claude/settings.json