Developer adds a UserPromptSubmit hook to block secrets in Claude Code prompts
11/18/2026 — 11/18, 09:15·1 sources (all)·1 reports (all)
Key takeaways
- A developer shared a UserPromptSubmit hook for Claude Code that scans prompts before they reach the model and blocks anything matching priva…
Background & analysis
On November 18, 2026, at 08:54, the AI section of DEV Community published a developer write-up describing a UserPromptSubmit hook for Claude Code that detects and blocks sensitive content before a prompt is handed to the model. According to the article, deny rules and write guards that protect files on disk do nothing when a user pastes a private key, a seed phrase, or an API token directly into the prompt itself, and the hook is meant to catch that pattern before the model ever sees it.
The proposed implementation is a shell script saved as .claude/hooks/block-secret-prompts.sh and made executable. Reading the hook event as JSON on stdin, the script extracts the prompt text and runs a regular expression check for the format of private keys, seed phrases, or API tokens. When the pattern matches, the script refuses the prompt by exiting with code 2. The stated effect is that blocked sensitive content never reaches the model and never ends up in the session record. Setup consists of writing the relevant configuration into .claude/settings.json, after which the hook takes effect.
The article is the only report available so far, and no follow-up developments, independent verifications, or competing accounts have been published yet. The approach therefore remains at the stage of a single developer-shared configuration, with no broader adoption or review records to report.
AI-generated from 1 reports · updated 25 minutes ago
Related AI tools
- Heat index
- 98
- All sources
- 1
- All reports
- 1
- First seen
- 49 minutes ago
Reports on this story headlines open the original
A developer shared a Claude Code UserPromptSubmit hook that scans prompts for private keys, seed phrases, and API tokens before the model sees them. The hook exits with code 2 to reject the prompt, so the pasted secret never reaches the model or the transcript; registration goes in .claude/settings.json.
DEV Community · AIAI score 54
Other stories people are talking about
- Heat index 64Developer Shares Workflow for Dual-Agent Development with Claude Code and Codex1 sources
- Heat index 70Developer shares automated YouTube workflow built with Claude Code1 sources
- Heat index 98NewDeveloper lays out starter experiments for five AI dev topics including Claude Code1 sources
- Heat index 140Claude Code team says Claude writes about 90% of new code2 sources
- Heat index 102T3 Code Enables Mobile-Based Remote Scheduling of Claude Code2 sources
How is heat calculated?About the methodHide
Heat counts how many independent sources covered a story in the last 48 hours: one source counts once no matter how many posts it published, decaying with a 24-hour half-life. What ranks first is what many people are talking about.
This page aggregates public feeds. Headlines and summaries are machine-organized and remain the property of the original authors; verify important facts at the source. If you believe a headline or summary infringes your rights, email the contact address in the footer with the page URL and basis of your claim, and we will remove or replace it after review.
- Surge
- Discussion rising fast
- New
- First report within 6 hours
- Rising
- Still gathering discussion

