[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ASEV80J3E1TNMGTJ36DTKG":3,"skill-same:01M7ASEV80J3E1TNMGTJ36DTKG":61},{"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":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7ASEV80J3E1TNMGTJ36DTKG","creating-hooks",null,"Creates Claude Code hooks.","saski\u002Farnesto","saski","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F140356?v=4","01M7ASBDSNXTRYDYB4K1PEA1RV","01M7ASBDTAKBDAAV99S1GE7HK6",6,"Unlicense","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcreating-hooks\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: creating-hooks\ndescription: Creates Claude Code hooks.\n---\n\nSTARTER_CHARACTER = 🪝\n\n## Setup\n\nFirst, update the reference docs to get the latest from Anthropic:\n```bash\npython ~\u002F.claude\u002Fskills\u002Fcreating-hooks\u002Fscripts\u002Fupdate-docs.py\n```\n\n## What Hooks Are\n\nShell commands that execute at lifecycle points in Claude Code. Unlike prompts, hooks are deterministic—they always run when triggered.\n\n## Configuration\n\nHooks live in settings files:\n- `~\u002F.claude\u002Fsettings.json` - User settings (all projects)\n- `.claude\u002Fsettings.json` - Project settings (shared via git)\n- `.claude\u002Fsettings.local.json` - Local project settings (not committed)\n\n```json\n{\n  \"hooks\": {\n    \"EventName\": [\n      {\n        \"matcher\": \"ToolPattern\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"your-command-here\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n**Matcher**: Pattern to match tool names (case-sensitive)\n- Exact match: `Write`\n- Regex: `Edit|Write`\n- All tools: `*` or omit\n\n**Environment variables**:\n- `$CLAUDE_PROJECT_DIR` - Absolute path to project root\n- `$CLAUDE_ENV_FILE` - File path for persisting env vars (SessionStart only)\n\n## Hook Events\n\n**Tool events** (matcher applies):\n- `PreToolUse` - Before tool executes\n- `PostToolUse` - After tool completes\n- `PermissionRequest` - Permission dialog shown\n\n**Session events**:\n- `SessionStart` - Session begins\u002Fresumes (matcher: startup\u002Fresume\u002Fclear\u002Fcompact)\n- `SessionEnd` - Session ends\n- `PreCompact` - Before compaction (matcher: manual\u002Fauto)\n\n**Other events**:\n- `UserPromptSubmit` - User submits prompt\n- `Stop` - Agent finishes\n- `SubagentStop` - Subagent finishes\n- `Notification` - Alerts sent (matcher: notification type)\n\n## Exit Codes\n\n- **0**: Success. stdout shown in verbose mode. For `UserPromptSubmit`\u002F`SessionStart`, stdout added to context.\n- **2**: Block. stderr fed to Claude as error message. Blocks the action.\n- **Other**: Non-blocking error. stderr shown to user.\n\n## JSON Output\n\nFor advanced control, return JSON to stdout with exit code 0:\n\n```json\n{\n  \"continue\": false,\n  \"stopReason\": \"Message shown when stopping\"\n}\n```\n\n### PreToolUse Control\n\n```json\n{\n  \"hookSpecificOutput\": {\n    \"hookEventName\": \"PreToolUse\",\n    \"permissionDecision\": \"allow\",\n    \"permissionDecisionReason\": \"Auto-approved\",\n    \"updatedInput\": { \"field\": \"modified value\" }\n  }\n}\n```\n\nDecisions: `\"allow\"` (bypass permission), `\"deny\"` (block), `\"ask\"` (prompt user)\n\n### PostToolUse Feedback\n\n```json\n{\n  \"decision\": \"block\",\n  \"reason\": \"Explanation fed to Claude\"\n}\n```\n\n### Stop\u002FSubagentStop Control\n\n```json\n{\n  \"decision\": \"block\",\n  \"reason\": \"Must fix X before stopping\"\n}\n```\n\n## Hook Input\n\nHooks receive JSON via stdin:\n\n```json\n{\n  \"session_id\": \"abc123\",\n  \"transcript_path\": \"\u002Fpath\u002Fto\u002Ftranscript.jsonl\",\n  \"cwd\": \"\u002Fcurrent\u002Fdir\",\n  \"permission_mode\": \"default\",\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_name\": \"Write\",\n  \"tool_input\": { \"file_path\": \"\u002Fpath\", \"content\": \"...\" }\n}\n```\n\n## Common Patterns\n\n**Auto-format after edit**:\n```json\n{\n  \"hooks\": {\n    \"PostToolUse\": [{\n      \"matcher\": \"Edit|Write\",\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"jq -r '.tool_input.file_path' | xargs -I{} sh -c 'echo {} | grep -q \\\"\\\\.ts$\\\" && npx prettier --write {}'\"\n      }]\n    }]\n  }\n}\n```\n\n**Block dangerous commands**:\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [{\n      \"matcher\": \"Bash\",\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"\\\"$CLAUDE_PROJECT_DIR\\\"\u002F.claude\u002Fhooks\u002Fvalidate-bash.py\"\n      }]\n    }]\n  }\n}\n```\n\n**Inject context on prompt**:\n```json\n{\n  \"hooks\": {\n    \"UserPromptSubmit\": [{\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"echo '[REMINDER: Follow TDD]'\"\n      }]\n    }]\n  }\n}\n```\n\n**Desktop notification**:\n```json\n{\n  \"hooks\": {\n    \"Notification\": [{\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"osascript -e 'display notification \\\"Claude needs input\\\" with title \\\"Claude Code\\\"'\"\n      }]\n    }]\n  }\n}\n```\n\n## Hook Scripts\n\nFor complex logic, use external scripts. UV single-file format works well:\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv -S uv run --script\n# \u002F\u002F\u002F script\n# dependencies = []\n# requires-python = \">=3.11\"\n# \u002F\u002F\u002F\n\nimport json\nimport sys\n\ndata = json.load(sys.stdin)\ntool_input = data.get(\"tool_input\", {})\n\n# Validation logic here\n\nif should_block:\n    print(\"Error message\", file=sys.stderr)\n    sys.exit(2)\n\nsys.exit(0)\n```\n\n## Anti-Patterns\n\n- Using exit code 2 without stderr message (Claude gets no feedback)\n- Forgetting to handle JSON parsing errors in scripts\n- Blocking without explaining why (Claude will retry the same thing)\n- Long-running hooks without timeout (default is 60s)\n- Modifying files in PreToolUse (use PostToolUse for modifications)\n\n## Reference\n\n- [references\u002Fanthropic-hooks.md](references\u002Fanthropic-hooks.md) - Complete reference (input schemas, prompt hooks, MCP tools)\n- [references\u002Fanthropic-hooks-guide.md](references\u002Fanthropic-hooks-guide.md) - Quickstart and examples\n","STARTER_CHARACTER = 🪝\n\n## Setup\n\nFirst, update the reference docs to get the latest from Anthropic:\n```bash\npython ~\u002F.claude\u002Fskills\u002Fcreating-hooks\u002Fscripts\u002Fupdate-docs.py\n```\n\n## What Hooks Are\n\nShell commands that execute at lifecycle points in Claude Code. Unlike prompts, hooks are deterministic—they always run when triggered.\n\n## Configuration\n\nHooks live in settings files:\n- `~\u002F.claude\u002Fsettings.json` - User settings (all projects)\n- `.claude\u002Fsettings.json` - Project settings (shared via git)\n- `.claude\u002Fsettings.local.json` - Local project settings (not committed)\n\n```json\n{\n  \"hooks\": {\n    \"EventName\": [\n      {\n        \"matcher\": \"ToolPattern\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"your-command-here\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n**Matcher**: Pattern to match tool names (case-sensitive)\n- Exact match: `Write`\n- Regex: `Edit|Write`\n- All tools: `*` or omit\n\n**Environment variables**:\n- `$CLAUDE_PROJECT_DIR` - Absolute path to project root\n- `$CLAUDE_ENV_FILE` - File path for persisting env vars (SessionStart only)\n\n## Hook Events\n\n**Tool events** (matcher applies):\n- `PreToolUse` - Before tool executes\n- `PostToolUse` - After tool completes\n- `PermissionRequest` - Permission dialog shown\n\n**Session events**:\n- `SessionStart` - Session begins\u002Fresumes (matcher: startup\u002Fresume\u002Fclear\u002Fcompact)\n- `SessionEnd` - Session ends\n- `PreCompact` - Before compaction (matcher: manual\u002Fauto)\n\n**Other events**:\n- `UserPromptSubmit` - User submits prompt\n- `Stop` - Agent finishes\n- `SubagentStop` - Subagent finishes\n- `Notification` - Alerts sent (matcher: notification type)\n\n## Exit Codes\n\n- **0**: Success. stdout shown in verbose mode. For `UserPromptSubmit`\u002F`SessionStart`, stdout added to context.\n- **2**: Block. stderr fed to Claude as error message. Blocks the action.\n- **Other**: Non-blocking error. stderr shown to user.\n\n## JSON Output\n\nFor advanced control, return JSON to stdout with exit code 0:\n\n```json\n{\n  \"continue\": false,\n  \"stopReason\": \"Message shown when stopping\"\n}\n```\n\n### PreToolUse Control\n\n```json\n{\n  \"hookSpecificOutput\": {\n    \"hookEventName\": \"PreToolUse\",\n    \"permissionDecision\": \"allow\",\n    \"permissionDecisionReason\": \"Auto-approved\",\n    \"updatedInput\": { \"field\": \"modified value\" }\n  }\n}\n```\n\nDecisions: `\"allow\"` (bypass permission), `\"deny\"` (block), `\"ask\"` (prompt user)\n\n### PostToolUse Feedback\n\n```json\n{\n  \"decision\": \"block\",\n  \"reason\": \"Explanation fed to Claude\"\n}\n```\n\n### Stop\u002FSubagentStop Control\n\n```json\n{\n  \"decision\": \"block\",\n  \"reason\": \"Must fix X before stopping\"\n}\n```\n\n## Hook Input\n\nHooks receive JSON via stdin:\n\n```json\n{\n  \"session_id\": \"abc123\",\n  \"transcript_path\": \"\u002Fpath\u002Fto\u002Ftranscript.jsonl\",\n  \"cwd\": \"\u002Fcurrent\u002Fdir\",\n  \"permission_mode\": \"default\",\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_name\": \"Write\",\n  \"tool_input\": { \"file_path\": \"\u002Fpath\", \"content\": \"...\" }\n}\n```\n\n## Common Patterns\n\n**Auto-format after edit**:\n```json\n{\n  \"hooks\": {\n    \"PostToolUse\": [{\n      \"matcher\": \"Edit|Write\",\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"jq -r '.tool_input.file_path' | xargs -I{} sh -c 'echo {} | grep -q \\\"\\\\.ts$\\\" && npx prettier --write {}'\"\n      }]\n    }]\n  }\n}\n```\n\n**Block dangerous commands**:\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [{\n      \"matcher\": \"Bash\",\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"\\\"$CLAUDE_PROJECT_DIR\\\"\u002F.claude\u002Fhooks\u002Fvalidate-bash.py\"\n      }]\n    }]\n  }\n}\n```\n\n**Inject context on prompt**:\n```json\n{\n  \"hooks\": {\n    \"UserPromptSubmit\": [{\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"echo '[REMINDER: Follow TDD]'\"\n      }]\n    }]\n  }\n}\n```\n\n**Desktop notification**:\n```json\n{\n  \"hooks\": {\n    \"Notification\": [{\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"osascript -e 'display notification \\\"Claude needs input\\\" with title \\\"Claude Code\\\"'\"\n      }]\n    }]\n  }\n}\n```\n\n## Hook Scripts\n\nFor complex logic, use external scripts. UV single-file format works well:\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv -S uv run --script\n# \u002F\u002F\u002F script\n# dependencies = []\n# requires-python = \">=3.11\"\n# \u002F\u002F\u002F\n\nimport json\nimport sys\n\ndata = json.load(sys.stdin)\ntool_input = data.get(\"tool_input\", {})\n\n# Validation logic here\n\nif should_block:\n    print(\"Error message\", file=sys.stderr)\n    sys.exit(2)\n\nsys.exit(0)\n```\n\n## Anti-Patterns\n\n- Using exit code 2 without stderr message (Claude gets no feedback)\n- Forgetting to handle JSON parsing errors in scripts\n- Blocking without explaining why (Claude will retry the same thing)\n- Long-running hooks without timeout (default is 60s)\n- Modifying files in PreToolUse (use PostToolUse for modifications)\n\n## Reference\n\n- [references\u002Fanthropic-hooks.md](references\u002Fanthropic-hooks.md) - Complete reference (input schemas, prompt hooks, MCP tools)\n- [references\u002Fanthropic-hooks-guide.md](references\u002Fanthropic-hooks-guide.md) - Quickstart and examples\n",{"name":5,"description":7},"main","3c24fc2c035029b08c7326774bee3fef8fb95566",".agents\u002Fskills\u002Fcreating-hooks",0,"https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto","https:\u002F\u002Fgithub.com\u002Fsaski","http:\u002F\u002Fsaski.com","2026-11-12 20:09:16",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add saski\u002Farnesto --skill creating-hooks",{"tool":37,"command":38},"bunx","bunx skills add saski\u002Farnesto --skill creating-hooks",{"tool":40,"command":41},"pnpm","pnpm dlx skills add saski\u002Farnesto --skill creating-hooks","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcreating-hooks\u002FSKILL.md",true,[45,51,55],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"references\u002Fanthropic-hooks-guide.md","REFERENCE","参考文档",29220,"https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcreating-hooks\u002Freferences\u002Fanthropic-hooks-guide.md",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"references\u002Fanthropic-hooks.md",73415,"https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcreating-hooks\u002Freferences\u002Fanthropic-hooks.md",{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"scripts\u002Fupdate-docs.py","SCRIPT","脚本",991,"https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcreating-hooks\u002Fscripts\u002Fupdate-docs.py",[62,69,76,83,90,97],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":18},"01M7AT7F5FSHNAMFMF01N0QA1X","visualize","Use \u002Fvisualize for creating compact charts, diagrams, or other visuals inline as part of the conversation itself. It chooses among Markdown tables, Mermaid, inline HTML, and other supported in-transcript forms. Use Canvas for durable artifacts outside the transcript that users may revisit, refine, or share.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fvisualize\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M7AT79MHSAR3JDDMP7DGERM9","update-cursor-settings","Modify Cursor\u002FVSCode user settings in settings.json. Use when you want to change editor settings, preferences, configuration, themes, font size, tab size, format on save, auto save, keybindings, or any settings.json values.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fupdate-cursor-settings\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":18},"01M7AT73WF3Y22E0FKYAMCCJES","update-cli-config","View and modify Cursor CLI configuration settings in ~\u002F.cursor\u002Fcli-config.json. Use when the user wants to change CLI settings, configure permissions, switch approval mode, enable vim mode, toggle display options, configure sandbox, or manage any CLI preferences.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fupdate-cli-config\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":18},"01M7AT6F3FBP85AJJ5BJNR8B5W","statusline","Configure a custom status line in the CLI. Use when the user mentions status line, statusline, statusLine, CLI status bar, prompt footer customization, or wants to add session context above the prompt.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fstatusline\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":18},"01M7AT6D24QFS5XRAFN8S5XJ7W","split-to-prs","Split current work into small reviewable PRs. Use when the user asks to split a chat, set of changes, branch, or PR.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fsplit-to-prs\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":18},"01M7AT69FYFN84XZKW452JV5DF","shell","Runs the rest of a \u002Fshell request as a literal shell command. Use only when the user explicitly invokes \u002Fshell and wants the following text executed directly in the terminal.","https:\u002F\u002Fgithub.com\u002Fsaski\u002Farnesto\u002Fblob\u002Fmain\u002F.cursor\u002Fskills-cursor\u002Fshell\u002FSKILL.md",[],[]]