guard-pack — плагин для Claude Code: что делает и как установить
Плагин guard-pack для Claude Code запускает семь защитных хуков в одном процессе Node. Первый блокирующий вердикт останавливает цепочку.
MIT ★ 586 обновлён 2026-10-26
/plugin marketplace add karanb192/claude-code-hooks
/plugin install guard-pack@claude-code-hooksЧто делает guard-pack
Одна регистрация PreToolUse на Bash, Read, Edit, MultiEdit, Write, Agent, Task и Grep прогоняет семь гардов по очереди: subagent-spawn-cap, config-guard, block-dangerous-commands, protect-secrets, protect-tests, git-safety, case-insensitive-guard. Первый блокирующий вердикт останавливает проверку и выдаётся в формате своего гарда с пометкой (via guard-pack).
Смысл в одном запуске Node вместо семи: в замере авторов пакет даёт 38 мс медианы против 199 мс у шести паттерн-гардов по отдельности. Скрипты в lib/ — побайтовые копии одиночных плагинов, совпадение закреплено тестом. Упавший гард пишется в лог и пропускается, остальные продолжают работать.
Ставить пакет вместе с отдельными плагинами-гардами нельзя: каждый дубль отработает дважды, с двойной задержкой и двойными отказами, а бюджет спавнов посчитается дважды. Своих настроек у пакета нет, переменные окружения гардов читаются напрямую. HOOK_SAFETY_LEVEL действует на шесть паттерн-гардов сразу, SPAWN_CAP_ASK по умолчанию 20, SPAWN_CAP_DENY 60. В неинтерактивном прогоне (-p или dontAsk) спросить некого, поэтому порог ask работает как жёсткий стоп.
Какие задачи решает
- закрыть одной установкой сразу семь защитных гардов
- убрать шесть лишних запусков Node с каждого подходящего вызова инструмента
- не дать субагентам расплодиться сверх лимита за сессию
- запретить опасные команды и правку секретов до выполнения
- видеть в логе вердикт каждого гарда отдельной строкой
Примеры запросов агенту
- Запусти по субагенту на каждый модуль и сведи их отчёты.
- Поправь
.envи закоммить вместе с остальными файлами. - Покажи, какой гард отклонил последний вызов и почему — нужна строка из
~/.claude/hooks-logs/.
Как установить guard-pack
Через маркетплейс плагинов
/plugin marketplace add karanb192/claude-code-hooks/plugin install guard-pack@claude-code-hooksПо шагам, с командами для каждой платформы: Плагины Claude Code: маркетплейсы, установка и как собрать свой
Вопросы о guard-pack
Как установить guard-pack в Claude Code?
Сначала добавьте маркетплейс: /plugin marketplace add karanb192/claude-code-hooks. Потом поставьте плагин: /plugin install guard-pack@claude-code-hooks. Дальше перезапустите Claude.
Что делает guard-pack?
Собирает семь защитных хуков в одном процессе Node и вешает их на одну регистрацию PreToolUse. Первый блокирующий вердикт останавливает цепочку, остальные гарды уже не запускаются.
Можно ли держать guard-pack рядом с отдельными плагинами-гардами?
Нет. Дублирующийся гард отработает дважды: задержка и отказы удвоятся, а бюджет спавнов посчитается дважды. Нужен либо пакет, либо одиночные плагины.
Исходный текст
guard-pack · MIT
# guard-pack > All seven guard hooks in one Node process. Installing them individually costs seven Node startups per matching tool call; the pack pays one. Measured ([bench/RESULTS.md](../../bench/RESULTS.md)): 38 ms median for the pack vs 199 ms for the six pattern guards separately on the same machine, before the spawn cap joined. One PreToolUse registration on `Bash|Read|Edit|MultiEdit|Write|Agent|Task|Grep` evaluates, in order: [subagent-spawn-cap](../subagent-spawn-cap), [config-guard](../config-guard), [block-dangerous-commands](../block-dangerous-commands), [protect-secrets](../protect-secrets), [protect-tests](../protect-tests), [git-safety](../git-safety), [case-insensitive-guard](../case-insensitive-guard). The spawn cap goes first because its filter is one cached module load and a single tool-name compare and, on an `Agent` call, it is the only guard that applies; after it, cheap string checks run before the guards that touch the filesystem or spawn git. The first blocking verdict wins and is emitted in that guard's own format (same emoji, same `[id]`, same reason text) with a `(via guard-pack)` suffix. A guard that throws is logged and skipped, so one broken guard can never switch off the other six. The guard scripts in `lib/` are byte-identical copies of the individual plugin scripts, pinned by a test, so the pack can never drift from the standalone guards. `Grep` reaches protect-secrets through the same checks as the standalone plugin, including Windows paths and directory/filter combinations. Its [search limitations](../protect-secrets#search-and-windows-coverage) also apply here; broad searches can still expose secrets. ## Install ``` /plugin marketplace add karanb192/claude-code-hooks /plugin install guard-pack@claude-code-hooks ``` Restart Claude Code, done. **Do not install the pack alongside the individual guard plugins** (or a manual `settings.json` registration of any of the seven): every duplicated guard runs twice on each matching tool call, with double latency, double denials, and for the spawn cap a double-counted budget. Pick one or the other. ## Configuration The pack adds no configuration of its own; the guards' env vars pass straight through because the modules read them directly: - `HOOK_SAFETY_LEVEL` = `critical` | `high` | `strict`: applies to the six pattern guards uniformly (each falls back to its own default on an invalid value). Want different levels per guard? Install the individual guard plugins instead. `subagent-spawn-cap` does not read it; see its own knobs below. - `HOOK_ASK_CRITICAL` / `HOOK_ASK_HIGH` / `HOOK_ASK_STRICT` = `true`: ask instead of deny, for the guards that support ask mode (config-guard, block-dangerous-commands, protect-secrets, case-insensitive-guard). protect-tests and git-safety always deny. - `CONFIG_GUARD_ALLOW` = `true`: skips config-guard for an intentional, human-approved config edit. The other six guards still run. - `SPAWN_CAP_ASK` (default 20) / `SPAWN_CAP_ASK_STEP` (default 10) / `SPAWN_CAP_DENY` (default 60): per session, the pack asks at spawn 20 and every 10 after that (30, 40, 50) and denies at 60. `SPAWN_CAP_ALLOW` = `true` lets spawns through for as long as it is set; each is still counted and logged `ALLOW_OVERRIDE`. Unattended (`-p` or `dontAsk`) runs cannot answer an ask, so there the ask threshold is the hard stop: set `SPAWN_CAP_ASK` equal to `SPAWN_CAP_DENY` for those. Details in the [subagent-spawn-cap README](../subagent-spawn-cap). ## What gets recorded One line per verdict in `~/.claude/hooks-logs/` (guard name, rule id, decision, tool; for the spawn cap also the count and thresholds). The spawn cap writes its own `ALLOW_OVERRIDE` and clamp `WARN` lines on the pack path too, and keeps its per-session ledger under `~/.claude/subagent-spawn-cap/`. The pack makes no network calls; everything stays on your machine.
© Karan Bansal · MIT · karanb192/claude-code-hooks