From scaffold
Interview the user, then author a Claude Code hook script and wire it into their config repo's settings.template.json. Use when the user says "add a hook", "create a hook", "run X automatically when Y", "before/after every tool call do X", "notify me when Claude finishes", or "/add-hook". Hooks are how the harness runs deterministic automation that Claude itself cannot — events like PreToolUse, PostToolUse, Stop, Notification, UserPromptSubmit.
How this skill is triggered — by the user, by Claude, or both
Slash command
/scaffold:add-hookThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Author a hook script under `hooks/` and wire it into `settings.template.json` in
Author a hook script under hooks/ and wire it into settings.template.json in
the user's config repo (default ~/claude-config). Hooks are shell commands the
harness runs on lifecycle events — the right tool for "always do X when Y"
automation, which Claude's own behavior can't guarantee.
Resolve in order: $CLAUDE_CONFIG_REPO, then ~/claude-config, then ask. If no
settings.template.json exists, suggest /scaffold-config first.
Use AskUserQuestion for the event/matcher choices, plain questions for free text. Get:
PreToolUse — before a tool runs; can block it (exit 2 + stderr).PostToolUse — after a tool runs (e.g. auto-format an edited file).UserPromptSubmit — when the user submits a prompt.Stop / SubagentStop — when Claude finishes a turn (e.g. chime/notify).Notification — when Claude needs attention (e.g. desktop banner).SessionStart / SessionEnd.Bash,
Edit|Write|MultiEdit, or .* for all.Write hooks/<name>.sh, executable, reading the event JSON from stdin with
jq. Keep it fast and dependency-light (jq is fine). Example skeleton:
#!/usr/bin/env bash
set -euo pipefail
input="$(cat)"
# tool="$(printf '%s' "$input" | jq -r '.tool_name // empty')"
# ...decide, then: exit 0 (allow) or echo "reason" >&2; exit 2 (block, PreToolUse)
Wire it into settings.template.json under the right event, using a
__REPO__ path so bootstrap renders it:
"PostToolUse": [
{ "matcher": "Edit|Write|MultiEdit",
"hooks": [ { "type": "command", "command": "bash \"__REPO__/hooks/<name>.sh\"" } ] }
]
Merge into existing arrays for that event — don't clobber other hooks.
chmod +x hooks/<name>.sh.
bash <repo>/bootstrap.sh validate (checks the hook exists and is
executable and the JSON parses).settings.json, so re-run ./bootstrap.sh and
tell the user to restart Claude Code to load the new hook.__REPO__ paths.Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub markusjohansen/mj-plugins --plugin scaffold