Prevent Accidental npm publish

Claude Code can run npm publish during a refactoring session, pushing half-finished code to the public npm registry. In Auto Mode, there's no confirmation prompt.

The Fix

The npm-publish-guard hook (included by default in cc-safe-setup) blocks all publish commands:

# Blocks: npm publish, npm publish --tag, yarn publish, pnpm publish
npx cc-safe-setup

Also blocks: cargo publish, gem push, twine upload, pip publish. Each has a dedicated guard hook.

Allow Dry-Run

The hook allows npm publish --dry-run — you can test without actually publishing.

Package Manager Coverage

EcosystemHookBlocks
npm/yarn/pnpmnpm-publish-guardnpm publish
Rustcargo-publish-guardcargo publish
Pythonpip-publish-guardtwine upload
Rubygem-push-guardgem push
PHPcomposer-guardcomposer global require

Block All Publish Commands

npx cc-safe-setup

npm-publish-guard included by default. 667 hooks total.

cc-safe-setup · GitHub