fix(hooks): restore hooks.json in plugin dir, remove from settings.local

hooks.json in ~/.claude/skills/hub-guide/hooks/hooks.json IS auto-detected
by Claude Code for skills-dir plugins. Remove from settings.local.json
to avoid duplication.

- hooks.json restored with hooks wrapper + proper matchers
- install.sh simplified, no settings.json manipulation
This commit is contained in:
asepharyana
2026-07-26 12:09:48 +07:00
parent 6612cd9163
commit f149899ad5
2 changed files with 31 additions and 65 deletions
+23
View File
@@ -0,0 +1,23 @@
{
"hooks": {
"SessionStart": [{
"matcher": "startup|resume|compact",
"hooks": [{
"type": "command",
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/detect-project.sh\"",
"shell": "bash",
"timeout": 10,
"async": false
}]
}],
"PreToolUse": [{
"matcher": "Write|Edit",
"hooks": [{
"type": "command",
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/detect-file-type.sh\"",
"shell": "bash",
"timeout": 10
}]
}]
}
}
+8 -65
View File
@@ -1,23 +1,21 @@
#!/bin/bash
# install.sh — hub-guide installer for Claude Code
# Installs skills to ~/.claude/skills/ + configures hooks in settings.local.json
# Installs the entire hub-guide directory as one unit into ~/.claude/skills/.
# Skills auto-discover, hooks auto-load from hooks/hooks.json.
# Usage:
# ./install.sh # Copy + hooks
# ./install.sh --link # Symlink (edits live) + hooks
# ./install.sh --no-hooks # Skills only, no hook setup
# Requires: Claude Code, python3
# ./install.sh # Copy hub-guide to ~/.claude/skills/
# ./install.sh --link # Symlink (edits live)
# Requires: Claude Code
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILLS_DIR="${HOME}/.claude/skills"
LINK_MODE=false
NO_HOOKS=false
for arg in "$@"; do
case "$arg" in
--link) LINK_MODE=true ;;
--no-hooks) NO_HOOKS=true ;;
--*) echo "Unknown: $arg"; exit 1 ;;
esac
done
@@ -26,7 +24,6 @@ echo "hub-guide installer"
echo " target: ${SKILLS_DIR}/hub-guide/"
echo " mode: $([ "$LINK_MODE" = true ] && echo 'symlink' || echo 'copy')"
# --- install skills ---
mkdir -p "$SKILLS_DIR"
DST="${SKILLS_DIR}/hub-guide"
@@ -38,64 +35,10 @@ else
cp -r "$SCRIPT_DIR" "$DST"
fi
echo " skills installed to ${DST}/"
echo " installed to ${DST}/"
if [ "$LINK_MODE" = true ]; then
echo " (symlink)"
echo " (symlink — edits in this repo are live)"
fi
# --- configure hooks in settings.local.json ---
if [ "$NO_HOOKS" = false ]; then
HOOKS_DIR="${DST}/hooks"
SETTINGS_FILE="${HOME}/.claude/settings.local.json"
python3 << PYEOF
import json, os
dst = "${DST}"
settings_file = os.path.expanduser("${SETTINGS_FILE}")
# Read existing settings or create empty
settings = {}
if os.path.exists(settings_file):
with open(settings_file) as f:
settings = json.load(f)
# Ensure hooks key exists
if "hooks" not in settings:
settings["hooks"] = {}
hooks_config = {
"SessionStart": [{
"matcher": "startup|resume|compact",
"hooks": [{
"type": "command",
"command": "bash \"" + dst + "/hooks/scripts/detect-project.sh\"",
"timeout": 10,
"async": False
}]
}],
"PreToolUse": [{
"matcher": "Write|Edit",
"hooks": [{
"type": "command",
"command": "bash \"" + dst + "/hooks/scripts/detect-file-type.sh\"",
"timeout": 10
}]
}]
}
# Merge hooks into settings (update existing, don't overwrite unrelated hooks)
for event, handlers in hooks_config.items():
settings["hooks"][event] = handlers
os.makedirs(os.path.dirname(settings_file), exist_ok=True)
with open(settings_file, 'w') as f:
json.dump(settings, f, indent=2)
print(" hooks configured in " + settings_file)
PYEOF
fi
echo ""
echo "Done. Restart Claude Code or run /reload."
echo "Skills auto-trigger when you work."
echo "Skills auto-trigger. Hooks auto-load from hooks/hooks.json."