HaiAI123

Curated Global AI Tools Directory

Industry update
Flat

PreToolUse hook stops Claude Code from publishing packages

12/04/2026 — 12/04, 09:16·1 sources (all)·1 reports (all)

Key takeaways

  • A developer notes that write protection keeps Claude Code away from .env files but not from running npm publish or cargo publish mid-session…

Background & analysis

On December 4, 2026, a DEV Community post described how to stop Claude Code from publishing packages on its own during a session by using a PreToolUse hook. The author notes that a write guard can keep Claude Code away from .env files, but it will not stop a confident npm publish or cargo publish mid-session. Package registries do not ask for confirmation the way git remotes sometimes do, and a model that has just "finished the fix" may treat a publish as the obvious last step.

The proposed fix is a small hook: save the script as .claude/hooks/block_package_publish.py, have it name the command class it targets and exit 2, then attach it to the Bash tool under PreToolUse in settings.json. That way a release stays a human decision. The post does not say how well the approach works in practice or how broadly it applies.

AI-generated from 1 reports · updated 2 days ago

Related AI tools

updream
24-hour heatHeat index 33 · peak 67 · 23h ago
24 hours agonow

Reports on this story headlines open the original

Yesterday
  1. A write guard keeps Claude Code away from .env files but will not stop the model from running npm publish or cargo publish mid-session. The author's fix is a small PreToolUse hook saved as .claude/hooks/block_package_publish.py that exits with code 2 for those command classes and is wired to the Bash tool in settings.json, keeping releases a human decision.

    DEV Community · AIAI score 64

Other stories people are talking about

How is heat calculated?About the method

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

Back to AI industry updates →