用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill hook-authoring命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | hook-authoring |
| description | | Use when this capability is needed. |
This skill auto-applies when you're working with Claude Code hooks. Follow these patterns for consistent, reliable hooks.
Session Start
│
├── SessionStart hook
│
▼
┌─────────────────────────────────┐
│ User sends prompt │
│ │ │
│ ├── UserPromptSubmit hooks │
│ ▼ │
│ Claude processes... │
│ │ │
│ ├── Stop hook │
│ ▼ │
│ (repeat) │
└─────────────────────────────────┘
│
├── PreCompact hook
│
▼
Session End
│
└── SessionEnd hook
Always start with:
#!/bin/bash
set -euo pipefail
Critical: All hooks MUST consume stdin to avoid broken pipe errors:
# Read stdin (required even if not used)
input=$(cat)
# Or if you need the JSON:
input=$(cat)
session_id=$(echo "$input" | jq -r '.session_id // empty')
Hooks should work even when dependencies are missing:
# Check for jq
if ! command -v jq &>/dev/null; then
exit 0 # Silent exit, don't break Claude
fi
# Check for agent-event-bus-cli
if ! command -v agent-event-bus-cli &>/dev/null; then
cli_path="$HOME/.local/bin/agent-event-bus-cli"
[[ -x "$cli_path" ]] || exit 0
fi
# Check for zellij
if [[ -z "${ZELLIJ:-}" ]]; then
exit 0 # Not in zellij, skip zellij operations
fi
exit 0 - Success (normal completion)exit 0 for graceful degradationAll hooks receive JSON on stdin:
{
"session_id": "uuid",
"transcript_path": "/path/to/transcript.jsonl",
"cwd": "/current/working/directory"
}
Additional fields by trigger:
permission_mode, source ("user" or "resume")permission_mode, reasontriggerUse XML tags for data Claude should parse:
echo "<recent-events>"
echo "$events"
echo "</recent-events>"
Simple text output works:
echo "Hook completed successfully"
For hooks that only have side effects (like zjstatus notifications):
# No output needed - zellij pipe is the action
zellij pipe "zjstatus::notify::message" 2>/dev/null || true
When interacting with zellij:
# Check if in zellij first
[[ -z "${ZELLIJ:-}" ]] && exit 0
# Rename tab
zellij action rename-tab "$tab_name" 2>/dev/null || true
# Send zjstatus notification (appears in statusbar)
zellij pipe "zjstatus::notify::message" 2>/dev/null || true
# Clear zjstatus notification
zellij pipe "zjstatus::notify::" 2>/dev/null || true
For worktree paths, show repo (branch) format:
if [[ "$cwd" == */.worktrees/* ]]; then
repo=$(basename "$(dirname "$(dirname "$cwd")")")
branch=$(basename "$cwd")
tab_name="$repo ($branch)"
fi
For hooks that interact with the event bus:
# Find CLI
if command -v agent-event-bus-cli &>/dev/null; then
cli="agent-event-bus-cli"
elif [[ -x "$HOME/.local/bin/agent-event-bus-cli" ]]; then
cli="$HOME/.local/bin/agent-event-bus-cli"
else
exit 0
fi
# Register session
"$cli" register --name "$session_name" --client-id "$session_id"
# Publish events
"$cli" publish --type "event_type" --payload "message" --session-id "$session_id"
# Get events with resume (incremental)
"$cli" events --resume --session-id "$session_id"
Run make test-hooks to test all hooks. Tests verify:
Add new test cases in tests/test-hooks.sh.
Register hooks in settings.json:
{
"hooks": {
"SessionStart": [{ "hooks": [{ "type": "command", "command": "~/.claude/hooks/your-hook.sh" }] }]
}
}
Available triggers:
SessionStart - Session beginsSessionEnd - Session endsUserPromptSubmit - User sends messageStop - Claude finishes responsePreCompact - Before context summarizationSee existing hooks in home/.claude/hooks/ for examples:
session-start.sh - Event bus registration, zellij tab renamesession-end.sh - Cleanupprompt-events.sh - Incremental event pollingzj-status.sh - Visual state indicator (zjstatus notification)pre-compact.sh - WIP checkpointingConverted and distributed by TomeVault — claim your Tome and manage your conversions.