Предотвратите вставку приватного ключа в Claude Code с помощью UserPromptSubmit хука
DEV · 18.11.2026 · 00:54
Правила отказа и защитные механизмы защищают файлы на диске, но не предотвращают вставку приватных ключей или токенов в сам запрос. Хук UserPromptSubmit может перехватить такие данные до…
Оригинал
Stop yourself from pasting a private key into Claude Code with a UserPromptSubmit hook
Deny rules and write guards protect files on disk. They do nothing if you paste a private key, seed phrase, or API token into the prompt itself. A UserPromptSubmit hook can catch that shape before the model ever sees it. The hook Save this as .claude/hooks/block-secret-prompts.sh and make it executable (chmod +x): #!/usr/bin/env bash # Reads the hook event as JSON on stdin; exit code 2 blocks the prompt. text=$(jq -r '.prompt // .user_prompt // .content // empty') if echo "$text"