npx claudepluginhub joshuarweaver/cascade-code-general-misc-1 --plugin tubone24-claude-code-settingsDefined in hooks/hooks.json
*#!/bin/bash
input=$(cat)
# Save context snapshot
SNAPSHOT_DIR="$HOME/.claude/snapshots"
mkdir -p "$SNAPSHOT_DIR"
SNAPSHOT_FILE="$SNAPSHOT_DIR/context-$(date '+%Y%m%d-%H%M%S').md"
cat > "$SNAPSHOT_FILE" << 'SNAPSHOT_EOF'
# Context Snapshot
**Date:** $(date '+%Y-%m-%d %H:%M:%S')
**Directory:** $(pwd)
## Recent Git Changes
$(git diff --stat HEAD 2>/dev/null | tail -20 || echo 'No git repo')
## Modified Files (uncommitted)
$(git status --short 2>/dev/null | head -20 || echo 'N/A')
## Recent Commands (from history)
See ~/.claude/logs/agent-$(date '+%Y%m%d').log
SNAPSHOT_EOF
echo "[Hook] Context snapshot saved: $SNAPSHOT_FILE" >&2
echo "$input"10ms*#!/bin/bash
input=$(cat)
if git rev-parse --git-dir > /dev/null 2>&1; then
files=$(git diff --name-only HEAD 2>/dev/null | grep -E '\.(ts|tsx|js|jsx)$' || true)
[ -n "$files" ] && while IFS= read -r f; do
[ -f "$f" ] && grep -q "console\.log" "$f" 2>/dev/null && echo "[Hook] WARNING: console.log in $f" >&2
done <<< "$files"
fi
echo "$input"Edit|Write#!/bin/bash
input=$(cat)
p=$(echo "$input" | jq -r '.tool_input.file_path // ""')
BLOCKED=(".env" ".env.local" ".env.production" "credentials" "secrets" ".ssh" "id_rsa" "id_ed25519" ".pem" ".key" "serviceAccount" ".npmrc" ".pypirc")
for b in "${BLOCKED[@]}"; do
if [[ "$p" == *"$b"* ]]; then
echo "[Hook] BLOCKED: Cannot edit sensitive file: $p" >&2
exit 2
fi
done
echo "$input"Bash#!/bin/bash
input=$(cat)
cmd=$(echo "$input" | jq -r '.tool_input.command // ""')
if echo "$cmd" | grep -qE 'git push.*(--force|-f)'; then
echo '[Hook] BLOCKED: Force push is dangerous. Use --force-with-lease if necessary.' >&2
exit 2
fi
if echo "$cmd" | grep -qE 'rm -rf /|:(){ :|:& };:|> /dev/sd|mkfs\.|dd if='; then
echo '[Hook] BLOCKED: Potentially destructive command detected' >&2
exit 2
fi
echo "$input"tool == "Bash" && tool_input.command matches "git push"#!/bin/bash
input=$(cat)
echo '[Hook] git push detected - ensure changes are reviewed' >&2
osascript -e 'display notification "git pushを実行します" with title "Claude Code" sound name "Ping"' 2>/dev/null || true
echo "$input"tool == "Write" && tool_input.file_path matches "\\.(md|txt)$" && !(tool_input.file_path matches "README\\.md|CLAUDE\\.md|AGENTS\\.md|CONTRIBUTING\\.md|context-snapshot\\.md")#!/bin/bash
input=$(cat)
file_path=$(echo "$input" | jq -r '.tool_input.file_path // ""')
if [[ "$file_path" =~ \.(md|txt)$ ]] && [[ ! "$file_path" =~ (README|CLAUDE|AGENTS|CONTRIBUTING|context-snapshot)\.md$ ]]; then
echo "[Hook] BLOCKED: Unnecessary documentation file creation" >&2
echo "[Hook] File: $file_path" >&2
exit 1
fi
echo "$input"*#!/bin/bash
echo "[$(date '+%H:%M:%S')] SESSION END" >> ~/.claude/logs/agent-$(date '+%Y%m%d').log
osascript -e 'display notification "セッションが終了しました" with title "Claude Code" subtitle "処理完了" sound name "Hero"' 2>/dev/null || true
python3 ~/.claude/plugins/claude-code-settings/hooks/scripts/obsidian-export.py 2>/dev/null || true30mstool == "Bash"#!/bin/bash
input=$(cat)
cmd=$(echo "$input" | jq -r '.tool_input.command')
if echo "$cmd" | grep -qE 'gh pr create'; then
output=$(echo "$input" | jq -r '.tool_output.output // ""')
pr_url=$(echo "$output" | grep -oE 'https://github.com/[^/]+/[^/]+/pull/[0-9]+')
if [ -n "$pr_url" ]; then
echo "[Hook] PR created: $pr_url" >&2
osascript -e "display notification \"PR作成完了: $pr_url\" with title \"Claude Code\" sound name \"Hero\"" 2>/dev/null || true
fi
fi
echo "$input"tool == "Edit" && tool_input.file_path matches "\\.py$"#!/bin/bash
input=$(cat)
file_path=$(echo "$input" | jq -r '.tool_input.file_path // ""')
if [ -n "$file_path" ] && [ -f "$file_path" ]; then
if command -v black >/dev/null 2>&1; then
black --check "$file_path" 2>&1 | head -3 >&2 || echo "[Hook] black: format issues detected" >&2
fi
if command -v mypy >/dev/null 2>&1; then
mypy "$file_path" --no-error-summary 2>&1 | head -5 >&2 || true
fi
fi
echo "$input"tool == "Edit" && tool_input.file_path matches "\\.ts$"#!/bin/bash
input=$(cat)
file_path=$(echo "$input" | jq -r '.tool_input.file_path // ""')
if [ -n "$file_path" ] && [ -f "$file_path" ]; then
if command -v npx >/dev/null 2>&1; then
npx tsc --noEmit "$file_path" 2>&1 | head -5 >&2 || true
fi
fi
echo "$input"tool == "Edit" && tool_input.file_path matches "\\.(ts|tsx|js|jsx)$"#!/bin/bash
input=$(cat)
file_path=$(echo "$input" | jq -r '.tool_input.file_path // ""')
if [ -n "$file_path" ] && [ -f "$file_path" ]; then
command -v prettier >/dev/null 2>&1 && prettier --write "$file_path" 2>&1 | head -3 >&2
fi
echo "$input"tool == "Edit" && tool_input.file_path matches "\\.(ts|tsx)$"#!/bin/bash
input=$(cat)
file_path=$(echo "$input" | jq -r '.tool_input.file_path // ""')
if [ -n "$file_path" ] && [ -f "$file_path" ]; then
console_logs=$(grep -n "console\\.log" "$file_path" 2>/dev/null || true)
[ -n "$console_logs" ] && echo "[Hook] WARNING: console.log found" >&2
fi
echo "$input"*osascript -e 'display notification "Claude Codeが許可を求めています" with title "Claude Code" subtitle "確認待ち" sound name "Glass"'*bash ~/.claude/hooks/scripts/slack-notify.sh10ms*#!/bin/bash
mkdir -p ~/.claude/logs ~/.claude/snapshots
echo "[$(date '+%Y-%m-%d %H:%M:%S')] SESSION START in $(pwd)" >> ~/.claude/logs/agent-$(date '+%Y%m%d').log{"riskFlags": {"touchesBash": true, "matchAllTools": false, "touchesFileWrites": true}, "typeStats": {"command": 15}, "eventStats": {"Stop": 2, "PreToolUse": 4, "SessionEnd": 1, "PostToolUse": 5, "Notification": 2, "SessionStart": 1}, "originCounts": {"absolutePaths": 0, "pluginScripts": 0, "projectScripts": 0}, "timeoutStats": {"commandsWithoutTimeout": 12}}