/agentic-framework:hook-config-generatorfrom Agentic Framework for Claude
Generates Claude Code hook scripts (.ps1/.sh pairs or .sh-only) registered in hooks.json as shell-form chains. Use when asked to create, extend, or add a quality gate or advisory hook.
Ships in Agentic Framework for Claude. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Hooks in this framework are real Claude Code hooks: gates and advisory hooks are implemented as both PowerShell 7 (.ps1) and POSIX shell (.sh) scripts in hooks/, silent hooks as .sh only (see "sh-only advisory hooks" below); each reads a JSON payload on stdin and optionally emits a JSON decision on stdout. They are registered in hooks/hooks.json as a shell-form fallback chain (sh dispatch.sh <name> || pwsh -NoProfile -File <name>.ps1, or sh dispatch.sh <name> || exit 0 for an sh-only hook) and automatically loaded by Claude Code when the agentic-framework plugin is installed. On Linux/macOS, the dispatcher runs the .sh script; on Windows Git Bash it runs the .sh when jq is on PATH and the .ps1 otherwise (or the .ps1 directly if sh is unavailable). Study hooks/stop-peer-review-gate.ps1 and hooks/stop-peer-review-gate.sh (blocking Stop gate pair) and hooks/pretooluse-delegation-hint.ps1 and hooks/pretooluse-delegation-hint.sh (advisory pair) as reference implementations before writing anything.
session_id, cwd, tool_name, tool_input, and stop_hook_active (Stop hooks only).@{ decision = 'block'; reason = $reason } | ConvertTo-Json -Compress@{ suppressOutput = $true; systemMessage = "[hint] ..." } | ConvertTo-Json -Compress{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"..."}} — build it from an [ordered] hashtable with -Depth 5 so key order matches the .sh; keep the reason ASCII with no quotes, angle brackets or ampersands, because ConvertTo-Json escapes those and jq does not, which breaks byte-equivalence. hooks/pretooluse-model-guard.ps1/.sh is the reference pair for that [ordered]/ConvertTo-Json construction. hooks/pretooluse-code-review-gate.ps1/.sh is the second deliberate PreToolUse deny: its .ps1 writes the same JSON shape by hand (string concatenation, not ConvertTo-Json), and the byte-equivalence requirement applies to both.{"hookSpecificOutput":{"hookEventName":"PreToolUse","updatedInput":{...}}}, optionally with a top-level systemMessage. Measured on Claude Code 2.1.278 for the Agent tool: updatedInput REPLACES the tool input, so it must carry every original field plus the change — a partial object drops prompt and description and the call is rejected, whatever the docs say about partial updates. No permissionDecision is needed for the rewrite to take effect; leave it out so the hook does not override the user's permission rules. Echoing means the two implementations must round-trip every value losslessly: read stdin as UTF-8 bytes, never pass the payload through ConvertFrom-Json/ConvertTo-Json (a string that looks like an ISO date comes back as a reformatted DateTime), and compare the two implementations as canonical JSON (jq -S -c .), not as raw bytes, because their string escaping legitimately differs. The same guard pair is the reference.0. Fail-open is mandatory — wrap the entire body in try { ... } catch { exit 0 }. A hook must never break the session on error, malformed stdin, or non-git context.Rules every hook script must follow:
#Requires -Version 7.0 (validation enforces this pin).$payload = [Console]::In.ReadToEnd() | ConvertFrom-Json -ErrorAction Stop inside the try.exit 0 on any precondition failure (missing fields, wrong tool, unmapped file type).session_id before using it in a path: ([string]$payload.session_id) -replace '[^\w\-.]', ''.$env:CLAUDE_STATE_DIR, falling back to Join-Path $HOME '.claude/.state'. Prune files older than ~7 days.$payload.stop_hook_active first and exit 0 if true (loop safety), and bound repeat blocks with a .fired marker — an empty marker for a fire-once gate, or a counter file when a bounded number of re-fires is intended (the peer-review gate uses a counter: 1 block with no review, up to 3 on a CHANGES_REQUIRED verdict).bash scripts/validate-hooks.sh scans hook scripts for deprecated names and fails on any hit.decision: block) and a deliberate PreToolUse ceiling that denies one tool call (permissionDecision: deny, as pretooluse-model-guard does), and the push/PR gate pretooluse-code-review-gate is the second deliberate PreToolUse deny. Everything else must be advisory (systemMessage) or silent.exit 0, never partial output or stderr.The POSIX shell twin, used on Linux/macOS via dispatch.sh:
#!/bin/sh (shebang for POSIX sh, dash, bash — never bash-only syntax).set -u (fail on undefined variables; validation enforces this pin).payload=$(cat) at the top, inside the trap or early-exit handler.exit 0 on any precondition failure; use jq for JSON parsing (it is a framework dependency).session_id before using it in a path: session_id=$(printf "%s" "$session_id" | sed 's/[^-._[:alnum:]]//g').${CLAUDE_STATE_DIR:=$HOME/.claude/.state} (same as PowerShell side); use mkdir -p and touch for markers.stop_hook_active field (via jq) first and exit 0 if true; use the same .fired marker strategy as the .ps1.exit 0 on any error, or use || exit 0 guards at each step.jq to emit compressed JSON (jq -c), never partial output.Gates ship as .ps1/.sh pairs. An advisory or silent hook (telemetry, hints that never block) may ship as .sh only and simply no-op on Windows hosts without jq:
.ps1 half of Step 5; register the chain sh "${CLAUDE_PLUGIN_ROOT}/hooks/dispatch.sh" <name> || exit 0 with no || pwsh arm (and no .ps1 token, which is what the parity checks key on); the || exit 0 arm keeps a host without sh silent instead of surfacing a hook error on every fire.dispatch.sh runs pwsh in its Windows no-jq branch only when hooks/<name>.ps1 exists, so an sh-only hook exits 0 there.telemetry-session-start, telemetry-session-stop, telemetry-agent-run.The dispatcher hooks/dispatch.sh is a shell-form router that detects the platform (POSIX vs MINGW/MSYS/CYGWIN) and runs the appropriate script — on Windows Git Bash it runs the POSIX .sh directly when jq is on PATH (skipping a pwsh cold start), else the .ps1 via pwsh. It has a hardcoded allowlist of hook names — if a hook is not listed, the dispatcher exits 0 silently on POSIX (a silent no-op).
Open hooks/dispatch.sh and add your hook name to the case statement (this matches the real file — the allowlist branch is an empty pass-through; platform routing happens further down):
hook=${1:-}
case "$hook" in
stop-peer-review-gate|record-subagent-run|session-start-context|pretooluse-delegation-hint|pretooluse-model-guard|pretooluse-code-review-gate|your-new-hook) ;;
*) exit 0 ;;
esac
Warning: skipping this step means the hook will silently do nothing on POSIX systems — registration in hooks/hooks.json is not enough. On Windows, the .ps1 runs directly via pwsh, so it will still fire; but POSIX users will see no behavior.
Add an entry under the matching event. The event name must be one of the real Claude Code events: PreToolUse, PostToolUse, UserPromptSubmit, Notification, Stop, SubagentStop, SessionStart, SessionEnd, PreCompact — anything else fails validation.
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "sh \"${CLAUDE_PLUGIN_ROOT}/hooks/dispatch.sh\" <name> || pwsh -NoProfile -File \"${CLAUDE_PLUGIN_ROOT}/hooks/<name>.ps1\"",
"timeout": 10
}
]
}
]
args and NO shell field (pinning a shell would defeat the platform fallback). The || pwsh arm fires only when sh cannot spawn (Windows without Git Bash); on every other path dispatch.sh routes and exits 0.hooks object — the structure is { "hooks": { "Stop": [...], "PostToolUse": [...] } }.matcher is a regex over tool names for tool events (omit it for Stop/SessionStart-style events).${CLAUDE_PLUGIN_ROOT} as the path prefix — Claude Code substitutes it at runtime to the installed plugin root.timeout in seconds (10 for advisory, 15 for git-inspecting gates).hooks array instead of adding a duplicate matcher block.The pwsh harness (tests/hooks.test.ps1) is plain pwsh (no Pester): it builds a throwaway git repo and an isolated CLAUDE_STATE_DIR, pipes synthetic stdin JSON to each script via Invoke-Hook, and asserts on output and exit code. Add a Write-Host "<name>.ps1" section with at minimum:
Invoke-Hook '<name>.ps1' 'not json' must exit 0.Mirror the same cases in the POSIX harness (tests/hooks.test.sh): open a new section, pipe the synthetic payload straight into the script (printf '%s' "$payload" | sh hooks/<name>.sh), and use its assert_* helpers. If the hook writes state files, also add a fixture to tests/hooks-equivalence.test.sh — both implementations must produce byte-identical files and stdout.
Run: pwsh -NoProfile -File tests/hooks.test.ps1 and bash tests/hooks.test.sh — exit 0 from each means all assertions passed.
Run bash scripts/validate-hooks.sh. It enforces pair parity and must pass:
hooks/hooks.json has BOTH hooks/<name>.ps1 and hooks/<name>.sh on disk,hooks/*.ps1 and hooks/*.sh on disk is registered (no orphans on either side; dispatch.sh excluded),hooks/dispatch.sh exists and every registered chain references it,.ps1 pins PowerShell 7; every .sh starts with #!/bin/sh and sets set -u,The same checks run inside bash scripts/validate-consistency.sh (the full check battery) and in CI, so an unregistered or orphaned hook fails the build. The validator also parses dispatch.sh's name allowlist (rule j in scripts/lib/hookcheck.sh): a registered hook name missing from the case pattern fails as missing-dispatch-allowlist. Run the full battery too if you touched anything beyond hooks/ and hooks/hooks.json.
The hook is automatically deployed when the agentic-framework plugin is updated or reinstalled. Restart any running Claude Code session to pick up the new hook, or:
/plugin uninstall agentic-framework
/plugin install agentic-framework@agentic-framework
# then restart Claude Code
An advisory PostToolUse hook that reminds, once per session, to run the consistency battery after an agent definition is edited. Implemented as a pair.
hooks/posttooluse-agent-edit-hint.ps1:
#Requires -Version 7.0
# posttooluse-agent-edit-hint.ps1 — advisory PostToolUse hook (matcher: Write|Edit).
# After a file under agents/ is modified, reminds (once per session) to run the
# consistency validation. Never blocks; fail-open: any error => exit 0, no output.
try {
$payload = [Console]::In.ReadToEnd() | ConvertFrom-Json -ErrorAction Stop
$filePath = [string]($payload.tool_input.file_path ?? '')
if ($filePath -notmatch '[\\/]agents[\\/][^\\/]+\.md$') { exit 0 }
$sessionId = ([string]$payload.session_id) -replace '[^\w\-.]', ''
if (-not $sessionId) { exit 0 }
$stateRoot = $env:CLAUDE_STATE_DIR
if (-not $stateRoot) { $stateRoot = Join-Path $HOME '.claude/.state' }
$hintDir = Join-Path $stateRoot 'agent-edit-hints'
$seen = Join-Path $hintDir $sessionId
if (Test-Path $seen) { exit 0 }
New-Item -ItemType Directory -Force -Path $hintDir | Out-Null
New-Item -ItemType File -Force -Path $seen | Out-Null
@{
suppressOutput = $true
systemMessage = '[agent-edit-hint] Agent definition modified - run bash scripts/validate-consistency.sh before committing.'
} | ConvertTo-Json -Compress
exit 0
} catch {
exit 0
}
hooks/posttooluse-agent-edit-hint.sh (POSIX shell twin — same logic, POSIX-only):
#!/bin/sh
set -u
# posttooluse-agent-edit-hint.sh — advisory PostToolUse hook (matcher: Write|Edit).
# After a file under agents/ is modified, reminds (once per session) to run the
# consistency validation. Never blocks; fail-open: any error => exit 0, no output.
trap 'exit 0' EXIT INT TERM
payload=$(cat)
file_path=$(printf "%s" "$payload" | jq -r '.tool_input.file_path // ""')
if ! printf "%s" "$file_path" | grep -qE '.*/agents/[^/]+\.md$'; then
exit 0
fi
session_id=$(printf "%s" "$payload" | jq -r '.session_id // ""' | sed 's/[^-._[:alnum:]]//g')
if [ -z "$session_id" ]; then
exit 0
fi
state_root="${CLAUDE_STATE_DIR:=$HOME/.claude/.state}"
hint_dir="$state_root/agent-edit-hints"
seen="$hint_dir/$session_id"
if [ -f "$seen" ]; then
exit 0
fi
mkdir -p "$hint_dir"
touch "$seen"
printf '%s\n' \
'{"suppressOutput":true,"systemMessage":"[agent-edit-hint] Agent definition modified - run bash scripts/validate-consistency.sh before committing."}' | jq -c .
exit 0
Registration — add to hooks/hooks.json under PostToolUse:
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "sh \"${CLAUDE_PLUGIN_ROOT}/hooks/dispatch.sh\" posttooluse-agent-edit-hint || pwsh -NoProfile -File \"${CLAUDE_PLUGIN_ROOT}/hooks/posttooluse-agent-edit-hint.ps1\"",
"timeout": 10
}
]
}
Also add the name to the case statement in hooks/dispatch.sh:
case "$hook" in
stop-peer-review-gate|record-subagent-run|session-start-context|pretooluse-delegation-hint|pretooluse-model-guard|pretooluse-code-review-gate|posttooluse-agent-edit-hint) ;;
*) exit 0 ;;
esac
Tests — add to tests/hooks.test.ps1:
Write-Host "posttooluse-agent-edit-hint.ps1"
$r = Invoke-Hook 'posttooluse-agent-edit-hint.ps1' (New-Payload @{ session_id = 'e1'; tool_name = 'Edit'; tool_input = @{ file_path = 'D:/repo/agents/rust-expert.md' } })
Assert 'hints on agent file edit' ($r.Code -eq 0 -and $r.Out -match 'validate-consistency' -and $r.Out -match '"systemMessage"')
$r = Invoke-Hook 'posttooluse-agent-edit-hint.ps1' (New-Payload @{ session_id = 'e1'; tool_name = 'Edit'; tool_input = @{ file_path = 'D:/repo/agents/go-expert.md' } })
Assert 'hints at most once per session' ($r.Code -eq 0 -and -not $r.Out)
$r = Invoke-Hook 'posttooluse-agent-edit-hint.ps1' (New-Payload @{ session_id = 'e2'; tool_name = 'Edit'; tool_input = @{ file_path = 'D:/repo/README.md' } })
Assert 'silent for non-agent files' ($r.Code -eq 0 -and -not $r.Out)
$r = Invoke-Hook 'posttooluse-agent-edit-hint.ps1' 'not json'
Assert 'fail-open on malformed stdin' ($r.Code -eq 0)
And add to tests/hooks.test.sh (the harness sets RUN_OUT/RUN_RC and provides section + assert_* helpers; hooks are invoked by piping the payload straight into the script):
section "posttooluse-agent-edit-hint.sh"
payload=$(jq -cn '{session_id:"e1", tool_name:"Edit", tool_input:{file_path:"/repo/agents/rust-expert.md"}}')
RUN_OUT="$(printf '%s' "$payload" | sh "$SRC_REPO/hooks/posttooluse-agent-edit-hint.sh" 2>&1)"; RUN_RC=$?
assert_rc_zero "hints on agent file edit"
assert_out_contains "emits the reminder" "validate-consistency"
assert_out_contains "advisory shape" "systemMessage"
payload=$(jq -cn '{session_id:"e1", tool_name:"Edit", tool_input:{file_path:"/repo/agents/go-expert.md"}}')
RUN_OUT="$(printf '%s' "$payload" | sh "$SRC_REPO/hooks/posttooluse-agent-edit-hint.sh" 2>&1)"; RUN_RC=$?
assert_rc_zero "second edit same session exits 0"
assert_out_empty "hints at most once per session"
payload=$(jq -cn '{session_id:"e2", tool_name:"Edit", tool_input:{file_path:"/repo/README.md"}}')
RUN_OUT="$(printf '%s' "$payload" | sh "$SRC_REPO/hooks/posttooluse-agent-edit-hint.sh" 2>&1)"; RUN_RC=$?
assert_rc_zero "non-agent file exits 0"
assert_out_empty "silent for non-agent files"
RUN_OUT="$(printf '%s' 'not json' | sh "$SRC_REPO/hooks/posttooluse-agent-edit-hint.sh" 2>&1)"; RUN_RC=$?
assert_rc_zero "fail-open on malformed stdin"
Then run both test suites:
pwsh -NoProfile -File tests/hooks.test.ps1
bash tests/hooks.test.sh
And validate:
bash scripts/validate-hooks.sh
The hook is automatically deployed when the agentic-framework plugin is updated or reinstalled — restart Claude Code to load it.
.ps1 script in hooks/ pins PS7, reads stdin JSON, fails open, exits 0 on every path..sh script in hooks/ starts with #!/bin/sh, has set -u, reads stdin, fails open, identical output to .ps1.hooks/dispatch.sh case statement allowlist.hooks/hooks.json under a valid event with matcher and timeout, using sh dispatch.sh invocation (using ${CLAUDE_PLUGIN_ROOT}).tests/hooks.test.ps1 AND tests/hooks.test.sh; both harnesses pass.tests/hooks-equivalence.test.sh if the hook writes state files.bash scripts/validate-hooks.sh passes (pair parity, dispatch presence + chain reference, dispatch allowlist membership, events, PS7/sh pin, no deprecated names).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub tomas-rampas/agentic-framework --plugin agentic-framework11 skills in this plugin
/agent-debuggerDiagnose and fix agent routing, loading, and configuration issues by inspecting agents/*.md frontmatter, the claude.json registry, hook registration, and validator output — use when an agent is "not found", tasks route to the wrong specialist, models mismatch, hooks do not fire, or validate-consistency.sh fails./agent-routing-advisorRecommends which framework agent (or multi-agent workflow) should handle a task; use when the user asks which agent to use, how to delegate a piece of work, or how to sequence agents for a multi-domain task./code-reviewReview a PR (pull request), a branch, a diff, or a set of files with a structured 3-pass method (architecture, logic, expressiveness), five questions in pass 2, a Chesterton's Fence provenance check, and ICE-prefixed findings under a summary-first report. Use when asked to review, critique, or evaluate code changes./code-scaffolderGenerate idiomatic project scaffolding, config files, and boilerplate per language — use when starting a new project, adding a service, or bootstrapping a library/package (e.g. "scaffold a Rust CLI", "set up a new FastAPI project")./code-scoring-loopIteratively improve a pending (uncommitted) code change by having the matching specialist agent score the diff 0-100 against an explicit rubric, rewriting the weakest parts, and repeating until the score plateaus. Use after the quality bar is green (build/lint/format/tests clean) but before the review gates — e.g. polishing an implementation or refactor, or when asked to "clean up" uncommitted code without concrete criteria. Code-side sibling of self-scoring-loop./dependency-checkerVerify the framework's toolchain (git, bash, jq, gh, yq, PowerShell 7+, Node.js/npx, uv/uvx, shellcheck, Claude Code CLI) is installed and working — use when setting up the framework, after system updates, or when hooks, validators, MCP servers, or the executor agents fail with "command not found".Other plugins' skills for the same job