bash-guard.en — правило для Claude Code: что делает и как установить
Правило bash-guard.en для Claude Code запрещает опасные команды терминала и настраивает таймауты фоновых задач.
Apache-2.0 ★ 262 обновлён 2026-11-17
.claude/rules/bash-guard.en.mdЧто делает bash-guard.en
Правило ограничивает выполнение команд bash в среде ИИ-агентов. Оно блокирует pkill -f, фоновые циклы ожидания и sleep, требуя использовать таймауты и фоновые процессы с метками вроде # long-running-ok.
Для подзапросов Claude Code команды дольше 290 секунд автоматически уходят в фон. Загрузки через сеть направляются через прокси при установленной переменной HOOK_PROXY, а для прямых скачиваний требуется метка # direct-ok.
Перед слиянием пул-реквеста проверяются записи верификации, а тестовые сообщения не отправляются в командные чаты.
Какие задачи решает
- предотвратить завершение рабочей оболочки через
pkill -f - ограничить время выполнения фоновых команд таймаутами
- заблокировать циклы опроса через
sleepиgh watch - направить сетевые загрузки через корпоративный прокси
Примеры запросов агенту
- Запусти фоновую сборку проекта с таймаутом и меткой
- Проверь команду bash на соответствие правилам безопасности
- Настрой выполнение долгих тестов в фоновом режиме
Как установить bash-guard.en
Вручную: положить файлы
.claude/rules/bash-guard.en.mdПоле paths во frontmatter ограничивает файлы
AGENTS.md
Codex читает AGENTS.md: вставьте текст правила туда
Вручную: положить файлы
.cursor/rules/bash-guard.en.mdcВо frontmatter: description, globs, alwaysApply
Вручную: положить файлы
.github/instructions/bash-guard.en.instructions.mdПоле applyTo задаёт, к каким файлам применять
Вручную: положить файлы
.devin/rules/bash-guard.en.mdВручную: положить файлы
.clinerules/bash-guard.en.mdПо шагам, с командами для каждой платформы: AGENTS.md и CLAUDE.md: что это, кто читает и какой выбрать
Вопросы о bash-guard.en
Как установить bash-guard.en в Claude Code?
Сохраните файл правила в .claude/rules/bash-guard.en.md.
Что делает bash-guard.en?
Правило запрещает опасные вызовы терминала, управляет таймаутами долгих команд и блокирует бесконечные циклы ожидания у агентов.
Что нужно для работы bash-guard.en?
Для работы требуется поддерживаемая среда разработки вроде Claude Code, Cursor или Windsurf.
Исходный текст
bash-guard.en.md · Apache-2.0
- Commands (bash-guard): no `pkill -f` (it kills the shell running it); use `kill $(pgrep -f '[x]yz')` or a pid file. Background commands need a timeout (`timeout <s> <cmd>`; on macOS `perl -e 'alarm shift; exec @ARGV' <s> <cmd>`) and no `| tail`/`| head`; end a long-running service with `# long-running-ok`. With HOOK_PROXY set, downloads go through the proxy; add `# direct-ok` when a direct download is really needed. - Reject foreground gh watch, sleep >=60 seconds and sleep polling loops. DSH also rejects any foreground sleep, repeated polls/read-only commands and a fourth sequential single read-only step. Batched reads, child sessions and outing turns have scoped exemptions. DSH network installs/fetches require a timed background task. Missing session history never fabricates counts. - A Claude Code subagent's foreground command with a timeout over 290 seconds gets it cut to 290 seconds (a subagent's prompt cache lasts 5 minutes); what does not finish moves to the background by itself. Do not poll it then: deliver with the log path and the next step. Dispatch work that waits 5–60 minutes to a long-task subagent (1-hour cache, not capped). A while … sleep loop inside perl/python counts as polling too. - In the main session a foreground remote, install/download, CI or build/test command with a timeout over 5 minutes is capped to 290 seconds and moves to the background if it runs longer; start such commands in the background. A test command piped into `tail/head` gets `set -o pipefail` added: judge by the exit code. - `for … sleep … break` polling and `caffeinate -w` also count as waiting in the foreground. Before a PR merge, merge-gate checks the recorded real-entry verification; no test messages go to the team chat channels on the list. - Other CLIs do not inherit the Claude long-task cache policy. Start work expected to exceed five minutes in the native background, report its log/task ID, and end the turn: DSH run_in_background (timeoutMs can promote to background), Grok block_until_ms=0, Gemini is_background, or the session ID returned by Codex exec_command. Do not poll with wait/sleep. DSH child timeouts above 290000 ms are denied with capped retry arguments; Grok child block_until_ms is capped at 290000.
© zuiho-kai · Apache-2.0 · zuiho-kai/bothouse