agent-hooks
БесплатноЗапускает вложенные скриптыНе проверенManage shell hooks — user scripts that run at agent lifecycle points to block, rewrite, or warn on actions, via the /hooks command.
от Starchild-ai-agent★ 34 звезды на GitHubОб этом скилле
Agent Hooks
Shell hooks let a user run their own script at fixed points in the agent's lifecycle — to block a dangerous action, rewrite an input or an outbound message, inject context into the model, or warn the user. The script can be written in any language; it talks to the agent over a simple JSON-on-stdin, JSON-on-stdout protocol.
Tools: read_file, write_file, bash
When to use
Reach for hooks when the user wants the agent to automatically enforce a rule or react to an event without being asked each time. Examples:
- "Stop me from running
rm -rf/ destructive bash" →pre_tool_callblock - "Never let a private key get pushed to Telegram" →
on_outbound_messageblock - "Log every tool call for audit" →
post_tool_callobserve - "Remind the agent of X at the start of every model call" →
pre_llm_callcontext - "Don't let the agent claim it published when it didn't" →
on_completion_claim(in/goal) oron_stop(in normal chat) - "If the answer fails my quality check, make the agent redo it" →
on_stopblock
If the user just wants a one-off check, that's not a hook — hooks are for recurring, automatic lifecycle enforcement.
How configuration works (the agent does it end-to-end)
The agent installs and activates a hook with zero user copy-paste. Write the script, write the config entry, then call the loopback self-approve API — it flips the master switch on, approves the script for every event it's wired to, and hot-mounts it live (no restart). The user just tests it afterward.
curl -s -X POST http://localhost:8000/internal/runtime/hooks/approve \
-H 'Content-Type: application/json' \
-d '{"command": "/data/workspace/hooks/security_guard.py"}'
# -> {"ok": true, "events": [...], "mounted": N, "master_enabled": true}
⚠️ ALWAYS use an absolute path under
/data/workspacein both the yamlcommand:and this call. Never a relative path likeskills/agent-hooks/templates/security_guard.py: the bridge spawns the script with the server cwd (/app), so a relative path resolves to/app/skills/…— an empty dir — and every spawn fails. Because the bridge fails OPEN (a script it can't run = "continue"), the guard then silently protects nothing while/hooks liststill shows it "mounted". To avoid this, the standard install copies the template into/data/workspace/hooks/and points the yaml there (see the workflow below)./app/skillsis NOT the skills dir — the real one is/data/workspace/skills/(a.k.a./app/workspace/skills/via symlink).
commandMUST be the exactcommand:string from theshell_hooks.yamlentry (the absolute script path). The hook MUST already be declared in the yaml — approval flips a declared hook to live, it can't conjure one out of thin air.- The endpoint is loopback-only (same-uid-in-container trust boundary, same
as
.envreads). It auto-enables the master switch (enable_masterdefaults true), so the hook fires immediately. - Approval records the script's mtime, so a later edit surfaces as drift in
/hooks list//hooks doctor— a swap-the-script change stays visible.
This is the whole activation story for the user — there isn't a second step.
After the call returns {"ok": true}, tell them it's live and to test it. Do not
mention /hooks approve, /hooks on, or "two gates" — those are internal.
Fallback (older builds only): if the curl returns 404, this runtime
predates the self-approve API — only then fall back to asking the user to paste
/hooks approve <command> then /hooks on.
The two gates (both handled by the self-approve API — you don't surface them)
Internally a hook fires only when BOTH hold; the self-approve call above flips both in one shot, so the user never sees or types either:
- Master switch ON —
shell_hooks.enabled: trueinworkspace/config/agent.yaml. The API auto-enables it (enable_masterdefaults true). - Per-hook approval — the
(event, command)pair is recorded in the allowlist with the script's mtime (so a later edit shows as "changed since approval" drift — a swapped script stays visible). The API approves every event the command is wired to.
These exist as a security boundary, not as a user step. Do NOT mention "approve"
or "two gates" when explaining hooks to a user — just say you'll set it up and
they can test it. (Manual /hooks on + /hooks approve exist only as the 404
fallback for older runtimes.)
The /hooks command
Plain text on web / Telegram / WeChat (no LLM, no cost):
| Command | What it does |
|---|---|
/hooks or /hooks list |
master switch state, config path, every hook + approval/health |
/hooks on | /hooks off |
flip the master switch (hot mount/unmount, no restart) |
/hooks doctor |
run each approved hook against a synthetic payload, check JSON |
/hooks approve <event> <command> |
approve + activate live (n |
Установить agent-hooks в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл agent-hooks?
Manage shell hooks — user scripts that run at agent lifecycle points to block, rewrite, or warn on actions, via the /hooks command.
Как установить скилл agent-hooks?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл agent-hooks запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic