[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75DC3Y4436EBMEMHHGR1CQJ":3,"skill-same:01M75DC3Y4436EBMEMHHGR1CQJ":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":6,"updatedAt":33,"install":34,"resources":47},"01M75DC3Y4436EBMEMHHGR1CQJ","enhance-hooks",null,"Use when reviewing hooks for safety, timeouts, and correct frontmatter.","agisota\u002Fold-one","agisota","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F121413592?v=4","01M75B4BRNT67EC1NDRT8QZEP2","01M75B4BS7QR9VP580MSCPTS3X",3,"MIT","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fenhance-hooks\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: enhance-hooks\ndescription: \"Use when reviewing hooks for safety, timeouts, and correct frontmatter.\"\nversion: 5.1.0\nargument-hint: \"[path] [--fix]\"\n---\n\n# enhance-hooks\n\nAnalyze hook definitions and scripts for safety, correctness, and best practices.\n\n## Parse Arguments\n\n```javascript\nconst args = '$ARGUMENTS'.split(' ').filter(Boolean);\nconst targetPath = args.find(a => !a.startsWith('--')) || '.';\nconst fix = args.includes('--fix');\n```\n\n## Workflow\n\n1. **Discover** - Find hook files (.md, .sh, .json)\n2. **Classify** - Identify hook type and event\n3. **Parse** - Extract frontmatter and script content\n4. **Check** - Run all pattern checks against knowledge below\n5. **Filter** - Apply certainty filtering\n6. **Report** - Generate markdown output\n7. **Fix** - Apply auto-fixes if --fix flag present\n\n---\n\n## Hook Knowledge Reference\n\n### What Are Hooks\n\nHooks are automated actions triggered at specific points in a Claude Code session. They enable validation, monitoring, and control of Claude's actions through bash commands or LLM-based evaluation.\n\n### Hook Lifecycle (Complete Reference)\n\nHooks fire in this sequence:\n\n| Order | Event | Description | Matcher Required |\n|-------|-------|-------------|------------------|\n| 1 | `SessionStart` | Session begins or resumes | No |\n| 2 | `UserPromptSubmit` | User submits a prompt | No |\n| 3 | `PreToolUse` | Before tool execution (can modify\u002Fblock) | Yes |\n| 4 | `PermissionRequest` | When permission dialog appears | Yes |\n| 5 | `PostToolUse` | After tool succeeds | Yes |\n| 6 | `SubagentStart` | When spawning a subagent | No |\n| 7 | `SubagentStop` | When subagent finishes | No |\n| 8 | `Stop` | Claude finishes responding | No |\n| 9 | `PreCompact` | Before context compaction | No |\n| 10 | `SessionEnd` | Session terminates | No |\n| 11 | `Notification` | Claude Code sends notifications | No |\n\n### Hook Types\n\n**Command Hooks** (`type: \"command\"`):\n- Execute bash commands with full stdin\u002Fstdout control\n- Available for all events\n\n**Prompt Hooks** (`type: \"prompt\"`):\n- Use LLM evaluation for intelligent, context-aware decisions\n- **Only supported for `Stop` and `SubagentStop` events**\n\n### Configuration Locations\n\n| File | Location | Scope | Committed |\n|------|----------|-------|-----------|\n| User settings | `~\u002F.claude\u002Fsettings.json` | All projects | No |\n| Project settings | `.claude\u002Fsettings.json` | Current project | Yes |\n| Local settings | `.claude\u002Fsettings.local.json` | Current project | No |\n\n### Configuration Structure\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \".claude\u002Fhooks\u002Fvalidate-bash.sh\",\n            \"timeout\": 30\n          }\n        ]\n      }\n    ],\n    \"PostToolUse\": [\n      {\n        \"matcher\": \"Write|Edit\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Fformat-code.sh\"\n          }\n        ]\n      }\n    ],\n    \"Stop\": [\n      {\n        \"hooks\": [\n          {\n            \"type\": \"prompt\",\n            \"prompt\": \"Check if all requested tasks are complete.\",\n            \"timeout\": 30\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n### Matcher Syntax\n\n| Pattern | Description |\n|---------|-------------|\n| `Write` | Match exact tool name |\n| `Edit\\|Write` | Match multiple tools (regex OR) |\n| `Notebook.*` | Regex pattern matching |\n| `*` or `\"\"` | Match all tools |\n| (omitted) | Required for Stop, SubagentStop, UserPromptSubmit |\n\n### Input Schema (JSON via stdin)\n\nAll hooks receive this JSON structure:\n\n```json\n{\n  \"session_id\": \"abc123\",\n  \"transcript_path\": \"\u002Fpath\u002Fto\u002Ftranscript\",\n  \"cwd\": \"\u002Fproject\u002Froot\",\n  \"permission_mode\": \"default\",\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_name\": \"Bash\",\n  \"tool_input\": {\n    \"command\": \"npm test\",\n    \"description\": \"Run test suite\"\n  }\n}\n```\n\n### Exit Codes\n\n| Exit Code | Behavior |\n|-----------|----------|\n| 0 | Success - stdout shown to user or added as context |\n| 2 | Blocking error - stderr shown, action blocked |\n| Other | Non-blocking error - stderr shown in verbose mode |\n\n### Output Schemas\n\n**PreToolUse Decision Control:**\n```json\n{\n  \"hookSpecificOutput\": {\n    \"hookEventName\": \"PreToolUse\",\n    \"permissionDecision\": \"allow|deny|ask\",\n    \"permissionDecisionReason\": \"Reason for decision\",\n    \"updatedInput\": {\n      \"command\": \"modified command\"\n    },\n    \"additionalContext\": \"Context for Claude\"\n  }\n}\n```\n\n**Stop\u002FSubagentStop Control:**\n```json\n{\n  \"decision\": \"block\",\n  \"reason\": \"Tasks incomplete: missing test coverage\"\n}\n```\n\n### Environment Variables\n\n| Variable | Description | Available In |\n|----------|-------------|--------------|\n| `CLAUDE_PROJECT_DIR` | Absolute path to project root | All hooks |\n| `CLAUDE_CODE_REMOTE` | \"true\" if remote session | All hooks |\n| `CLAUDE_ENV_FILE` | Path to persist env vars | SessionStart only |\n| `CLAUDE_FILE_PATHS` | Space-separated file paths | PostToolUse (Write\u002FEdit) |\n\n### Practical Hook Examples\n\n**Security Firewall (PreToolUse):**\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\n\ncmd=$(jq -r '.tool_input.command \u002F\u002F \"\"')\n\n# Block dangerous patterns\nif echo \"$cmd\" | grep -qE 'rm -rf|git reset --hard|curl.*\\|.*sh'; then\n  echo '{\"decision\": \"block\", \"reason\": \"Dangerous command blocked\"}' >&2\n  exit 2\nfi\n\nexit 0\n```\n\n**Auto-Formatter (PostToolUse):**\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\n\nfiles=$(jq -r '.tool_input.file_path \u002F\u002F \"\"')\n\nfor file in $files; do\n  case \"$file\" in\n    *.py) black \"$file\" 2>\u002Fdev\u002Fnull || true ;;\n    *.js|*.ts) prettier --write \"$file\" 2>\u002Fdev\u002Fnull || true ;;\n  esac\ndone\n\nexit 0\n```\n\n**Command Logger (PreToolUse):**\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\ncmd=$(jq -r '.tool_input.command \u002F\u002F \"\"')\nprintf '%s %s\\n' \"$(date -Is)\" \"$cmd\" >> .claude\u002Fbash-commands.log\nexit 0\n```\n\n**Workflow Orchestration (SubagentStop - prompt type):**\n```json\n{\n  \"hooks\": {\n    \"SubagentStop\": [\n      {\n        \"hooks\": [\n          {\n            \"type\": \"prompt\",\n            \"prompt\": \"Review the subagent's work. Did it complete all tasks?\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n---\n\n## Detection Patterns\n\n### 1. Frontmatter Validation (HIGH Certainty)\n\n**Required:**\n- YAML frontmatter with `---` delimiters\n- `name` field in frontmatter\n- `description` field in frontmatter\n\n**Recommended:**\n- `timeout` for command hooks (default: 30s)\n- Hook type specification\n\n**Flag:**\n- Missing frontmatter delimiters\n- Missing name or description\n\n### 2. Script Safety (HIGH Certainty)\n\n**Required Safety Patterns:**\n- `set -euo pipefail` at script start\n- Error handling for jq\u002FJSON parsing\n- Proper quoting of variables\n\n**Dangerous Patterns to Flag:**\n\n| Pattern | Risk | Certainty |\n|---------|------|-----------|\n| `rm -rf` | Destructive without confirmation | HIGH |\n| `git reset --hard` | Data loss risk | HIGH |\n| `curl \\| sh` | Remote code execution | HIGH |\n| `eval \"$input\"` | Arbitrary code execution | HIGH |\n| `rm -r` | Recursive delete (may be intentional) | MEDIUM |\n| `git push --force` | Force push (may be intentional) | MEDIUM |\n\n### 3. Exit Code Handling (HIGH Certainty)\n\n**Check:** Scripts use correct exit codes\n\n**Flag:**\n- Missing `exit 0` for success path\n- Using exit code 1 for blocking (should be 2)\n- No exit code at end of script\n\n### 4. Hook Type Appropriateness (HIGH Certainty)\n\n**Check:** Hook type matches event\n\n**Flag:**\n- Prompt hooks used for events other than Stop\u002FSubagentStop\n- Missing type specification\n\n### 5. Lifecycle Event Appropriateness (MEDIUM Certainty)\n\n| Event | Appropriate Use Cases |\n|-------|----------------------|\n| `PreToolUse` | Security validation, command blocking, input modification |\n| `PostToolUse` | Formatting, logging, notifications |\n| `Stop` | Completion checks, cleanup, summary |\n| `SubagentStop` | Workflow orchestration, result validation |\n| `SessionStart` | Environment setup, initialization |\n\n**Flag:**\n- PostToolUse hooks trying to block actions (too late)\n- PreToolUse hooks doing heavy processing (should be fast)\n- Prompt hooks on unsupported events\n\n### 6. Timeout Configuration (MEDIUM Certainty)\n\n**Guidelines:**\n- Default: 30 seconds for command hooks\n- Network operations: Always set explicit timeout\n- External service calls: Set timeout based on expected latency\n\n**Flag:**\n- No timeout for network operations\n- Timeout missing for external service calls\n- Unreasonably long timeouts (>60s without justification)\n\n### 7. Output Format (MEDIUM Certainty)\n\n**PreToolUse Output Fields:**\n- `permissionDecision`: allow, deny, or ask\n- `permissionDecisionReason`: Explanation for decision\n- `updatedInput`: Modified tool input (optional)\n- `additionalContext`: Context for Claude (optional)\n\n**Flag:**\n- Invalid permissionDecision values\n- Missing reason for deny decisions\n- Malformed JSON output\n\n### 8. Matcher Patterns (MEDIUM Certainty)\n\n**Check:** Matcher syntax is valid\n\n**Flag:**\n- Invalid regex patterns\n- Too broad matchers (`*` without justification)\n- Matcher on events that don't support it (Stop, SubagentStop)\n\n### 9. Anti-Patterns (LOW Certainty)\n\n- Complex logic in hooks (should be simple and fast)\n- Missing documentation\u002Fcomments\n- Hardcoded paths (should use `$CLAUDE_PROJECT_DIR`)\n- Network calls without error handling\n- Secrets\u002Fcredentials in hook scripts\n\n---\n\n## Auto-Fix Implementations\n\n### 1. Missing safety header\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\n```\n\n### 2. Missing exit code\nAdd `exit 0` at end of script\n\n### 3. Missing frontmatter fields\n```yaml\n---\nname: hook-name\ndescription: Hook description\ntimeout: 30\n---\n```\n\n### 4. Wrong blocking exit code\nReplace `exit 1` with `exit 2` for blocking errors\n\n---\n\n## Output Format\n\n```markdown\n## Hook Analysis: {hook-name}\n\n**File**: {path}\n**Type**: {command|prompt|config}\n**Event**: {PreToolUse|PostToolUse|Stop|...}\n\n### Summary\n- HIGH: {count} issues\n- MEDIUM: {count} issues\n\n### Frontmatter Issues ({n})\n| Issue | Fix | Certainty |\n\n### Safety Issues ({n})\n| Issue | Fix | Certainty |\n\n### Exit Code Issues ({n})\n| Issue | Fix | Certainty |\n\n### Lifecycle Issues ({n})\n| Issue | Fix | Certainty |\n\n### Output Format Issues ({n})\n| Issue | Fix | Certainty |\n```\n\n---\n\n## Pattern Statistics\n\n| Category | Patterns | Auto-Fixable |\n|----------|----------|--------------|\n| Frontmatter | 3 | 2 |\n| Safety | 6 | 2 |\n| Exit Code | 3 | 2 |\n| Hook Type | 2 | 0 |\n| Lifecycle | 5 | 0 |\n| Timeout | 3 | 0 |\n| Output | 3 | 0 |\n| Matcher | 3 | 0 |\n| Anti-Pattern | 5 | 0 |\n| **Total** | **33** | **6** |\n\n---\n\n\u003Cexamples>\n### Example: Missing Safety Header\n\n\u003Cbad_example>\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\ncmd=$(jq -r '.tool_input.command \u002F\u002F \"\"')\n```\n**Why it's bad**: Missing `set -euo pipefail` means errors may silently pass.\n\u003C\u002Fbad_example>\n\n\u003Cgood_example>\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\ncmd=$(jq -r '.tool_input.command \u002F\u002F \"\"')\n```\n**Why it's good**: Fails fast on errors, unset variables, and pipe failures.\n\u003C\u002Fgood_example>\n\n### Example: Wrong Exit Code for Blocking\n\n\u003Cbad_example>\n```bash\nif [[ \"$cmd\" == *\"rm -rf\"* ]]; then\n  echo \"Blocked dangerous command\" >&2\n  exit 1  # Wrong!\nfi\n```\n**Why it's bad**: Exit code 1 is non-blocking. Action will still proceed.\n\u003C\u002Fbad_example>\n\n\u003Cgood_example>\n```bash\nif [[ \"$cmd\" == *\"rm -rf\"* ]]; then\n  echo '{\"decision\": \"block\", \"reason\": \"Dangerous command\"}' >&2\n  exit 2  # Correct blocking exit code\nfi\n```\n**Why it's good**: Exit code 2 blocks the action. JSON output provides context.\n\u003C\u002Fgood_example>\n\n### Example: Prompt Hook on Wrong Event\n\n\u003Cbad_example>\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"hooks\": [{ \"type\": \"prompt\", \"prompt\": \"Is this safe?\" }]\n      }\n    ]\n  }\n}\n```\n**Why it's bad**: Prompt hooks only work for Stop and SubagentStop events.\n\u003C\u002Fbad_example>\n\n\u003Cgood_example>\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"hooks\": [{ \"type\": \"command\", \"command\": \".\u002Fvalidate.sh\" }]\n      }\n    ]\n  }\n}\n```\n**Why it's good**: Command hooks work for all events.\n\u003C\u002Fgood_example>\n\n### Example: Dangerous Command Pattern\n\n\u003Cbad_example>\n```bash\nif echo \"$cmd\" | grep -q 'rm'; then\n  exit 2\nfi\n```\n**Why it's bad**: Too broad - blocks legitimate `rm file.tmp`.\n\u003C\u002Fbad_example>\n\n\u003Cgood_example>\n```bash\nif echo \"$cmd\" | grep -qE 'rm\\s+(-rf|-fr)\\s+\u002F'; then\n  exit 2\nfi\n```\n**Why it's good**: Specific pattern targets actual dangerous commands.\n\u003C\u002Fgood_example>\n\n### Example: Hardcoded Path\n\n\u003Cbad_example>\n```bash\nlog_file=\"\u002Fhome\u002Fuser\u002Fproject\u002F.claude\u002Fcommands.log\"\n```\n**Why it's bad**: Hardcoded path breaks on other machines.\n\u003C\u002Fbad_example>\n\n\u003Cgood_example>\n```bash\nlog_file=\"$CLAUDE_PROJECT_DIR\u002F.claude\u002Fcommands.log\"\n```\n**Why it's good**: Uses environment variable for portability.\n\u003C\u002Fgood_example>\n\u003C\u002Fexamples>\n\n---\n\n## Constraints\n\n- Only apply auto-fixes for HIGH certainty issues\n- Be cautious about security patterns - false negatives worse than false positives\n- Never remove content, only suggest improvements\n- Validate against embedded knowledge reference above\n","# enhance-hooks\n\nAnalyze hook definitions and scripts for safety, correctness, and best practices.\n\n## Parse Arguments\n\n```javascript\nconst args = '$ARGUMENTS'.split(' ').filter(Boolean);\nconst targetPath = args.find(a => !a.startsWith('--')) || '.';\nconst fix = args.includes('--fix');\n```\n\n## Workflow\n\n1. **Discover** - Find hook files (.md, .sh, .json)\n2. **Classify** - Identify hook type and event\n3. **Parse** - Extract frontmatter and script content\n4. **Check** - Run all pattern checks against knowledge below\n5. **Filter** - Apply certainty filtering\n6. **Report** - Generate markdown output\n7. **Fix** - Apply auto-fixes if --fix flag present\n\n---\n\n## Hook Knowledge Reference\n\n### What Are Hooks\n\nHooks are automated actions triggered at specific points in a Claude Code session. They enable validation, monitoring, and control of Claude's actions through bash commands or LLM-based evaluation.\n\n### Hook Lifecycle (Complete Reference)\n\nHooks fire in this sequence:\n\n| Order | Event | Description | Matcher Required |\n|-------|-------|-------------|------------------|\n| 1 | `SessionStart` | Session begins or resumes | No |\n| 2 | `UserPromptSubmit` | User submits a prompt | No |\n| 3 | `PreToolUse` | Before tool execution (can modify\u002Fblock) | Yes |\n| 4 | `PermissionRequest` | When permission dialog appears | Yes |\n| 5 | `PostToolUse` | After tool succeeds | Yes |\n| 6 | `SubagentStart` | When spawning a subagent | No |\n| 7 | `SubagentStop` | When subagent finishes | No |\n| 8 | `Stop` | Claude finishes responding | No |\n| 9 | `PreCompact` | Before context compaction | No |\n| 10 | `SessionEnd` | Session terminates | No |\n| 11 | `Notification` | Claude Code sends notifications | No |\n\n### Hook Types\n\n**Command Hooks** (`type: \"command\"`):\n- Execute bash commands with full stdin\u002Fstdout control\n- Available for all events\n\n**Prompt Hooks** (`type: \"prompt\"`):\n- Use LLM evaluation for intelligent, context-aware decisions\n- **Only supported for `Stop` and `SubagentStop` events**\n\n### Configuration Locations\n\n| File | Location | Scope | Committed |\n|------|----------|-------|-----------|\n| User settings | `~\u002F.claude\u002Fsettings.json` | All projects | No |\n| Project settings | `.claude\u002Fsettings.json` | Current project | Yes |\n| Local settings | `.claude\u002Fsettings.local.json` | Current project | No |\n\n### Configuration Structure\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \".claude\u002Fhooks\u002Fvalidate-bash.sh\",\n            \"timeout\": 30\n          }\n        ]\n      }\n    ],\n    \"PostToolUse\": [\n      {\n        \"matcher\": \"Write|Edit\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"$CLAUDE_PROJECT_DIR\u002F.claude\u002Fhooks\u002Fformat-code.sh\"\n          }\n        ]\n      }\n    ],\n    \"Stop\": [\n      {\n        \"hooks\": [\n          {\n            \"type\": \"prompt\",\n            \"prompt\": \"Check if all requested tasks are complete.\",\n            \"timeout\": 30\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n### Matcher Syntax\n\n| Pattern | Description |\n|---------|-------------|\n| `Write` | Match exact tool name |\n| `Edit\\|Write` | Match multiple tools (regex OR) |\n| `Notebook.*` | Regex pattern matching |\n| `*` or `\"\"` | Match all tools |\n| (omitted) | Required for Stop, SubagentStop, UserPromptSubmit |\n\n### Input Schema (JSON via stdin)\n\nAll hooks receive this JSON structure:\n\n```json\n{\n  \"session_id\": \"abc123\",\n  \"transcript_path\": \"\u002Fpath\u002Fto\u002Ftranscript\",\n  \"cwd\": \"\u002Fproject\u002Froot\",\n  \"permission_mode\": \"default\",\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_name\": \"Bash\",\n  \"tool_input\": {\n    \"command\": \"npm test\",\n    \"description\": \"Run test suite\"\n  }\n}\n```\n\n### Exit Codes\n\n| Exit Code | Behavior |\n|-----------|----------|\n| 0 | Success - stdout shown to user or added as context |\n| 2 | Blocking error - stderr shown, action blocked |\n| Other | Non-blocking error - stderr shown in verbose mode |\n\n### Output Schemas\n\n**PreToolUse Decision Control:**\n```json\n{\n  \"hookSpecificOutput\": {\n    \"hookEventName\": \"PreToolUse\",\n    \"permissionDecision\": \"allow|deny|ask\",\n    \"permissionDecisionReason\": \"Reason for decision\",\n    \"updatedInput\": {\n      \"command\": \"modified command\"\n    },\n    \"additionalContext\": \"Context for Claude\"\n  }\n}\n```\n\n**Stop\u002FSubagentStop Control:**\n```json\n{\n  \"decision\": \"block\",\n  \"reason\": \"Tasks incomplete: missing test coverage\"\n}\n```\n\n### Environment Variables\n\n| Variable | Description | Available In |\n|----------|-------------|--------------|\n| `CLAUDE_PROJECT_DIR` | Absolute path to project root | All hooks |\n| `CLAUDE_CODE_REMOTE` | \"true\" if remote session | All hooks |\n| `CLAUDE_ENV_FILE` | Path to persist env vars | SessionStart only |\n| `CLAUDE_FILE_PATHS` | Space-separated file paths | PostToolUse (Write\u002FEdit) |\n\n### Practical Hook Examples\n\n**Security Firewall (PreToolUse):**\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\n\ncmd=$(jq -r '.tool_input.command \u002F\u002F \"\"')\n\n# Block dangerous patterns\nif echo \"$cmd\" | grep -qE 'rm -rf|git reset --hard|curl.*\\|.*sh'; then\n  echo '{\"decision\": \"block\", \"reason\": \"Dangerous command blocked\"}' >&2\n  exit 2\nfi\n\nexit 0\n```\n\n**Auto-Formatter (PostToolUse):**\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\n\nfiles=$(jq -r '.tool_input.file_path \u002F\u002F \"\"')\n\nfor file in $files; do\n  case \"$file\" in\n    *.py) black \"$file\" 2>\u002Fdev\u002Fnull || true ;;\n    *.js|*.ts) prettier --write \"$file\" 2>\u002Fdev\u002Fnull || true ;;\n  esac\ndone\n\nexit 0\n```\n\n**Command Logger (PreToolUse):**\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\ncmd=$(jq -r '.tool_input.command \u002F\u002F \"\"')\nprintf '%s %s\\n' \"$(date -Is)\" \"$cmd\" >> .claude\u002Fbash-commands.log\nexit 0\n```\n\n**Workflow Orchestration (SubagentStop - prompt type):**\n```json\n{\n  \"hooks\": {\n    \"SubagentStop\": [\n      {\n        \"hooks\": [\n          {\n            \"type\": \"prompt\",\n            \"prompt\": \"Review the subagent's work. Did it complete all tasks?\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n---\n\n## Detection Patterns\n\n### 1. Frontmatter Validation (HIGH Certainty)\n\n**Required:**\n- YAML frontmatter with `---` delimiters\n- `name` field in frontmatter\n- `description` field in frontmatter\n\n**Recommended:**\n- `timeout` for command hooks (default: 30s)\n- Hook type specification\n\n**Flag:**\n- Missing frontmatter delimiters\n- Missing name or description\n\n### 2. Script Safety (HIGH Certainty)\n\n**Required Safety Patterns:**\n- `set -euo pipefail` at script start\n- Error handling for jq\u002FJSON parsing\n- Proper quoting of variables\n\n**Dangerous Patterns to Flag:**\n\n| Pattern | Risk | Certainty |\n|---------|------|-----------|\n| `rm -rf` | Destructive without confirmation | HIGH |\n| `git reset --hard` | Data loss risk | HIGH |\n| `curl \\| sh` | Remote code execution | HIGH |\n| `eval \"$input\"` | Arbitrary code execution | HIGH |\n| `rm -r` | Recursive delete (may be intentional) | MEDIUM |\n| `git push --force` | Force push (may be intentional) | MEDIUM |\n\n### 3. Exit Code Handling (HIGH Certainty)\n\n**Check:** Scripts use correct exit codes\n\n**Flag:**\n- Missing `exit 0` for success path\n- Using exit code 1 for blocking (should be 2)\n- No exit code at end of script\n\n### 4. Hook Type Appropriateness (HIGH Certainty)\n\n**Check:** Hook type matches event\n\n**Flag:**\n- Prompt hooks used for events other than Stop\u002FSubagentStop\n- Missing type specification\n\n### 5. Lifecycle Event Appropriateness (MEDIUM Certainty)\n\n| Event | Appropriate Use Cases |\n|-------|----------------------|\n| `PreToolUse` | Security validation, command blocking, input modification |\n| `PostToolUse` | Formatting, logging, notifications |\n| `Stop` | Completion checks, cleanup, summary |\n| `SubagentStop` | Workflow orchestration, result validation |\n| `SessionStart` | Environment setup, initialization |\n\n**Flag:**\n- PostToolUse hooks trying to block actions (too late)\n- PreToolUse hooks doing heavy processing (should be fast)\n- Prompt hooks on unsupported events\n\n### 6. Timeout Configuration (MEDIUM Certainty)\n\n**Guidelines:**\n- Default: 30 seconds for command hooks\n- Network operations: Always set explicit timeout\n- External service calls: Set timeout based on expected latency\n\n**Flag:**\n- No timeout for network operations\n- Timeout missing for external service calls\n- Unreasonably long timeouts (>60s without justification)\n\n### 7. Output Format (MEDIUM Certainty)\n\n**PreToolUse Output Fields:**\n- `permissionDecision`: allow, deny, or ask\n- `permissionDecisionReason`: Explanation for decision\n- `updatedInput`: Modified tool input (optional)\n- `additionalContext`: Context for Claude (optional)\n\n**Flag:**\n- Invalid permissionDecision values\n- Missing reason for deny decisions\n- Malformed JSON output\n\n### 8. Matcher Patterns (MEDIUM Certainty)\n\n**Check:** Matcher syntax is valid\n\n**Flag:**\n- Invalid regex patterns\n- Too broad matchers (`*` without justification)\n- Matcher on events that don't support it (Stop, SubagentStop)\n\n### 9. Anti-Patterns (LOW Certainty)\n\n- Complex logic in hooks (should be simple and fast)\n- Missing documentation\u002Fcomments\n- Hardcoded paths (should use `$CLAUDE_PROJECT_DIR`)\n- Network calls without error handling\n- Secrets\u002Fcredentials in hook scripts\n\n---\n\n## Auto-Fix Implementations\n\n### 1. Missing safety header\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\n```\n\n### 2. Missing exit code\nAdd `exit 0` at end of script\n\n### 3. Missing frontmatter fields\n```yaml\n---\nname: hook-name\ndescription: Hook description\ntimeout: 30\n---\n```\n\n### 4. Wrong blocking exit code\nReplace `exit 1` with `exit 2` for blocking errors\n\n---\n\n## Output Format\n\n```markdown\n## Hook Analysis: {hook-name}\n\n**File**: {path}\n**Type**: {command|prompt|config}\n**Event**: {PreToolUse|PostToolUse|Stop|...}\n\n### Summary\n- HIGH: {count} issues\n- MEDIUM: {count} issues\n\n### Frontmatter Issues ({n})\n| Issue | Fix | Certainty |\n\n### Safety Issues ({n})\n| Issue | Fix | Certainty |\n\n### Exit Code Issues ({n})\n| Issue | Fix | Certainty |\n\n### Lifecycle Issues ({n})\n| Issue | Fix | Certainty |\n\n### Output Format Issues ({n})\n| Issue | Fix | Certainty |\n```\n\n---\n\n## Pattern Statistics\n\n| Category | Patterns | Auto-Fixable |\n|----------|----------|--------------|\n| Frontmatter | 3 | 2 |\n| Safety | 6 | 2 |\n| Exit Code | 3 | 2 |\n| Hook Type | 2 | 0 |\n| Lifecycle | 5 | 0 |\n| Timeout | 3 | 0 |\n| Output | 3 | 0 |\n| Matcher | 3 | 0 |\n| Anti-Pattern | 5 | 0 |\n| **Total** | **33** | **6** |\n\n---\n\n\u003Cexamples>\n### Example: Missing Safety Header\n\n\u003Cbad_example>\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\ncmd=$(jq -r '.tool_input.command \u002F\u002F \"\"')\n```\n**Why it's bad**: Missing `set -euo pipefail` means errors may silently pass.\n\u003C\u002Fbad_example>\n\n\u003Cgood_example>\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\ncmd=$(jq -r '.tool_input.command \u002F\u002F \"\"')\n```\n**Why it's good**: Fails fast on errors, unset variables, and pipe failures.\n\u003C\u002Fgood_example>\n\n### Example: Wrong Exit Code for Blocking\n\n\u003Cbad_example>\n```bash\nif [[ \"$cmd\" == *\"rm -rf\"* ]]; then\n  echo \"Blocked dangerous command\" >&2\n  exit 1  # Wrong!\nfi\n```\n**Why it's bad**: Exit code 1 is non-blocking. Action will still proceed.\n\u003C\u002Fbad_example>\n\n\u003Cgood_example>\n```bash\nif [[ \"$cmd\" == *\"rm -rf\"* ]]; then\n  echo '{\"decision\": \"block\", \"reason\": \"Dangerous command\"}' >&2\n  exit 2  # Correct blocking exit code\nfi\n```\n**Why it's good**: Exit code 2 blocks the action. JSON output provides context.\n\u003C\u002Fgood_example>\n\n### Example: Prompt Hook on Wrong Event\n\n\u003Cbad_example>\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"hooks\": [{ \"type\": \"prompt\", \"prompt\": \"Is this safe?\" }]\n      }\n    ]\n  }\n}\n```\n**Why it's bad**: Prompt hooks only work for Stop and SubagentStop events.\n\u003C\u002Fbad_example>\n\n\u003Cgood_example>\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"hooks\": [{ \"type\": \"command\", \"command\": \".\u002Fvalidate.sh\" }]\n      }\n    ]\n  }\n}\n```\n**Why it's good**: Command hooks work for all events.\n\u003C\u002Fgood_example>\n\n### Example: Dangerous Command Pattern\n\n\u003Cbad_example>\n```bash\nif echo \"$cmd\" | grep -q 'rm'; then\n  exit 2\nfi\n```\n**Why it's bad**: Too broad - blocks legitimate `rm file.tmp`.\n\u003C\u002Fbad_example>\n\n\u003Cgood_example>\n```bash\nif echo \"$cmd\" | grep -qE 'rm\\s+(-rf|-fr)\\s+\u002F'; then\n  exit 2\nfi\n```\n**Why it's good**: Specific pattern targets actual dangerous commands.\n\u003C\u002Fgood_example>\n\n### Example: Hardcoded Path\n\n\u003Cbad_example>\n```bash\nlog_file=\"\u002Fhome\u002Fuser\u002Fproject\u002F.claude\u002Fcommands.log\"\n```\n**Why it's bad**: Hardcoded path breaks on other machines.\n\u003C\u002Fbad_example>\n\n\u003Cgood_example>\n```bash\nlog_file=\"$CLAUDE_PROJECT_DIR\u002F.claude\u002Fcommands.log\"\n```\n**Why it's good**: Uses environment variable for portability.\n\u003C\u002Fgood_example>\n\u003C\u002Fexamples>\n\n---\n\n## Constraints\n\n- Only apply auto-fixes for HIGH certainty issues\n- Be cautious about security patterns - false negatives worse than false positives\n- Never remove content, only suggest improvements\n- Validate against embedded knowledge reference above\n",{"name":5,"version":23,"description":7,"argument-hint":24},"5.1.0","[path] [--fix]","main","f37de8f681f0c0ca0e0ebab6e5fddf764ca7553d","skills\u002Fenhance-hooks",1,"https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one","https:\u002F\u002Fagisota.github.io\u002Fold-one\u002F","https:\u002F\u002Fgithub.com\u002Fagisota","pzd.world","2026-07-04 22:32:06",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add agisota\u002Fold-one --skill enhance-hooks",{"tool":40,"command":41},"bunx","bunx skills add agisota\u002Fold-one --skill enhance-hooks",{"tool":43,"command":44},"pnpm","pnpm dlx skills add agisota\u002Fold-one --skill enhance-hooks","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fenhance-hooks\u002FSKILL.md",true,[],[49,56,63,72,79,86],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M75KRGZWQWE9JDBS6RX42NWV","zoom-out","Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fzoom-out\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":18},"01M75KRCZHKE0ZYAQFFYHS0YNP","zeroize-audit","Detects missing zeroization of sensitive data in source code and identifies zeroization removed by compiler optimizations, with assembly-level analysis, and control-flow verification. Use for auditing C\u002FC++\u002FRust code handling secrets, keys, passwords, or other sensitive data.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fzeroize-audit\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":67,"licenseFileUrl":68,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":18},"01M75KR94KYQ30DTE1P9WNDAE0","yeet","Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":18},"01M75KR3H13YJ9QHMD49818FA1","yara-rule-authoring","Guides authoring of high-quality YARA-X detection rules for malware identification. Use when writing, reviewing, or optimizing YARA rules. Covers naming conventions, string selection, performance optimization, migration from legacy YARA, and false positive reduction. Triggers on: YARA, YARA-X, malware detection, threat hunting, IOC, signature, crx module, dex module.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyara-rule-authoring\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":18},"01M75KQMPY8A4Y8XTDD2DT0M9T","x-twitter-growth","X\u002FTwitter growth engine for building audience, crafting viral content, and analyzing engagement. Use when the user wants to grow on X\u002FTwitter, write tweets or threads, analyze their X profile, research competitors on X, plan a posting strategy, or optimize engagement. Complements social-content (generic multi-platform) with X-specific depth: algorithm mechanics, thread engineering, reply strategy, profile optimization, and competitive intelligence via web search.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fx-twitter-growth\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":18},"01M75KQHNZ0ANZNJGZY6M8MDAK","x-api","X\u002FTwitter API integration for posting tweets, threads, reading timelines, search, and analytics. Covers OAuth auth patterns, rate limits, and platform-native content posting. Use when the user wants to interact with X programmatically.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fx-api\u002FSKILL.md",[],[]]