cc-safe-setup 29.8.0 → 30.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +72 -19
- package/.claude-plugin/plugin.json +1 -1
- package/CONTRIBUTING.md +7 -2
- package/COOKBOOK.md +50 -46
- package/LICENSE +21 -0
- package/MIGRATION.md +8 -8
- package/README.md +419 -512
- package/SAFETY_CHECKLIST.md +15 -7
- package/SERVICES.md +194 -0
- package/SETTINGS_REFERENCE.md +236 -17
- package/SKILL.md +5 -5
- package/TROUBLESHOOTING.md +35 -14
- package/action.yml +12 -4
- package/audit/README.md +84 -0
- package/audit/audit-checklist.md +152 -0
- package/audit/boundary-selftest.sh +85 -0
- package/audit/boundary.sh +123 -0
- package/audit/count-hooks.py +42 -0
- package/audit/find-dead-hooks.sh +82 -0
- package/audit/find-unfirable-rules.sh +142 -0
- package/audit/fire.sh +97 -0
- package/audit/selftest.sh +42 -0
- package/audit/unfirable-selftest.sh +81 -0
- package/audit-web/index.html +9 -9
- package/examples/README.md +54 -17
- package/examples/account-billing-log.sh +98 -0
- package/examples/account-routing-preflight.sh +123 -0
- package/examples/agent-sdk-credit-pool-monitor.sh +145 -0
- package/examples/agent-view-quota-decrement.sh +32 -0
- package/examples/agent-view-quota-warn.sh +94 -0
- package/examples/agents-md-edit-drift-warner.sh +223 -0
- package/examples/agents-md-loader.sh +160 -0
- package/examples/agents-md-sync-checker.sh +102 -0
- package/examples/ai-slop-punctuation-arrest.sh +210 -0
- package/examples/allowlist.sh +70 -10
- package/examples/always-allow-pattern-suggester.sh +125 -0
- package/examples/ansible-vault-guard.sh +2 -1
- package/examples/anthropic-base-url-guard.sh +76 -0
- package/examples/api-busyloop-guard.sh +123 -0
- package/examples/api-endpoint-guard.sh +12 -0
- package/examples/api-key-in-url-guard.sh +17 -1
- package/examples/api-rate-limit-guard.sh +36 -1
- package/examples/api-rate-limit-tracker.sh +12 -0
- package/examples/articulated-scope-capture.sh +101 -0
- package/examples/askuserquestion-autonomy-gate.sh +102 -0
- package/examples/attachment-traversal-guard.sh +118 -0
- package/examples/aup-block-pattern-logger.sh +161 -0
- package/examples/aup-false-positive-helper.sh +124 -0
- package/examples/aup-large-tool-output-warner.sh +282 -0
- package/examples/aup-retry-loop-guard.sh +229 -0
- package/examples/auth-expiry-reminder.sh +157 -0
- package/examples/auth-macos-sleep-detector.sh +185 -0
- package/examples/auth-path-detector.sh +171 -0
- package/examples/auth-status-checker.sh +157 -0
- package/examples/authorized-reconfirmation-detector.sh +195 -0
- package/examples/auto-approve-build.sh +39 -0
- package/examples/auto-approve-cargo.sh +31 -1
- package/examples/auto-approve-docker.sh +35 -0
- package/examples/auto-approve-git-read.sh +37 -14
- package/examples/auto-approve-go.sh +30 -1
- package/examples/auto-approve-gradle.sh +29 -1
- package/examples/auto-approve-make.sh +29 -1
- package/examples/auto-approve-maven.sh +29 -1
- package/examples/auto-approve-python.sh +41 -1
- package/examples/auto-approve-readonly-tools.sh +1 -0
- package/examples/auto-approve-readonly.sh +110 -33
- package/examples/auto-approve-ssh.sh +30 -1
- package/examples/auto-approve-test.sh +44 -0
- package/examples/auto-checkpoint.sh +1 -1
- package/examples/auto-compact-prep.sh +0 -0
- package/examples/auto-git-checkpoint.sh +0 -0
- package/examples/auto-mode-safe-commands.sh +53 -1
- package/examples/auto-mode-safety-enforcer.sh +151 -4
- package/examples/auto-push-session-branch.sh +22 -0
- package/examples/aws-production-guard.sh +13 -1
- package/examples/aws-region-guard.sh +1 -1
- package/examples/background-cost-launch-guard.sh +82 -0
- package/examples/background-task-guard.sh +12 -0
- package/examples/backup-before-refactor.sh +0 -0
- package/examples/banned-command-guard.sh +12 -0
- package/examples/bash-allowlist-secondary-check.sh +157 -0
- package/examples/bash-domain-allowlist.sh +12 -0
- package/examples/bash-fanout-bounded-rewriter.sh +191 -0
- package/examples/bash-heuristic-approver.sh +112 -10
- package/examples/bash-project-fence.sh +194 -0
- package/examples/bash-safety-auto-deny.sh +12 -0
- package/examples/bash-secret-output-detector.sh +44 -3
- package/examples/bash-trace-guard.sh +12 -0
- package/examples/bashrc-safety-check.sh +0 -0
- package/examples/bg-permission-prompt-warner.sh +182 -0
- package/examples/bg-task-cooldown-guard.sh +12 -0
- package/examples/binary-read-detector.sh +135 -0
- package/examples/binary-upload-guard.sh +12 -0
- package/examples/block-database-wipe.sh +35 -10
- package/examples/branch-name-check.sh +8 -3
- package/examples/branch-naming-convention.sh +0 -0
- package/examples/broad-find-guard.sh +12 -0
- package/examples/broad-prefix-session-trap-warner.sh +106 -0
- package/examples/bulk-file-delete-guard.sh +45 -0
- package/examples/bypass-mode-effective-verifier.sh +203 -0
- package/examples/cache-creation-drift-detector.sh +120 -0
- package/examples/cache-residue-detector.sh +195 -0
- package/examples/cache-tier-logger.sh +70 -0
- package/examples/cache-ttl-eviction-detector.sh +149 -0
- package/examples/cargo-publish-guard.sh +14 -1
- package/examples/case-insensitive-path-guard.sh +21 -2
- package/examples/case-sensitive-guard.sh +23 -2
- package/examples/cch-cache-guard.sh +0 -0
- package/examples/cch-sentinel-precommit-guard.sh +47 -0
- package/examples/check-abort-controller.sh +1 -1
- package/examples/check-accessibility.sh +0 -0
- package/examples/check-aria-labels.sh +0 -0
- package/examples/check-before-act-enforcer.sh +12 -0
- package/examples/check-charset-meta.sh +0 -0
- package/examples/check-cookie-flags.sh +0 -0
- package/examples/check-cors-config.sh +0 -0
- package/examples/check-csp-headers.sh +0 -0
- package/examples/check-csrf-protection.sh +0 -0
- package/examples/check-debounce.sh +1 -1
- package/examples/check-dependency-age.sh +0 -0
- package/examples/check-dependency-license.sh +0 -0
- package/examples/check-dockerfile-best-practice.sh +0 -0
- package/examples/check-error-boundaries.sh +0 -0
- package/examples/check-error-class.sh +1 -1
- package/examples/check-error-handling.sh +0 -0
- package/examples/check-error-logging.sh +1 -1
- package/examples/check-error-message.sh +0 -0
- package/examples/check-error-stack.sh +0 -0
- package/examples/check-favicon.sh +0 -0
- package/examples/check-git-hooks-compat.sh +0 -0
- package/examples/check-gitattributes.sh +0 -0
- package/examples/check-https-redirect.sh +0 -0
- package/examples/check-input-validation.sh +0 -0
- package/examples/check-lang-attribute.sh +0 -0
- package/examples/check-npm-scripts-exist.sh +0 -0
- package/examples/check-package-size.sh +0 -0
- package/examples/check-port-availability.sh +0 -0
- package/examples/check-promise-all.sh +1 -1
- package/examples/check-rate-limiting.sh +0 -0
- package/examples/check-return-types.sh +0 -0
- package/examples/check-semantic-versioning.sh +0 -0
- package/examples/check-suspense-fallback.sh +1 -1
- package/examples/check-test-exists.sh +0 -0
- package/examples/check-test-naming.sh +0 -0
- package/examples/check-timeout-cleanup.sh +1 -1
- package/examples/check-tls-version.sh +0 -0
- package/examples/check-unsubscribe.sh +1 -1
- package/examples/check-viewport-meta.sh +0 -0
- package/examples/check-worker-terminate.sh +1 -1
- package/examples/checkpoint-tamper-guard.sh +12 -0
- package/examples/chmod-guard.sh +12 -0
- package/examples/chown-guard.sh +24 -0
- package/examples/ci-workflow-guard.sh +6 -1
- package/examples/claim-verify-detector.sh +109 -0
- package/examples/claim-vs-caveat-checker.sh +77 -0
- package/examples/classifier-fallback-allow.sh +114 -40
- package/examples/claude-cache-gc.sh +1 -0
- package/examples/claude-code-version-pin-advisor.sh +183 -0
- package/examples/claude-md-reinjector.sh +129 -0
- package/examples/claude-md-size-monitor.sh +66 -0
- package/examples/claude-update-budget-guard.sh +123 -0
- package/examples/claude-update-smart.sh +113 -0
- package/examples/claudeignore-enforce-guard.sh +12 -0
- package/examples/claudemd-enforcer.sh +0 -0
- package/examples/claudemd-tool-prohibition.sh +128 -0
- package/examples/clear-command-confirm-guard.sh +32 -15
- package/examples/cli-config-pinning-detector.sh +162 -0
- package/examples/cliff-countdown-advisor.sh +96 -0
- package/examples/clipboard-secret-guard.sh +12 -0
- package/examples/closure-word-verify-gate.sh +150 -0
- package/examples/cloud-cli-guard.sh +39 -2
- package/examples/commit-all-scope-guard.sh +44 -0
- package/examples/commit-message-check.sh +1 -1
- package/examples/commit-message-quality.sh +6 -1
- package/examples/commitment-carry-forward-arrest.sh +361 -0
- package/examples/compact-alert-notification.sh +0 -0
- package/examples/compact-dispatch-watchdog.sh +149 -0
- package/examples/completion-claim-without-verification-detector.sh +207 -0
- package/examples/composer-guard.sh +12 -0
- package/examples/compound-bash-permission-resolver.sh +156 -0
- package/examples/compound-command-allow.sh +1 -1
- package/examples/compound-command-deny-enforcer.sh +183 -0
- package/examples/compound-inject-guard.sh +12 -0
- package/examples/concurrent-edit-lock.sh +12 -0
- package/examples/conflict-marker-guard.sh +12 -0
- package/examples/consecutive-error-breaker.sh +0 -0
- package/examples/console-log-count.sh +1 -0
- package/examples/context-compact-advisor.sh +29 -2
- package/examples/context-length-budget.sh +69 -0
- package/examples/context-threshold-alert.sh +12 -0
- package/examples/context-usage-drift-alert.sh +41 -13
- package/examples/conversation-history-guard.sh +12 -0
- package/examples/core-file-protect-guard.sh +12 -0
- package/examples/cors-star-warn.sh +0 -0
- package/examples/cost-incident-self-audit.sh +162 -0
- package/examples/cowork-claude-md-load-checker.sh +100 -0
- package/examples/cowork-fuse-staleness-watcher.sh +140 -0
- package/examples/cowork-hook-absence-warner.sh +167 -0
- package/examples/cowork-model-picker-advisor.sh +115 -0
- package/examples/credential-exfil-guard.sh +65 -4
- package/examples/credential-file-cat-guard.sh +17 -1
- package/examples/cron-create-receipt.sh +112 -0
- package/examples/cron-modification-guard.sh +12 -0
- package/examples/cross-product-mcp-spawn-detector.sh +178 -0
- package/examples/cwd-project-boundary-guard.sh +0 -0
- package/examples/daemon-zombie-worker-surfacer.sh +118 -0
- package/examples/daily-cost-guard.sh +164 -0
- package/examples/daily-usage-tracker.sh +0 -0
- package/examples/dangerous-pip-flag-guard.sh +12 -0
- package/examples/db-connect-guard.sh +13 -1
- package/examples/denied-action-retry-guard.sh +12 -0
- package/examples/deny-bypass-detector.sh +12 -0
- package/examples/deny-rule-integrity-verifier.sh +181 -0
- package/examples/dependency-install-guard.sh +12 -0
- package/examples/deploy-guard.sh +14 -2
- package/examples/deploy-path-verify-guard.sh +12 -0
- package/examples/deployment-readback-gate.sh +135 -0
- package/examples/deployment-readback-gh-adapter.sh +247 -0
- package/examples/deployment-verify-guard.sh +25 -2
- package/examples/destructive-db-script-write-guard.sh +166 -0
- package/examples/destructive-migration-write-guard.sh +163 -0
- package/examples/diff-size-guard.sh +12 -0
- package/examples/disabled-feature-toggle-advisor.sh +88 -0
- package/examples/disk-partition-guard.sh +12 -0
- package/examples/dispatch-allowlist-preflight.sh +301 -0
- package/examples/dispatch-liveness-watchdog.sh +216 -0
- package/examples/dispatch-receipt.sh +174 -0
- package/examples/django-migrate-guard.sh +12 -0
- package/examples/dns-config-guard.sh +12 -0
- package/examples/docker-dangerous-guard.sh +12 -0
- package/examples/docker-volume-guard.sh +0 -0
- package/examples/dockerfile-latest-guard.sh +1 -0
- package/examples/dotenv-anthropic-key-billing-guard.sh +99 -0
- package/examples/dotenv-commit-guard.sh +12 -0
- package/examples/dotenv-read-guard.sh +12 -0
- package/examples/dotfile-protection-guard.sh +12 -0
- package/examples/dotnet-build-on-edit.sh +1 -1
- package/examples/drizzle-migrate-guard.sh +27 -2
- package/examples/echo-probe-spam-detector.sh +176 -0
- package/examples/edit-counter-test-gate.sh +12 -0
- package/examples/edit-error-counter.sh +1 -1
- package/examples/edit-guard.sh +12 -0
- package/examples/edit-old-string-validator.sh +12 -0
- package/examples/edit-quote-ambiguity-guard.sh +97 -0
- package/examples/edit-retry-loop-guard.sh +0 -0
- package/examples/edit-verify.sh +0 -0
- package/examples/env-inline-secret-guard.sh +14 -2
- package/examples/env-naming-convention.sh +0 -0
- package/examples/env-prod-guard.sh +0 -0
- package/examples/env-required-check.sh +0 -0
- package/examples/env-source-guard.sh +12 -0
- package/examples/env-var-check.sh +24 -1
- package/examples/ephemeral-container-detector.sh +147 -0
- package/examples/error-memory-guard.sh +12 -0
- package/examples/evidence-claim-gate.sh +187 -0
- package/examples/exploration-budget-guard.sh +12 -0
- package/examples/expo-eject-guard.sh +13 -0
- package/examples/extended-thinking-loop-guard.sh +139 -0
- package/examples/extended-thinking-resume-warning.sh +119 -0
- package/examples/extended-thinking-tool-use-mismatch-detector.sh +212 -0
- package/examples/fabricated-command-detector.sh +145 -0
- package/examples/false-disk-full-guard.sh +63 -0
- package/examples/feature-deprecation-detector.sh +109 -0
- package/examples/file-change-tracker.sh +1 -1
- package/examples/file-change-undo-tracker.sh +0 -0
- package/examples/file-edit-backup.sh +63 -14
- package/examples/file-reference-check.sh +0 -0
- package/examples/file-size-limit.sh +12 -0
- package/examples/financial-operation-guard.sh +12 -0
- package/examples/firewall-guard.sh +12 -0
- package/examples/fish-shell-wrapper.sh +125 -7
- package/examples/five-hundred-milestone.sh +1 -0
- package/examples/flask-static-route-guard.sh +89 -0
- package/examples/forbidden-response-phrase-detector.sh +161 -0
- package/examples/gem-push-guard.sh +13 -0
- package/examples/gh-cli-destructive-guard.sh +13 -1
- package/examples/git-checkout-safety-guard.sh +12 -0
- package/examples/git-checkout-uncommitted-guard.sh +12 -0
- package/examples/git-config-guard.sh +12 -0
- package/examples/git-crypt-worktree-guard.sh +12 -0
- package/examples/git-filter-repo-guard.sh +56 -0
- package/examples/git-history-rewrite-guard.sh +12 -0
- package/examples/git-hook-bypass-guard.sh +0 -0
- package/examples/git-maintenance-guard.sh +83 -0
- package/examples/git-merge-conflict-prevent.sh +0 -0
- package/examples/git-message-length-check.sh +0 -0
- package/examples/git-message-length.sh +0 -0
- package/examples/git-operations-require-approval.sh +68 -14
- package/examples/git-pack-temp-cleanup-guard.sh +102 -0
- package/examples/git-push-blast-radius-guard.sh +218 -0
- package/examples/git-remote-guard.sh +24 -3
- package/examples/git-rm-orphan-wipe-guard.sh +85 -0
- package/examples/git-stash-before-checkout.sh +12 -0
- package/examples/git-stash-before-danger.sh +0 -0
- package/examples/git-submodule-guard.sh +69 -2
- package/examples/git-tag-guard.sh +12 -0
- package/examples/github-actions-secret-guard.sh +0 -0
- package/examples/gitignore-check.sh +0 -0
- package/examples/gitops-drift-guard.sh +12 -0
- package/examples/go-mod-tidy-warn.sh +1 -0
- package/examples/go-vet-after-edit.sh +12 -0
- package/examples/goal-iteration-limit-warner.sh +152 -0
- package/examples/grep-nul-false-negative-guard.sh +30 -0
- package/examples/growthbook-flag-monitor.sh +257 -0
- package/examples/hallucination-url-check.sh +1 -1
- package/examples/halt-signal-detector.sh +135 -0
- package/examples/handoff-on-clear.sh +65 -0
- package/examples/hardcoded-ip-guard.sh +1 -0
- package/examples/headless-empty-result-guard.sh +0 -0
- package/examples/headless-stop-guard.sh +0 -0
- package/examples/helm-install-guard.sh +2 -1
- package/examples/home-critical-bash-guard.sh +17 -1
- package/examples/hook-debug-wrapper.sh +6 -2
- package/examples/hook-permission-fixer.sh +0 -0
- package/examples/hook-self-disable-detector.sh +99 -0
- package/examples/hook-stdout-sanitizer.sh +6 -2
- package/examples/hook-tamper-guard.sh +12 -0
- package/examples/idle-session-cost-alert.sh +0 -0
- package/examples/image-dimension-guard.sh +109 -0
- package/examples/image-file-validator.sh +0 -0
- package/examples/iteration-quality-degradation-detector.sh +170 -0
- package/examples/java-compile-on-edit.sh +1 -1
- package/examples/json-syntax-check.sh +0 -0
- package/examples/k8s-production-guard.sh +13 -1
- package/examples/kill-process-guard.sh +12 -0
- package/examples/kubernetes-guard.sh +13 -1
- package/examples/laravel-artisan-guard.sh +13 -0
- package/examples/large-file-guard.sh +1 -1
- package/examples/log-level-guard.sh +0 -0
- package/examples/log-truncation-guard.sh +12 -0
- package/examples/long-session-malformed-tool-call-detector.sh +183 -0
- package/examples/loop-detector.sh +12 -0
- package/examples/magic-number-warn.sh +1 -0
- package/examples/main-branch-warn.sh +12 -0
- package/examples/markdown-link-check.sh +0 -0
- package/examples/max-concurrent-agents.sh +12 -0
- package/examples/max-edit-size-guard.sh +13 -0
- package/examples/max-file-count-guard.sh +0 -0
- package/examples/max-file-delete-count.sh +0 -0
- package/examples/max-function-length.sh +1 -0
- package/examples/max-import-count.sh +0 -0
- package/examples/max-subagent-count.sh +0 -0
- package/examples/mcp-config-freeze.sh +12 -0
- package/examples/mcp-config-poisoning-audit.sh +150 -0
- package/examples/mcp-data-boundary.sh +1 -1
- package/examples/mcp-misdiagnosis-arrest.sh +209 -0
- package/examples/mcp-orphan-leak-warner.sh +49 -0
- package/examples/mcp-permissions-ask-warner.sh +151 -0
- package/examples/mcp-routine-approval-detector.sh +154 -0
- package/examples/mcp-server-allowlist.sh +12 -0
- package/examples/mcp-server-guard.sh +12 -0
- package/examples/mcp-startup-bloat-detector.sh +87 -0
- package/examples/mcp-stdio-compatibility-test.sh +153 -0
- package/examples/mcp-tool-audit-log.sh +0 -0
- package/examples/mcp-tool-guard.sh +101 -1
- package/examples/mcp-warmup-wait.sh +0 -0
- package/examples/memory-chain-audit.sh +56 -0
- package/examples/memory-orphan-detector.sh +188 -0
- package/examples/memory-write-guard.sh +99 -17
- package/examples/migration-verify-guard.sh +12 -0
- package/examples/model-swap-suggester.sh +177 -0
- package/examples/model-version-alert.sh +5 -1
- package/examples/model-version-lock.sh +63 -0
- package/examples/move-delete-sequence-guard.sh +33 -2
- package/examples/multi-file-plan-routing-gate.sh +192 -0
- package/examples/multi-vendor-concurrent-warner.sh +108 -0
- package/examples/multi-window-auth-drift-detector.sh +183 -0
- package/examples/multiline-command-approver.sh +161 -23
- package/examples/nested-background-agent-guard.sh +109 -0
- package/examples/nested-spawn-inflight-guard.sh +178 -0
- package/examples/network-exfil-guard.sh +12 -0
- package/examples/network-guard.sh +12 -0
- package/examples/network-interface-guard.sh +12 -0
- package/examples/nextjs-env-guard.sh +1 -1
- package/examples/no-absolute-import.sh +0 -0
- package/examples/no-alert-confirm-prompt.sh +0 -0
- package/examples/no-anonymous-default-export.sh +0 -0
- package/examples/no-any-type.sh +0 -0
- package/examples/no-any-typescript.sh +1 -0
- package/examples/no-ask-human.sh +12 -0
- package/examples/no-assignment-in-condition.sh +0 -0
- package/examples/no-base64-exfil.sh +12 -0
- package/examples/no-callback-hell.sh +0 -0
- package/examples/no-circular-dependency.sh +0 -0
- package/examples/no-cleartext-storage.sh +0 -0
- package/examples/no-commented-code.sh +0 -0
- package/examples/no-commit-fixup.sh +0 -0
- package/examples/no-console-assert.sh +0 -0
- package/examples/no-console-error-swallow.sh +0 -0
- package/examples/no-console-in-prod.sh +0 -0
- package/examples/no-console-log-commit.sh +12 -0
- package/examples/no-console-log.sh +0 -0
- package/examples/no-console-time.sh +0 -0
- package/examples/no-cors-wildcard.sh +4 -1
- package/examples/no-curl-upload.sh +0 -0
- package/examples/no-dangerouslySetInnerHTML.sh +0 -0
- package/examples/no-dangling-await.sh +1 -0
- package/examples/no-debug-commit.sh +12 -0
- package/examples/no-debug-in-commit.sh +0 -0
- package/examples/no-deep-nesting.sh +0 -0
- package/examples/no-deep-relative-import.sh +1 -0
- package/examples/no-default-credentials.sh +0 -0
- package/examples/no-deploy-friday.sh +13 -1
- package/examples/no-disabled-test.sh +0 -0
- package/examples/no-document-write.sh +0 -0
- package/examples/no-empty-function.sh +0 -0
- package/examples/no-eval-in-template.sh +0 -0
- package/examples/no-eval-template.sh +3 -1
- package/examples/no-eval.sh +0 -0
- package/examples/no-exec-user-input.sh +0 -0
- package/examples/no-fixme-ship.sh +12 -0
- package/examples/no-floating-promises.sh +0 -0
- package/examples/no-force-flag.sh +22 -5
- package/examples/no-force-install.sh +0 -0
- package/examples/no-git-amend.sh +12 -0
- package/examples/no-git-rebase-public.sh +0 -0
- package/examples/no-global-install.sh +12 -0
- package/examples/no-global-state.sh +0 -0
- package/examples/no-hardcoded-port.sh +1 -0
- package/examples/no-hardcoded-url.sh +0 -0
- package/examples/no-helmet-missing.sh +0 -0
- package/examples/no-http-url.sh +1 -0
- package/examples/no-http-without-https.sh +0 -0
- package/examples/no-inline-style.sh +0 -0
- package/examples/no-inline-styles.sh +1 -0
- package/examples/no-innerhtml.sh +0 -0
- package/examples/no-install-global.sh +12 -0
- package/examples/no-jwt-in-url.sh +0 -0
- package/examples/no-large-commit.sh +0 -0
- package/examples/no-localhost-expose.sh +0 -0
- package/examples/no-magic-number.sh +0 -0
- package/examples/no-md5-sha1.sh +0 -0
- package/examples/no-mixed-line-endings.sh +8 -1
- package/examples/no-mutation-in-reducer.sh +0 -0
- package/examples/no-nested-ternary.sh +0 -0
- package/examples/no-network-exfil.sh +0 -0
- package/examples/no-open-redirect.sh +0 -0
- package/examples/no-output-truncation.sh +12 -0
- package/examples/no-package-downgrade.sh +0 -0
- package/examples/no-package-lock-edit.sh +12 -0
- package/examples/no-path-join-user-input.sh +0 -0
- package/examples/no-port-bind.sh +0 -0
- package/examples/no-process-exit.sh +0 -0
- package/examples/no-prototype-pollution.sh +0 -0
- package/examples/no-push-without-ci.sh +0 -0
- package/examples/no-push-without-tests.sh +12 -0
- package/examples/no-raw-password-in-url.sh +0 -0
- package/examples/no-root-user-docker.sh +1 -0
- package/examples/no-root-write.sh +12 -0
- package/examples/no-secrets-in-args.sh +4 -1
- package/examples/no-secrets-in-logs.sh +0 -0
- package/examples/no-sensitive-log.sh +0 -0
- package/examples/no-sleep-in-hooks.sh +0 -0
- package/examples/no-star-import-python.sh +1 -0
- package/examples/no-string-concat-sql.sh +0 -0
- package/examples/no-sudo-guard.sh +12 -0
- package/examples/no-sync-fs.sh +0 -0
- package/examples/no-todo-in-merge.sh +0 -0
- package/examples/no-todo-in-production.sh +1 -0
- package/examples/no-todo-without-issue.sh +0 -0
- package/examples/no-unused-import.sh +0 -0
- package/examples/no-var-keyword.sh +0 -0
- package/examples/no-verify-blocker.sh +12 -0
- package/examples/no-wget-piped-bash.sh +12 -0
- package/examples/no-wildcard-cors.sh +0 -0
- package/examples/no-wildcard-delete.sh +0 -0
- package/examples/no-wildcard-import.sh +0 -0
- package/examples/no-with-statement.sh +0 -0
- package/examples/no-write-outside-src.sh +0 -0
- package/examples/no-xml-external-entity.sh +0 -0
- package/examples/non-english-quality-warner.sh +156 -0
- package/examples/notify-waiting.sh +1 -1
- package/examples/npm-audit-warn.sh +0 -0
- package/examples/npm-global-install-guard.sh +12 -0
- package/examples/npm-publish-guard.sh +12 -0
- package/examples/npm-script-injection.sh +0 -0
- package/examples/npm-supply-chain-guard.sh +0 -0
- package/examples/nuxt-config-guard.sh +1 -0
- package/examples/oauth-refresh-monitor.sh +210 -0
- package/examples/opus-degradation-tracker.sh +187 -0
- package/examples/opus48-routine-task-warning.sh +196 -0
- package/examples/opus48-thinking-wedge-advisor.sh +143 -0
- package/examples/output-credential-scan.sh +1 -1
- package/examples/output-secret-mask.sh +31 -9
- package/examples/output-token-spike-detector.sh +145 -0
- package/examples/package-json-guard.sh +12 -0
- package/examples/package-lock-frozen.sh +12 -0
- package/examples/parallel-batch-size-limiter.sh +121 -0
- package/examples/parallel-cascade-detector.sh +116 -0
- package/examples/partial-view-claim-arrest.sh +174 -0
- package/examples/path-deny-bash-guard.sh +12 -0
- package/examples/path-traversal-guard.sh +12 -0
- package/examples/per-prompt-token-cap.sh +124 -0
- package/examples/permission-audit-log.sh +1 -1
- package/examples/permission-denial-enforcer.sh +12 -0
- package/examples/permission-entry-validator.sh +0 -0
- package/examples/persisted-1m-model-advisor.sh +88 -0
- package/examples/php-lint-on-edit.sh +1 -1
- package/examples/pii-upload-guard.sh +12 -0
- package/examples/pip-publish-guard.sh +13 -0
- package/examples/pip-requirements-guard.sh +12 -0
- package/examples/pip-venv-required.sh +12 -0
- package/examples/plan-mode-edit-guard.sh +12 -0
- package/examples/plan-mode-enforcer.sh +12 -0
- package/examples/plan-mode-strict-guard.sh +12 -0
- package/examples/plugin-hooks-json-bloat-detector.sh +169 -0
- package/examples/plugin-process-cleanup.sh +0 -0
- package/examples/polyglot-rm-guard.sh +12 -0
- package/examples/post-compact-safety.sh +12 -0
- package/examples/post-edit-disk-verify.sh +152 -0
- package/examples/powershell-remove-item-guard.sh +85 -0
- package/examples/pr-description-check.sh +0 -0
- package/examples/pr-duplicate-guard.sh +13 -0
- package/examples/pre-bash-sed-line-ending-windows.sh +87 -0
- package/examples/pre-compact-knowledge-save.sh +0 -0
- package/examples/pre-compact-transcript-backup.sh +0 -0
- package/examples/pre-execution-claim-detector.sh +179 -0
- package/examples/prefer-builtin-tools.sh +10 -1
- package/examples/prefer-const.sh +0 -0
- package/examples/prefer-dedicated-tools.sh +12 -0
- package/examples/prefer-optional-chaining.sh +0 -0
- package/examples/prisma-migrate-guard.sh +24 -7
- package/examples/production-port-kill-guard.sh +12 -0
- package/examples/prompt-injection-guard.sh +2 -1
- package/examples/prompt-usage-logger.sh +0 -0
- package/examples/protect-claudemd.sh +12 -0
- package/examples/protect-dotfiles.sh +12 -0
- package/examples/proxy-capture-suggester.sh +159 -0
- package/examples/public-artefact-socratic-narrowing.sh +232 -0
- package/examples/public-repo-push-guard.sh +12 -0
- package/examples/push-requires-test-pass-record.sh +0 -0
- package/examples/push-requires-test-pass.sh +12 -0
- package/examples/quota-anomaly-detector.sh +173 -0
- package/examples/quota-reset-audit.sh +58 -0
- package/examples/quoted-flag-approver.sh +99 -10
- package/examples/rails-migration-guard.sh +12 -0
- package/examples/rate-limit-guard.sh +0 -0
- package/examples/read-all-files-enforcer.sh +0 -0
- package/examples/read-budget-guard.sh +12 -0
- package/examples/read-loop-detector.sh +59 -0
- package/examples/read-once-guard.sh +96 -0
- package/examples/read-only-mode.sh +12 -0
- package/examples/readme-exists-check.sh +0 -0
- package/examples/record-read-coverage.sh +73 -0
- package/examples/redirect-fragment-warner.sh +149 -0
- package/examples/redis-flushall-guard.sh +13 -0
- package/examples/redundant-read-blocker.sh +132 -0
- package/examples/refusal-arrest-gate.sh +248 -0
- package/examples/registry-publish-guard.sh +13 -1
- package/examples/remote-control-billing-classifier.sh +135 -0
- package/examples/replace-all-guard.sh +12 -0
- package/examples/repo-visibility-guard.sh +12 -0
- package/examples/reroute-after-block-guard.sh +150 -0
- package/examples/response-budget-guard.sh +0 -0
- package/examples/resume-drift-watcher.sh +57 -0
- package/examples/rg-replace-flag-detector.sh +125 -0
- package/examples/rhetorical-verification-prompt-detector.sh +102 -0
- package/examples/ripgrep-permission-fix.sh +0 -0
- package/examples/rm-safety-net.sh +151 -8
- package/examples/role-tool-guard.sh +12 -0
- package/examples/route-handler-emptiness-gate.sh +324 -0
- package/examples/ruby-lint-on-edit.sh +1 -1
- package/examples/runtime-binary-change-detector.sh +102 -0
- package/examples/same-command-repeat-detector.sh +196 -0
- package/examples/same-correction-arrest.sh +169 -0
- package/examples/sandbox-denywrite-enforcer.sh +78 -0
- package/examples/sandbox-relative-path-audit.sh +83 -25
- package/examples/sandbox-write-verify.sh +12 -0
- package/examples/schema-migration-guard.sh +0 -0
- package/examples/scope-expansion-receipt.sh +178 -0
- package/examples/scope-guard.sh +88 -9
- package/examples/secret-file-read-guard.sh +12 -0
- package/examples/secret-file-write-guard.sh +150 -0
- package/examples/self-modify-bypass-guard.sh +0 -0
- package/examples/sensitive-file-read-guard.sh +23 -3
- package/examples/sensitive-log-guard.sh +1 -0
- package/examples/server-side-prompt-injection-detector.sh +69 -0
- package/examples/session-agent-cost-limiter.sh +12 -0
- package/examples/session-backup-on-start.sh +1 -1
- package/examples/session-cost-alert.sh +12 -0
- package/examples/session-drift-guard.sh +12 -0
- package/examples/session-duration-guard.sh +25 -2
- package/examples/session-end-logger.sh +0 -0
- package/examples/session-health-monitor.sh +0 -0
- package/examples/session-index-repair.sh +1 -1
- package/examples/session-memory-watchdog.sh +1 -0
- package/examples/session-permission-reset-guard.sh +12 -0
- package/examples/session-persistence-verifier.sh +93 -0
- package/examples/session-plugin-pin-watch.sh +68 -0
- package/examples/session-rate-monitor.sh +176 -0
- package/examples/session-resume-env-fix.sh +0 -0
- package/examples/session-start-quota-status.sh +193 -0
- package/examples/session-start-safety-check.sh +55 -3
- package/examples/session-state-saver.sh +0 -0
- package/examples/session-summary-stop.sh +1 -1
- package/examples/session-summary.sh +0 -0
- package/examples/session-token-counter.sh +1 -1
- package/examples/settings-hooks-key-restorer.sh +99 -0
- package/examples/settings-json-health-check.sh +57 -0
- package/examples/settings-json-model-guard.sh +0 -0
- package/examples/settings-regression-tester.sh +188 -0
- package/examples/shell-config-truncation-guard.sh +12 -0
- package/examples/shell-wrapper-guard.sh +12 -0
- package/examples/skill-cumulative-size-detector.sh +104 -0
- package/examples/skill-description-drop-detector.sh +148 -0
- package/examples/skill-gate.sh +0 -0
- package/examples/skill-truncation-detector.sh +154 -0
- package/examples/skills-context-recorder.sh +167 -0
- package/examples/skills-load-verifier.sh +96 -0
- package/examples/skills-settings-validator.sh +139 -0
- package/examples/sonnet-45-deprecation-helper.sh +85 -0
- package/examples/spec-file-scope-guard.sh +12 -0
- package/examples/spring-profile-guard.sh +1 -0
- package/examples/spurious-malformed-notice-detector.sh +247 -0
- package/examples/sql-bulk-delete-warn.sh +88 -0
- package/examples/sql-injection-detect.sh +0 -0
- package/examples/ssh-key-protect.sh +12 -0
- package/examples/staged-secret-scan.sh +22 -1
- package/examples/stale-temp-settings-detector.sh +86 -0
- package/examples/standing-rule-session-surfacer.sh +137 -0
- package/examples/stop-hook-sigterm-wrapper.sh +182 -0
- package/examples/stop-transcript-write-health.sh +64 -0
- package/examples/strict-allowlist.sh +57 -15
- package/examples/strip-coauthored-by.sh +50 -10
- package/examples/subagent-blast-radius-guard.sh +184 -0
- package/examples/subagent-boundary-precheck.sh +126 -0
- package/examples/subagent-budget-guard.sh +12 -0
- package/examples/subagent-claudemd-inject.sh +0 -0
- package/examples/subagent-closure-verify-gate.sh +164 -0
- package/examples/subagent-destructive-git-guard.sh +120 -0
- package/examples/subagent-error-detector.sh +0 -0
- package/examples/subagent-forged-system-reminder-guard.sh +156 -0
- package/examples/subagent-identity-leak-guard.sh +102 -0
- package/examples/subagent-identity-reassertion.sh +51 -0
- package/examples/subagent-inheritance-tester.sh +179 -0
- package/examples/subagent-permission-mode-guard.sh +110 -0
- package/examples/subagent-scope-guard.sh +12 -0
- package/examples/subagent-spawn-verification-enforcer.sh +102 -0
- package/examples/subagent-tool-allowlist-enforcer.sh +101 -0
- package/examples/subagent-tool-call-limiter.sh +87 -15
- package/examples/subcommand-chain-guard.sh +12 -0
- package/examples/subscription-api-billing-warner.sh +160 -0
- package/examples/subscription-bypass-detector.sh +152 -0
- package/examples/svelte-lint-on-edit.sh +1 -0
- package/examples/swift-build-on-edit.sh +1 -1
- package/examples/symlink-guard.sh +27 -2
- package/examples/symlink-protect.sh +1 -0
- package/examples/system-dir-protection-guard.sh +73 -8
- package/examples/system-message-workaround.sh +38 -13
- package/examples/system-package-guard.sh +12 -0
- package/examples/systemd-service-guard.sh +12 -0
- package/examples/task-integrity-guard.sh +12 -0
- package/examples/temp-file-cleanup.sh +1 -1
- package/examples/temporal-suggestion-detector.sh +135 -0
- package/examples/terraform-guard.sh +27 -6
- package/examples/test-after-edit.sh +1 -1
- package/examples/test-before-push.sh +12 -0
- package/examples/test-coverage-reminder.sh +24 -1
- package/examples/thinking-budget-effort-mismatch-detector.sh +149 -0
- package/examples/timezone-guard.sh +0 -0
- package/examples/tmp-output-size-guard.sh +0 -0
- package/examples/todo-check.sh +1 -1
- package/examples/token-budget-guard.sh +12 -0
- package/examples/token-budget-per-task.sh +12 -0
- package/examples/token-usage-tracker.sh +7 -1
- package/examples/tokenizer-ratio-alert-corpus.sh +90 -0
- package/examples/tokenizer-ratio-alert.sh +104 -0
- package/examples/tool-call-rate-limiter.sh +0 -0
- package/examples/tool-result-correlation-checker.sh +167 -0
- package/examples/tool-result-size-guard.sh +132 -0
- package/examples/tool-retry-budget-guard.sh +12 -0
- package/examples/transcript-contamination-detector.sh +138 -0
- package/examples/trustfall-mcp-injection-guard.sh +103 -0
- package/examples/ultrareview-large-diff-advisor.sh +184 -0
- package/examples/unbounded-output-guard.sh +94 -0
- package/examples/uncommitted-changes-stop.sh +1 -0
- package/examples/uncommitted-discard-guard.sh +23 -5
- package/examples/uncommitted-work-guard.sh +12 -0
- package/examples/usage-warn.sh +0 -0
- package/examples/user-account-guard.sh +12 -0
- package/examples/userprompt-submit-receipt.sh +123 -0
- package/examples/variable-expansion-guard.sh +12 -0
- package/examples/verify-after-publish-reminder.sh +93 -0
- package/examples/verify-before-commit.sh +12 -0
- package/examples/version-bump-detector.sh +156 -0
- package/examples/version-regression-warner.sh +144 -0
- package/examples/vue-lint-on-edit.sh +1 -0
- package/examples/warn-cron-cost-trap.sh +173 -0
- package/examples/webfetch-runaway-guard.sh +89 -0
- package/examples/wellness-break-reminder.sh +118 -0
- package/examples/windows-destructive-command-guard.sh +177 -0
- package/examples/windows-path-guard.sh +12 -0
- package/examples/windows-python-stub-detector.sh +63 -0
- package/examples/work-hours-guard.sh +12 -0
- package/examples/working-directory-fence.sh +12 -0
- package/examples/workspace-lease-guard.sh +205 -0
- package/examples/worktree-create-log.sh +1 -0
- package/examples/worktree-delete-guard.sh +12 -0
- package/examples/worktree-edit-boundary-guard.sh +127 -0
- package/examples/worktree-escape-write-guard.sh +114 -0
- package/examples/worktree-hook-linker.sh +0 -0
- package/examples/worktree-hooks-path-fix.sh +111 -0
- package/examples/worktree-parent-write-guard.sh +43 -0
- package/examples/worktree-project-unify.sh +2 -1
- package/examples/worktree-remove-uncommitted-guard.sh +13 -0
- package/examples/worktree-unmerged-guard.sh +7 -1
- package/examples/write-byte-integrity-verifier.sh +190 -0
- package/examples/write-empty-content-guard.sh +67 -0
- package/examples/write-nul-corruption-detector.sh +61 -0
- package/examples/write-overwrite-confirm.sh +160 -14
- package/examples/write-secret-guard.sh +27 -5
- package/examples/write-shrink-guard.sh +12 -0
- package/examples/write-test-ratio.sh +0 -0
- package/examples/wsl-host-disk-space-guard.sh +97 -0
- package/examples/xml-format-leak-detector.sh +266 -0
- package/examples/yaml-syntax-check.sh +12 -0
- package/hooks/hooks.json +6 -6
- package/index.mjs +1699 -183
- package/mission.md +2 -0
- package/package.json +4 -4
- package/plugins/credential-guard/.claude-plugin/plugin.json +9 -7
- package/plugins/git-protection/.claude-plugin/plugin.json +10 -8
- package/plugins/safety-essentials/.claude-plugin/plugin.json +9 -7
- package/plugins/token-guard/.claude-plugin/plugin.json +10 -8
- package/scripts/agents-md-sync-setup.sh +156 -0
- package/scripts/autonomy-blocked-summary.sh +148 -0
- package/scripts/build-search-index.py +43 -0
- package/scripts/build-sitemap.py +119 -0
- package/scripts/cc-doctor.sh +192 -0
- package/scripts/check-hook-event-names.py +127 -0
- package/scripts/check-misfire-instrument.sh +64 -0
- package/scripts/claim-verify-audit.sh +467 -0
- package/scripts/cowork-claudemd-helper.sh +136 -0
- package/scripts/june-15-deprecated-model-scan.sh +111 -0
- package/scripts/measure-heredoc-shapes.sh +67 -0
- package/scripts/measure-literal-match-misfire.sh +110 -0
- package/scripts/probe-scope-guard-branches.sh +48 -0
- package/scripts/probe-skip-line-both-ways.sh +65 -0
- package/scripts/receipts-aggregate.py +199 -0
- package/scripts/session-forensic-audit.py +360 -0
- package/scripts.json +9 -9
- package/scripts.json.bak-2026-07-27-find +13 -0
- package/skills/safety-setup/SKILL.md +5 -5
- package/tests/approve-side-remaining-two.test.sh +129 -0
- package/tests/approver-list-granularity.test.sh +145 -0
- package/tests/askuserquestion-autonomy-gate.test.sh +181 -0
- package/tests/audit-ci-gate.test.sh +87 -0
- package/tests/audit-cross-layer-claudemd.test.sh +170 -0
- package/tests/audit-fail-open-parse.test.sh +100 -0
- package/tests/auto-approve-compound-tail.test.sh +194 -0
- package/tests/auto-mode-path-invoked-commands.test.sh +89 -0
- package/tests/auto-mode-quoted-targets.test.sh +127 -0
- package/tests/auto-mode-unquoted-targets.test.sh +112 -0
- package/tests/bash-secret-output-detector-detects.test.sh +102 -0
- package/tests/blindspots-cross-layer.test.sh +177 -0
- package/tests/block-database-wipe.test.sh +64 -0
- package/tests/bundled-short-flags-bypass.test.sh +85 -0
- package/tests/cd-git-allow-compound-tail.test.sh +67 -0
- package/tests/chown-guard-filesystem-root.test.sh +64 -0
- package/tests/ci-workflow-guard-skip-rule.test.sh +115 -0
- package/tests/compound-deny-safe-rm-targets.test.sh +105 -0
- package/tests/core-scripts-parser-fallback.test.sh +140 -0
- package/tests/destructive-guard-bare-glob.test.sh +74 -0
- package/tests/destructive-guard-every-operand.test.sh +100 -0
- package/tests/destructive-guard-find-deletion.test.sh +114 -0
- package/tests/destructive-guard-flag-order.test.sh +106 -0
- package/tests/destructive-guard-mentions-vs-invocations.test.sh +107 -0
- package/tests/destructive-guard-quoted-target.test.sh +89 -0
- package/tests/destructive-guard-separators.test.sh +105 -0
- package/tests/destructive-guard-variable-target.test.sh +98 -0
- package/tests/destructive-guard-wrapped-command.test.sh +91 -0
- package/tests/doctor-hook-disabling-env.test.sh +92 -0
- package/tests/doctor-misspelled-settings-keys.test.sh +106 -0
- package/tests/example-guards-wrapped-command.test.sh +169 -0
- package/tests/file-edit-backup.test.sh +93 -0
- package/tests/git-filter-repo-guard.test.sh +60 -0
- package/tests/git-global-options-bypass.test.sh +141 -0
- package/tests/git-invocation-prefixes-all-guards.test.sh +114 -0
- package/tests/git-maintenance-guard.test.sh +83 -0
- package/tests/git-pack-temp-cleanup-guard.test.sh +133 -0
- package/tests/git-rm-orphan-wipe-guard.test.sh +66 -0
- package/tests/git-submodule-guard.test.sh +50 -0
- package/tests/grep-pcre-portability.test.sh +155 -0
- package/tests/hook-registration-matches-input.test.sh +73 -0
- package/tests/hook-trigger-matches-envelope.test.sh +178 -0
- package/tests/install-does-not-claim-protection.test.sh +110 -0
- package/tests/install-example-standalone-tools.test.sh +139 -0
- package/tests/line-continuation-bypass.test.sh +114 -0
- package/tests/mcp-config-poisoning-audit.test.sh +106 -0
- package/tests/nested-background-agent-guard.test.sh +58 -0
- package/tests/no-unqualified-safety-claims.test.sh +114 -0
- package/tests/option-eating-grep-patterns.test.sh +130 -0
- package/tests/outdated-core-guards.test.sh +134 -0
- package/tests/outdated-report.test.sh +155 -0
- package/tests/output-secret-mask-warns.test.sh +73 -0
- package/tests/plugin-hooks-fail-open-under-sh.test.sh +165 -0
- package/tests/plugins-word-order.test.sh +126 -0
- package/tests/powershell-remove-item-guard.test.sh +85 -0
- package/tests/project-dir-naming.test.sh +103 -0
- package/tests/quoted-safe-targets-and-mentions.test.sh +190 -0
- package/tests/reroute-after-block-guard.test.sh +104 -0
- package/tests/secret-guard-documented-promises.test.sh +97 -0
- package/tests/session-plugin-pin-watch.test.sh +45 -0
- package/tests/settings-unreadable-refuses-to-write.test.sh +95 -0
- package/tests/shield-no-silent-adoption.test.py +110 -0
- package/tests/shield-no-silent-adoption.test.sh +46 -0
- package/tests/stop-transcript-write-health.test.sh +46 -0
- package/tests/system-dir-guard-root-erased.test.sh +66 -0
- package/tests/test-account-billing-log.sh +100 -0
- package/tests/test-account-routing-preflight.sh +77 -0
- package/tests/test-agent-sdk-credit-pool-monitor.sh +157 -0
- package/tests/test-agent-view-quota-warn.sh +184 -0
- package/tests/test-agents-md-edit-drift-warner.sh +176 -0
- package/tests/test-agents-md-loader.sh +204 -0
- package/tests/test-agents-md-sync-checker.sh +125 -0
- package/tests/test-ai-slop-punctuation-arrest.sh +280 -0
- package/tests/test-allowlist.sh +60 -0
- package/tests/test-always-allow-pattern-suggester.sh +147 -0
- package/tests/test-anthropic-base-url-guard.sh +88 -0
- package/tests/test-articulated-scope-capture.sh +139 -0
- package/tests/test-attachment-traversal-guard.sh +168 -0
- package/tests/test-aup-block-pattern-logger.sh +315 -0
- package/tests/test-aup-false-positive-helper.sh +188 -0
- package/tests/test-aup-large-tool-output-warner.sh +370 -0
- package/tests/test-aup-retry-loop-guard.sh +341 -0
- package/tests/test-auth-expiry-reminder.sh +303 -0
- package/tests/test-auth-macos-sleep-detector.sh +254 -0
- package/tests/test-auth-path-detector.sh +232 -0
- package/tests/test-auth-status-checker.sh +233 -0
- package/tests/test-authorized-reconfirmation-detector.sh +280 -0
- package/tests/test-background-cost-launch-guard.sh +62 -0
- package/tests/test-bash-allowlist-secondary-check.sh +143 -0
- package/tests/test-bash-fanout-bounded-rewriter.sh +186 -0
- package/tests/test-bash-project-fence.sh +127 -0
- package/tests/test-bg-permission-prompt-warner.sh +221 -0
- package/tests/test-binary-read-detector.sh +173 -0
- package/tests/test-broad-prefix-session-trap-warner.sh +167 -0
- package/tests/test-bulk-delete-target-resolution.sh +49 -0
- package/tests/test-bypass-mode-effective-verifier.sh +179 -0
- package/tests/test-cache-creation-drift-detector.sh +244 -0
- package/tests/test-cache-residue-detector.sh +429 -0
- package/tests/test-cache-tier-logger.sh +59 -0
- package/tests/test-cache-ttl-eviction-detector.sh +282 -0
- package/tests/test-cch-sentinel-precommit-guard.sh +64 -0
- package/tests/test-claim-verify-detector.sh +222 -0
- package/tests/test-claim-vs-caveat-checker.sh +134 -0
- package/tests/test-claude-code-version-pin-advisor.sh +353 -0
- package/tests/test-claude-md-reinjector.sh +173 -0
- package/tests/test-claude-md-size-monitor.sh +107 -0
- package/tests/test-claude-update-budget-guard.sh +132 -0
- package/tests/test-claude-update-smart.sh +91 -0
- package/tests/test-claudemd-tool-prohibition.sh +239 -0
- package/tests/test-cli-config-pinning-detector.sh +233 -0
- package/tests/test-cliff-countdown-advisor.sh +138 -0
- package/tests/test-closure-word-verify-gate.sh +158 -0
- package/tests/test-commit-all-scope-guard.sh +73 -0
- package/tests/test-commitment-carry-forward-arrest.sh +250 -0
- package/tests/test-compact-dispatch-watchdog.sh +147 -0
- package/tests/test-completion-claim-without-verification-detector.sh +326 -0
- package/tests/test-compound-bash-permission-resolver.sh +264 -0
- package/tests/test-compound-command-deny-enforcer.sh +67 -0
- package/tests/test-context-length-budget.sh +68 -0
- package/tests/test-context-usage-drift-alert.sh +52 -22
- package/tests/test-cost-incident-self-audit.sh +94 -0
- package/tests/test-cowork-claude-md-load-checker.sh +257 -0
- package/tests/test-cowork-claudemd-helper.sh +141 -0
- package/tests/test-cowork-fuse-staleness-watcher.sh +287 -0
- package/tests/test-cowork-hook-absence-warner.sh +230 -0
- package/tests/test-cowork-model-picker-advisor.sh +317 -0
- package/tests/test-credential-exfil-guard.sh +62 -0
- package/tests/test-cron-create-receipt.sh +165 -0
- package/tests/test-cross-product-mcp-spawn-detector.sh +112 -0
- package/tests/test-daemon-zombie-worker-surfacer.sh +71 -0
- package/tests/test-daily-cost-guard.sh +131 -0
- package/tests/test-deny-rule-integrity-verifier.sh +288 -0
- package/tests/test-deployment-readback-gate.sh +92 -0
- package/tests/test-deployment-readback-gh-adapter.sh +163 -0
- package/tests/test-disabled-feature-toggle-advisor.sh +78 -0
- package/tests/test-dispatch-allowlist-preflight.sh +385 -0
- package/tests/test-dispatch-liveness-watchdog.sh +319 -0
- package/tests/test-dispatch-receipt.sh +314 -0
- package/tests/test-dotenv-anthropic-key-billing-guard.sh +160 -0
- package/tests/test-echo-probe-spam-detector.sh +143 -0
- package/tests/test-edit-quote-ambiguity-guard.sh +75 -0
- package/tests/test-ephemeral-container-detector.sh +251 -0
- package/tests/test-evidence-claim-gate.sh +291 -0
- package/tests/test-extended-thinking-loop-guard.sh +289 -0
- package/tests/test-extended-thinking-resume-warning.sh +240 -0
- package/tests/test-extended-thinking-tool-use-mismatch-detector.sh +236 -0
- package/tests/test-fabricated-command-detector.sh +296 -0
- package/tests/test-false-disk-full-guard.sh +36 -0
- package/tests/test-feature-deprecation-detector.sh +117 -0
- package/tests/test-forbidden-response-phrase-detector.sh +246 -0
- package/tests/test-git-operations-require-approval.sh +53 -0
- package/tests/test-git-push-blast-radius-guard.sh +115 -0
- package/tests/test-goal-iteration-limit-warner.sh +128 -0
- package/tests/test-growthbook-flag-monitor.sh +428 -0
- package/tests/test-halt-signal-detector.sh +120 -0
- package/tests/test-hook-self-disable-detector.sh +232 -0
- package/tests/test-iteration-quality-degradation-detector.sh +244 -0
- package/tests/test-long-session-malformed-tool-call-detector.sh +185 -0
- package/tests/test-marketplace-plugins.sh +193 -0
- package/tests/test-mcp-misdiagnosis-arrest.sh +235 -0
- package/tests/test-mcp-orphan-leak-warner.sh +71 -0
- package/tests/test-mcp-permissions-ask-warner.sh +207 -0
- package/tests/test-mcp-routine-approval-detector.sh +229 -0
- package/tests/test-mcp-startup-bloat-detector.sh +141 -0
- package/tests/test-mcp-stdio-compatibility-test.sh +112 -0
- package/tests/test-memory-chain-audit.sh +59 -0
- package/tests/test-memory-orphan-detector.sh +227 -0
- package/tests/test-model-swap-suggester.sh +368 -0
- package/tests/test-model-version-lock.sh +83 -0
- package/tests/test-multi-file-plan-routing-gate.sh +277 -0
- package/tests/test-multi-window-auth-drift-detector.sh +262 -0
- package/tests/test-nested-spawn-inflight-guard.sh +281 -0
- package/tests/test-no-force-flag.sh +49 -0
- package/tests/test-non-english-quality-warner.sh +229 -0
- package/tests/test-oauth-refresh-monitor.sh +311 -0
- package/tests/test-opus-degradation-tracker.sh +274 -0
- package/tests/test-opus48-routine-task-warning.sh +201 -0
- package/tests/test-opus48-thinking-wedge-advisor.sh +249 -0
- package/tests/test-output-token-spike-detector.sh +315 -0
- package/tests/test-parallel-batch-size-limiter.sh +228 -0
- package/tests/test-parallel-cascade-detector.sh +191 -0
- package/tests/test-partial-view-claim-arrest.sh +272 -0
- package/tests/test-per-prompt-token-cap.sh +136 -0
- package/tests/test-persisted-1m-model-advisor.sh +71 -0
- package/tests/test-plugin-hooks-json-bloat-detector.sh +267 -0
- package/tests/test-post-edit-disk-verify.sh +294 -0
- package/tests/test-pre-bash-sed-line-ending-windows.sh +108 -0
- package/tests/test-pre-execution-claim-detector.sh +366 -0
- package/tests/test-private-key-backup-and-git-credentials.sh +100 -0
- package/tests/test-proxy-capture-suggester.sh +214 -0
- package/tests/test-public-artefact-socratic-narrowing.sh +346 -0
- package/tests/test-quota-anomaly-detector.sh +321 -0
- package/tests/test-quota-reset-audit.sh +81 -0
- package/tests/test-read-loop-detector.sh +137 -0
- package/tests/test-read-once-guard.sh +85 -0
- package/tests/test-receipts-aggregate.sh +143 -0
- package/tests/test-redirect-fragment-warner.sh +130 -0
- package/tests/test-redundant-read-blocker.sh +155 -0
- package/tests/test-refusal-arrest-gate.sh +303 -0
- package/tests/test-remote-control-billing-classifier.sh +125 -0
- package/tests/test-resume-drift-watcher.sh +65 -0
- package/tests/test-rg-replace-flag-detector.sh +175 -0
- package/tests/test-rhetorical-verification-prompt-detector.sh +237 -0
- package/tests/test-rm-safety-net.sh +115 -0
- package/tests/test-route-handler-emptiness-gate.sh +300 -0
- package/tests/test-runtime-binary-change-detector.sh +196 -0
- package/tests/test-same-command-repeat-detector.sh +165 -0
- package/tests/test-same-correction-arrest.sh +165 -0
- package/tests/test-scope-expansion-receipt.sh +207 -0
- package/tests/test-server-side-prompt-injection-detector.sh +181 -0
- package/tests/test-session-persistence-verifier.sh +128 -0
- package/tests/test-session-rate-monitor.sh +284 -0
- package/tests/test-session-start-quota-status.sh +210 -0
- package/tests/test-session-start-safety-check.sh +138 -0
- package/tests/test-settings-hooks-key-restorer.sh +257 -0
- package/tests/test-settings-json-health-check.sh +70 -0
- package/tests/test-settings-regression-tester.sh +197 -0
- package/tests/test-skill-cumulative-size-detector.sh +198 -0
- package/tests/test-skill-description-drop-detector.sh +236 -0
- package/tests/test-skill-truncation-detector.sh +263 -0
- package/tests/test-skills-context-recorder.sh +329 -0
- package/tests/test-skills-load-verifier.sh +184 -0
- package/tests/test-skills-settings-validator.sh +242 -0
- package/tests/test-sonnet-45-deprecation-helper.sh +150 -0
- package/tests/test-spurious-malformed-notice-detector.sh +290 -0
- package/tests/test-sql-bulk-delete-warn.sh +123 -0
- package/tests/test-ssh-key-protect.sh +81 -0
- package/tests/test-stale-temp-settings-detector.sh +161 -0
- package/tests/test-standing-rule-session-surfacer.sh +215 -0
- package/tests/test-starter-hooks-manifest.sh +96 -0
- package/tests/test-stop-hook-sigterm-wrapper.sh +258 -0
- package/tests/test-strict-allowlist.sh +72 -0
- package/tests/test-subagent-boundary-precheck.sh +137 -0
- package/tests/test-subagent-closure-verify-gate.sh +193 -0
- package/tests/test-subagent-destructive-git-guard.sh +86 -0
- package/tests/test-subagent-identity-leak-guard.sh +62 -0
- package/tests/test-subagent-identity-reassertion.sh +61 -0
- package/tests/test-subagent-inheritance-tester.sh +319 -0
- package/tests/test-subagent-permission-mode-guard.sh +61 -0
- package/tests/test-subagent-spawn-verification-enforcer.sh +60 -0
- package/tests/test-subagent-tool-allowlist-enforcer.sh +62 -0
- package/tests/test-subagent-tool-call-limiter.sh +97 -0
- package/tests/test-subscription-api-billing-warner.sh +138 -0
- package/tests/test-subscription-bypass-detector.sh +255 -0
- package/tests/test-temporal-suggestion-detector.sh +183 -0
- package/tests/test-thinking-budget-effort-mismatch-detector.sh +327 -0
- package/tests/test-tokenizer-ratio-alert-corpus.sh +77 -0
- package/tests/test-tokenizer-ratio-alert.sh +93 -0
- package/tests/test-tool-result-correlation-checker.sh +264 -0
- package/tests/test-tool-result-size-guard.sh +121 -0
- package/tests/test-transcript-contamination-detector.sh +264 -0
- package/tests/test-trigger-header-parsing.sh +151 -0
- package/tests/test-ultrareview-large-diff-advisor.sh +192 -0
- package/tests/test-userprompt-submit-receipt.sh +181 -0
- package/tests/test-verify-after-publish-reminder.sh +184 -0
- package/tests/test-version-bump-detector.sh +212 -0
- package/tests/test-version-regression-warner.sh +165 -0
- package/tests/test-warn-cron-cost-trap.sh +82 -0
- package/tests/test-webfetch-runaway-guard.sh +77 -0
- package/tests/test-wellness-break-reminder.sh +138 -0
- package/tests/test-windows-destructive-command-guard.sh +169 -0
- package/tests/test-windows-python-stub-detector.sh +146 -0
- package/tests/test-worktree-edit-boundary-guard.sh +219 -0
- package/tests/test-write-byte-integrity-verifier.sh +192 -0
- package/tests/test-xml-format-leak-detector.sh +299 -0
- package/tests/trustfall-mcp-injection-guard.test.sh +183 -0
- package/tests/workspace-lease-guard.test.sh +144 -0
- package/tests/worktree-escape-write-guard.test.sh +68 -0
- package/tests/worktree-hooks-path-fix.test.sh +181 -0
- package/tests/worktree-parent-write-guard.test.sh +51 -0
- package/tests/write-empty-content-guard.test.sh +39 -0
- package/tests/write-nul-corruption-detector.test.sh +29 -0
- package/tests/write-overwrite-unread-content.test.sh +178 -0
- package/tests/wsl-host-disk-space-guard.test.sh +55 -0
package/README.md
CHANGED
|
@@ -1,618 +1,525 @@
|
|
|
1
1
|
# cc-safe-setup
|
|
2
|
+
**[日本語の README はこちら / Japanese README](docs/README.ja.md)**
|
|
2
3
|
|
|
3
|
-
[
|
|
4
|
-
[](https://www.npmjs.com/package/cc-safe-setup)
|
|
5
|
-
[](https://github.com/yurukusa/cc-safe-setup/actions/workflows/test.yml)
|
|
4
|
+
One command to add safety hooks to [Claude Code](https://docs.claude.com/en/docs/claude-code). It installs a set of `PreToolUse`, `PostToolUse`, `SessionStart`, `Stop`, and `SubagentStop` hooks that stop destructive or irreversible operations *before* they run, and that surface silent failures.
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
**One command to make Claude Code safe for autonomous operation.** 701 example hooks · 9,200+ tests · 30K+ total installs · [日本語](docs/README.ja.md)
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npx cc-safe-setup
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Installs 8 safety hooks in ~10 seconds. Blocks `rm -rf /`, prevents pushes to main, catches secret leaks, validates syntax after every edit. Zero npm dependencies. Hooks use [`jq`](https://jqlang.github.io/jq/) at runtime (`brew install jq` / `apt install jq`).
|
|
16
|
-
|
|
17
|
-
> **What's a hook?** A checkpoint that runs before Claude executes a command. Like airport security — it inspects what's about to happen and blocks anything dangerous before it reaches the gate.
|
|
18
|
-
|
|
19
|
-
[**Getting Started**](https://yurukusa.github.io/cc-safe-setup/getting-started.html) · [**Incident Tracker**](https://yurukusa.github.io/cc-safe-setup/incidents.html) · [**Hook Selector**](https://yurukusa.github.io/cc-safe-setup/hook-selector.html) · [**Token Checkup**](https://yurukusa.github.io/cc-safe-setup/token-checkup.html) · [**Cache Health**](https://yurukusa.github.io/cc-safe-setup/cache-health.html) · [**Version Check**](https://yurukusa.github.io/cc-safe-setup/version-check.html) · [**CLAUDE.md Analyzer**](https://yurukusa.github.io/cc-safe-setup/claudemd-analyzer.html) · [**All Tools**](https://yurukusa.github.io/cc-safe-setup/hub.html) · [**Recipes**](https://yurukusa.github.io/cc-safe-setup/recipes.html) · [Validate your settings.json](https://yurukusa.github.io/cc-safe-setup/validator.html) · [**Check your score**](https://yurukusa.github.io/cc-health-check/) (`npx cc-health-check`) · [**Safety Audit**](https://yurukusa.github.io/cc-safe-setup/safety-audit.html)
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
cc-safe-setup
|
|
23
|
-
Make Claude Code safe for autonomous operation
|
|
24
|
-
|
|
25
|
-
Prevents real incidents (from GitHub Issues):
|
|
26
|
-
✗ rm -rf permanently destroyed ~50 GB / 1,500 files (#49129) ← April 2026
|
|
27
|
-
✗ Auto mode approved ~/.ssh deletion — all SSH keys gone (#49554)
|
|
28
|
-
✗ ~/.git-credentials PATs deleted without confirmation (#49539)
|
|
29
|
-
✗ rm -rf deleted 3,467 files (~7 GB) without confirmation (#46058)
|
|
30
|
-
✗ rm -rf deleted entire user directory via NTFS junction (#36339)
|
|
31
|
-
✗ Remove-Item -Recurse -Force destroyed unpushed source (#37331)
|
|
32
|
-
✗ Entire Mac filesystem deleted during cleanup (#36233)
|
|
33
|
-
✗ Untested code pushed to main at 3am
|
|
34
|
-
✗ Force-push rewrote shared branch history
|
|
35
|
-
✗ API keys committed to public repos via git add .
|
|
36
|
-
✗ Syntax errors cascading through 30+ files
|
|
37
|
-
✗ Sessions losing all context with no warning
|
|
38
|
-
✗ CLAUDE.md rules silently ignored after context compaction
|
|
39
|
-
✗ Claude ran destructive DDL on production database (#46684)
|
|
40
|
-
✗ AI executed delete/kill operations on production environment (#46650)
|
|
41
|
-
✗ Subagents ignoring all CLAUDE.md rules since v2.1.84 (#40459)
|
|
42
|
-
|
|
43
|
-
Hooks to install:
|
|
44
|
-
|
|
45
|
-
● Destructive Command Blocker
|
|
46
|
-
● Branch Push Protector
|
|
47
|
-
● Post-Edit Syntax Validator
|
|
48
|
-
● Context Window Monitor
|
|
49
|
-
● Bash Comment Stripper
|
|
50
|
-
● cd+git Auto-Approver
|
|
51
|
-
● Secret Leak Prevention
|
|
52
|
-
|
|
53
|
-
Install all 8 safety hooks? [Y/n] Y
|
|
54
|
-
|
|
55
|
-
✓ Done. 8 safety hooks installed.
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Why This Exists
|
|
59
|
-
|
|
60
|
-
A user [lost 3,467 files (~7 GB)](https://github.com/anthropics/claude-code/issues/46058) when Claude ran `rm -rf` on their data directory without confirmation. Another [lost their entire C:\Users directory](https://github.com/anthropics/claude-code/issues/36339) when `rm -rf` followed NTFS junctions. Another [lost all source code](https://github.com/anthropics/claude-code/issues/37331) when Claude ran `Remove-Item -Recurse -Force *` on a repo. One user's Claude [ran destructive DDL on a production database](https://github.com/anthropics/claude-code/issues/46684) when asked only to investigate. Another had Claude [execute delete and kill operations on production systems](https://github.com/anthropics/claude-code/issues/46650). Others had untested code pushed to main at 3am. API keys got committed via `git add .`. Syntax errors cascaded through 30+ files before anyone noticed. And [CLAUDE.md rules get silently dropped](https://github.com/anthropics/claude-code/issues/6354) after context compaction — your instructions vanish mid-session.
|
|
61
|
-
|
|
62
|
-
One user [analyzed 6,852 sessions](https://github.com/anthropics/claude-code/issues/42796) and found the Read:Edit ratio dropped from 6.6 to 2.0 — Claude editing files it never read jumped from 6% to 34%. That issue has over 2,100 reactions. The `read-before-edit` example hook catches this pattern before damage happens.
|
|
63
|
-
|
|
64
|
-
In April 2026, [$1,446 was transferred without authorization](https://github.com/anthropics/claude-code/issues/46828) when Claude moved funds between exchange accounts. A user [lost $367 and got their account suspended](https://github.com/anthropics/claude-code/issues/47046) from a Claude-generated script. [Physical coordinates were uploaded to a public website](https://github.com/anthropics/claude-code/issues/46910) despite 17 sessions of "no PII" in CLAUDE.md. And [deny rules can be bypassed with 50+ subcommands](https://adversa.ai/blog/claude-code-security-bypass-deny-rules-disabled/).
|
|
65
|
-
|
|
66
|
-
Claude Code ships with no safety hooks by default. This tool fixes that. ([Standalone guard script](https://gist.github.com/yurukusa/87f51b97bb655357dd148b66109d0c14) for quick setup | [Database protection hooks](https://gist.github.com/yurukusa/ad27e541769992e9e0cd15c1b487a1d2) | [Credential protection hooks](https://gist.github.com/yurukusa/7292ead735df0aa673f0485eba5587f3) | [Fabrication detection hook](https://gist.github.com/yurukusa/03f4bbbab61f7ddf31049cc28a01d0d9) | [Security vulnerability hooks](https://gist.github.com/yurukusa/81f79ae6d760b27c17f2cd642ea846d7))
|
|
67
|
-
|
|
68
|
-
**Works with Auto Mode.** Claude Code's [Auto Mode sandboxing](https://www.anthropic.com/engineering/claude-code-sandboxing) provides container-level isolation. cc-safe-setup adds process-level hooks as defense-in-depth — catching destructive commands even outside sandboxed environments.
|
|
69
|
-
|
|
70
|
-
**Works with subagents.** Since v2.1.84, subagents and teammates [don't receive CLAUDE.md](https://github.com/anthropics/claude-code/issues/40459) — your project rules are silently skipped. Hooks operate at the process level, but [subagent tool calls may bypass PreToolUse hooks](https://github.com/anthropics/claude-code/issues/21460) in some configurations. As defense-in-depth, cc-safe-setup installs hooks at the user level (`~/.claude/settings.json`). The `subagent-claudemd-inject` example hook re-injects critical rules into subagent prompts.
|
|
71
|
-
|
|
72
|
-
### 🚨 Opus 4.7 Crisis (April 2026)
|
|
73
|
-
|
|
74
|
-
Opus 4.7 broke auto mode's safety classifier — it was [hardcoded to Opus 4.6](https://github.com/anthropics/claude-code/issues/49618). **If you use auto mode with Opus 4.7, dangerous commands run without the built-in safety check.** In 3 days: [50 GB permanently deleted](https://github.com/anthropics/claude-code/issues/49129), [~/.ssh wiped](https://github.com/anthropics/claude-code/issues/49554), [git credentials destroyed](https://github.com/anthropics/claude-code/issues/49539), [shell configs truncated to 0 bytes](https://github.com/anthropics/claude-code/issues/49615). Users report [4x token consumption](https://github.com/anthropics/claude-code/issues/49541) from silent model switches.
|
|
75
|
-
|
|
76
|
-
**One command to fix it:**
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
npx cc-safe-setup --opus47
|
|
6
|
+
```sh
|
|
7
|
+
npx github:yurukusa/cc-safe-setup
|
|
80
8
|
```
|
|
81
9
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
## What Gets Installed
|
|
85
|
-
|
|
86
|
-
| Hook | Prevents | Related Issues |
|
|
87
|
-
|------|----------|----------------|
|
|
88
|
-
| **Destructive Guard** | `rm -rf /`, `git reset --hard`, `git clean -fd`, `git checkout --force`, `sudo` + destructive, PowerShell `Remove-Item -Recurse -Force`, `rd /s /q`, NFS mount detection | [#46058](https://github.com/anthropics/claude-code/issues/46058) [#36339](https://github.com/anthropics/claude-code/issues/36339) [#36640](https://github.com/anthropics/claude-code/issues/36640) [#37331](https://github.com/anthropics/claude-code/issues/37331) |
|
|
89
|
-
| **Branch Guard** | Pushes to main/master + force-push (`--force`) on all branches | |
|
|
90
|
-
| **Secret Guard** | `git add .env`, credential files, `git add .` with .env present | [#6527](https://github.com/anthropics/claude-code/issues/6527) |
|
|
91
|
-
| **Syntax Check** | Python, Shell, JSON, YAML, JS errors after edits | |
|
|
92
|
-
| **Context Monitor** | Session state loss from context window overflow (40%→25%→20%→15% warnings) | |
|
|
93
|
-
| **Comment Stripper** | Bash comments breaking permission allowlists | [#29582](https://github.com/anthropics/claude-code/issues/29582) |
|
|
94
|
-
| **cd+git Auto-Approver** | Permission prompt spam for `cd /path && git log` | [#32985](https://github.com/anthropics/claude-code/issues/32985) [#16561](https://github.com/anthropics/claude-code/issues/16561) |
|
|
95
|
-
| **API Error Alert** | Silent session death from rate limits or API errors — desktop notification + log | |
|
|
96
|
-
|
|
97
|
-
Each hook exists because a real incident happened without it.
|
|
98
|
-
|
|
99
|
-
### Free diagnostic tools
|
|
100
|
-
|
|
101
|
-
| Tool | What it does |
|
|
102
|
-
|------|-------------|
|
|
103
|
-
| **[Token Checkup](https://yurukusa.github.io/cc-safe-setup/token-checkup.html)** | 5 questions → find where your tokens are going (30 seconds) |
|
|
104
|
-
| **[Security Checkup](https://yurukusa.github.io/cc-safe-setup/security-checkup.html)** | 6 questions based on real incidents ($1,800+ in losses) |
|
|
105
|
-
| **[Version Check](https://yurukusa.github.io/cc-safe-setup/version-check.html)** | Is your CC version affected by cache inflation? |
|
|
10
|
+
The command is interactive: it shows what each hook does and lets you choose which to install into your `~/.claude/settings.json` (or a project-local `.claude/settings.json`). Nothing is installed without your confirmation. MIT licensed.
|
|
106
11
|
|
|
107
|
-
|
|
12
|
+
> **Why not `npx cc-safe-setup`?** The npm release is stuck at 29.8.0 (2026-04-20) while this repository is at 30.0.4, and the gap is not cosmetic — 29.8.0 lets twenty-five command shapes through that the current code blocks. Details, including the comparison table, are in [The npm release is behind this repository](#the-npm-release-is-behind-this-repository) below.
|
|
108
13
|
|
|
109
|
-
|
|
110
|
-
|----------|-------------|-------|
|
|
111
|
-
| **[Token Book](https://yurukusa.github.io/cc-safe-setup/token-book.html)** | Cut token consumption in half. CLAUDE.md templates, hook configs, context management, 32 failure patterns with fixes. 44,000+ words from 800+ hours of real operation data. | ¥2,500 (~$17). Ch.1 free |
|
|
112
|
-
| **[Safety Guide](https://zenn.dev/yurukusa/books/6076c23b1cb18b)** | End-to-end Claude Code safety setup. From first install to overnight autonomous runs. | ¥800 (~$5). Ch.3 free |
|
|
14
|
+
Reading this in order, rather than by section: **[The Claude Code Safety Field Manual](https://leanpub.com/claude-code-safety-field-manual)** is this repository's documentation laid out as a path — the pre-flight checklist, what each guard actually refuses, how to make one fire on purpose so you can watch it work, and what to read in the log afterwards. The minimum price is zero.
|
|
113
15
|
|
|
114
|
-
|
|
16
|
+
## Something already broken? Start here
|
|
115
17
|
|
|
116
|
-
|
|
18
|
+
If you arrived from a search with something already broken, start here: the symptom on the
|
|
19
|
+
left, and the section that answers it on the right. Every section it points to is a
|
|
20
|
+
measurement on a real machine, not a guess. (A third of the visitors here do arrive from a
|
|
21
|
+
search engine — 51 of 152 unique visitors in the 14 days to 2026-09-19. The rest come from
|
|
22
|
+
links such as a gist or GitHub itself, or with no referrer recorded at all.)
|
|
117
23
|
|
|
118
|
-
|
|
24
|
+
| What you are seeing | Start here | Where |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| The hook refuses, and the tool call runs anyway | The refusal is in a shape or a word the event does not read — or the hook exited 1, crashed, or could not find `jq` | [A refusal the tool never reads](#a-refusal-the-tool-never-reads), then [Proving a hook fires](#proving-a-hook-fires) |
|
|
27
|
+
| The hook never seems to run at all | The session was started in a way that skips your hooks entirely | [Four ways your guards stop running at all](#four-ways-your-guards-stop-running-at-all) |
|
|
28
|
+
| The hook runs, but never on the commands you care about | Your pattern is anchored where your commands are not | [A hook can be installed, current, registered — and still never see you](#a-hook-can-be-installed-current-registered--and-still-never-see-you) |
|
|
29
|
+
| You are not sure the hook does anything | You have not fired it on purpose yet | [Proving a hook fires](#proving-a-hook-fires) |
|
|
30
|
+
| The hooks are installed but feel out of date | Installed copies are snapshots and do not update themselves | [Your installed hooks do not update themselves](#your-installed-hooks-do-not-update-themselves) |
|
|
31
|
+
| `npx cc-safe-setup` behaves unlike this page | npm is serving an older release | [The npm release is behind this repository](#the-npm-release-is-behind-this-repository) |
|
|
119
32
|
|
|
120
|
-
|
|
121
|
-
{
|
|
122
|
-
"type": "command",
|
|
123
|
-
"if": "Bash(git push *)",
|
|
124
|
-
"command": "~/.claude/hooks/test-before-push.sh"
|
|
125
|
-
}
|
|
126
|
-
```
|
|
33
|
+
## Install as a Claude Code plugin
|
|
127
34
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
## PermissionRequest Hooks (NEW)
|
|
131
|
-
|
|
132
|
-
Override Claude Code's built-in confirmation prompts. These run **after** the built-in safety checks, so they can auto-approve prompts that `permissions.allow` cannot suppress.
|
|
133
|
-
|
|
134
|
-
| Hook | What It Solves | Issue |
|
|
135
|
-
|------|---------------|-------|
|
|
136
|
-
| `quoted-flag-approver` | "Quoted characters in flag names" prompt on `git commit -m "msg"` | [#27957](https://github.com/anthropics/claude-code/issues/27957) |
|
|
137
|
-
| `bash-heuristic-approver` | Safety heuristic prompts for `$()`, backticks, ANSI-C quoting | [#30435](https://github.com/anthropics/claude-code/issues/30435) |
|
|
138
|
-
| `edit-always-allow` | Edit prompts in `.claude/skills/` despite `bypassPermissions` | [#36192](https://github.com/anthropics/claude-code/issues/36192) |
|
|
139
|
-
| `allow-git-hooks-dir` | Edit prompts in `.git/hooks/` for pre-commit/pre-push setup | |
|
|
140
|
-
| `allow-protected-dirs` | All protected directory prompts (CI/Docker environments) | [#36168](https://github.com/anthropics/claude-code/issues/36168) |
|
|
141
|
-
| `git-show-flag-sanitizer` | Strips invalid `--no-stat` from `git show` (wastes context on error) | [#13071](https://github.com/anthropics/claude-code/issues/13071) |
|
|
142
|
-
| `compact-blocker` | Blocks auto-compaction via PreCompact (preserves full context) | [#6689](https://github.com/anthropics/claude-code/issues/6689) |
|
|
143
|
-
| `webfetch-domain-allow` | Auto-approves WebFetch by domain (fixes broken `domain:*` wildcard) | [#9329](https://github.com/anthropics/claude-code/issues/9329) |
|
|
144
|
-
|
|
145
|
-
Install any of these: `npx cc-safe-setup --install-example <name>`
|
|
146
|
-
|
|
147
|
-
## Session Protection Hooks
|
|
148
|
-
|
|
149
|
-
Guards against issues that corrupt sessions or waste tokens silently.
|
|
150
|
-
|
|
151
|
-
| Hook | What It Solves | Issue |
|
|
152
|
-
|------|---------------|-------|
|
|
153
|
-
| `cch-cache-guard` | Blocks reads of Claude session/billing files that poison prompt cache via `cch=` substitution | [#40652](https://github.com/anthropics/claude-code/issues/40652) |
|
|
154
|
-
| `image-file-validator` | Blocks Read of fake image files (text in .png) that permanently corrupt sessions | [#24387](https://github.com/anthropics/claude-code/issues/24387) |
|
|
155
|
-
| `terminal-state-restore` | Restores Kitty keyboard protocol, cursor, bracketed paste on exit | [#39096](https://github.com/anthropics/claude-code/issues/39096) [#39272](https://github.com/anthropics/claude-code/issues/39272) |
|
|
156
|
-
| `large-read-guard` | Warns before reading large files via `cat`/`less` that waste context tokens | [#41617](https://github.com/anthropics/claude-code/issues/41617) |
|
|
157
|
-
| `prompt-usage-logger` | Logs every prompt with timestamps to track token consumption patterns | [#41249](https://github.com/anthropics/claude-code/issues/41249) |
|
|
158
|
-
| `compact-alert-notification` | Alerts when auto-compaction fires (tracks compact-rebuild cycles that burn tokens) | [#41788](https://github.com/anthropics/claude-code/issues/41788) |
|
|
159
|
-
| `token-budget-guard` | Blocks tool calls when estimated session cost exceeds a configurable threshold | [#38335](https://github.com/anthropics/claude-code/issues/38335) |
|
|
160
|
-
| `session-index-repair` | Rebuilds `sessions-index.json` on exit so `claude --resume` finds all sessions | [#25032](https://github.com/anthropics/claude-code/issues/25032) |
|
|
161
|
-
| `session-backup-on-start` | Backs up session JSONL files on start (protects against silent deletion) | [#41874](https://github.com/anthropics/claude-code/issues/41874) |
|
|
162
|
-
| `working-directory-fence` | Blocks Read/Edit/Write outside CWD (prevents operating on wrong project copy) | [#41850](https://github.com/anthropics/claude-code/issues/41850) |
|
|
163
|
-
| `mcp-warmup-wait` | Waits for MCP servers to initialize on session start (fixes first-turn tool errors) | [#41778](https://github.com/anthropics/claude-code/issues/41778) |
|
|
164
|
-
| `pre-compact-transcript-backup` | Full JSONL backup before compaction (protects against rate-limit data loss) | [#40352](https://github.com/anthropics/claude-code/issues/40352) |
|
|
165
|
-
| `conversation-history-guard` | Blocks access to session JSONL files (prevents 20x cache poisoning) | [#40524](https://github.com/anthropics/claude-code/issues/40524) |
|
|
166
|
-
| `read-before-edit` | Warns when Edit targets a file not recently Read (Read:Edit ratio dropped 70% — [#42796](https://github.com/anthropics/claude-code/issues/42796)) | [#42796](https://github.com/anthropics/claude-code/issues/42796) |
|
|
167
|
-
| `replace-all-guard` | Warns/blocks Edit `replace_all:true` (prevents bulk data corruption) | [#41681](https://github.com/anthropics/claude-code/issues/41681) |
|
|
168
|
-
| `ripgrep-permission-fix` | Auto-fixes vendored ripgrep +x permission on start (fixes broken commands/skills) | [#41933](https://github.com/anthropics/claude-code/issues/41933) |
|
|
169
|
-
|
|
170
|
-
## All 49 Commands
|
|
171
|
-
|
|
172
|
-
| Command | What It Does |
|
|
173
|
-
|---------|-------------|
|
|
174
|
-
| `npx cc-safe-setup` | Install 8 safety hooks |
|
|
175
|
-
| `--create "desc"` | Generate hook from plain English |
|
|
176
|
-
| `--audit [--fix\|--json\|--badge]` | Safety score 0-100 |
|
|
177
|
-
| `--lint` | Static analysis of config |
|
|
178
|
-
| `--diff <file>` | Compare settings |
|
|
179
|
-
| `--compare <a> <b>` | Side-by-side hook comparison |
|
|
180
|
-
| `--migrate` | Detect hooks from other projects |
|
|
181
|
-
| `--generate-ci` | Create GitHub Actions workflow |
|
|
182
|
-
| `--share` | Generate shareable URL |
|
|
183
|
-
| `--benchmark` | Measure hook speed |
|
|
184
|
-
| `--dashboard` | Real-time terminal UI |
|
|
185
|
-
| `--issues` | GitHub Issues each hook addresses |
|
|
186
|
-
| `--doctor` | Diagnose hook problems |
|
|
187
|
-
| `--watch` | Live blocked command feed |
|
|
188
|
-
| `--stats` | Block history analytics |
|
|
189
|
-
| `--learn [--apply]` | Pattern learning |
|
|
190
|
-
| `--scan [--apply]` | Tech stack detection |
|
|
191
|
-
| `--export / --import` | Team config sharing |
|
|
192
|
-
| `--verify` | Test each hook |
|
|
193
|
-
| `--install-example <name>` | Install from 701 examples |
|
|
194
|
-
| `--examples [filter]` | Browse examples by keyword |
|
|
195
|
-
| `--full` | All-in-one setup |
|
|
196
|
-
| `--status` | Check installed hooks |
|
|
197
|
-
| `--dry-run` | Preview changes |
|
|
198
|
-
| `--uninstall` | Remove all hooks |
|
|
199
|
-
| `--shield` | Maximum safety in one command |
|
|
200
|
-
| `--guard "rule"` | Instantly enforce a rule from English |
|
|
201
|
-
| `--suggest` | Predict risks from project analysis |
|
|
202
|
-
| `--from-claudemd` | Convert CLAUDE.md rules to hooks |
|
|
203
|
-
| `--team` | Project-level hooks for git sharing |
|
|
204
|
-
| `--profile [level]` | Switch safety profiles |
|
|
205
|
-
| `--save-profile <name>` | Save current hooks as profile |
|
|
206
|
-
| `--analyze` | Session analysis dashboard |
|
|
207
|
-
| `--health` | Hook health table |
|
|
208
|
-
| `--quickfix` | Auto-fix common problems |
|
|
209
|
-
| `--replay` | Visual blocked commands timeline |
|
|
210
|
-
| `--why <hook>` | Show real incident behind hook |
|
|
211
|
-
| `--migrate-from <tool>` | Migrate from other hook tools |
|
|
212
|
-
| `--diff-hooks [path]` | Compare hook configurations |
|
|
213
|
-
| `--init-project` | Full project setup (hooks + CLAUDE.md + CI) |
|
|
214
|
-
| `--score` | CI-friendly safety score (exit 1 if below threshold) |
|
|
215
|
-
| `--test-hook <name>` | Test a specific hook with sample input |
|
|
216
|
-
| `--simulate "cmd"` | Preview how all hooks react to a command |
|
|
217
|
-
| `--protect <path>` | Block edits to a file or directory |
|
|
218
|
-
| `--rules [file]` | Compile YAML rules into hooks |
|
|
219
|
-
| `--validate` | Validate all hook scripts (syntax + structure) |
|
|
220
|
-
| `--safe-mode` | Maximum protection: all safety hooks + strict config |
|
|
221
|
-
| `--changelog` | Show what changed in each version |
|
|
222
|
-
| `--report` | Generate safety report |
|
|
223
|
-
| `--help` | Show help |
|
|
224
|
-
|
|
225
|
-
## Quick Start by Scenario
|
|
226
|
-
|
|
227
|
-
| I want to... | Command |
|
|
228
|
-
|---|---|
|
|
229
|
-
| Make Claude Code safe right now | `npx cc-safe-setup --shield` |
|
|
230
|
-
| Stop permission prompt spam | `npx cc-safe-setup --install-example auto-approve-readonly` |
|
|
231
|
-
| Enforce a rule instantly | `npx cc-safe-setup --guard "never delete production data"` |
|
|
232
|
-
| See what risks my project has | `npx cc-safe-setup --suggest` |
|
|
233
|
-
| Convert CLAUDE.md rules to hooks | `npx cc-safe-setup --from-claudemd` |
|
|
234
|
-
| Share hooks with my team | `npx cc-safe-setup --team && git add .claude/` |
|
|
235
|
-
| Choose a safety level | `npx cc-safe-setup --profile strict` |
|
|
236
|
-
| See what Claude blocked today | `npx cc-safe-setup --replay` |
|
|
237
|
-
| Know why a hook exists | `npx cc-safe-setup --why destructive-guard` |
|
|
238
|
-
| Block silent memory file edits | `npx cc-safe-setup --install-example memory-write-guard` |
|
|
239
|
-
| Stop built-in skills editing opaquely | `npx cc-safe-setup --install-example skill-gate` |
|
|
240
|
-
| Diagnose why hooks aren't working | `npx cc-safe-setup --doctor` |
|
|
241
|
-
| Preview how hooks react to a command | `npx cc-safe-setup --simulate "git push origin main"` |
|
|
242
|
-
| Protect a specific file from edits | `npx cc-safe-setup --protect .env` |
|
|
243
|
-
| Stop .git/ write prompts | `npx cc-safe-setup --install-example allow-git-hooks-dir` |
|
|
244
|
-
| Auto-approve compound git commands | `npx cc-safe-setup --install-example auto-approve-compound-git` |
|
|
245
|
-
| Detect prompt injection patterns | `npx cc-safe-setup --install-example prompt-injection-detector` |
|
|
246
|
-
| Define rules in YAML, compile to hooks | `npx cc-safe-setup --rules rules.yaml` |
|
|
247
|
-
| Validate all hook scripts are correct | `npx cc-safe-setup --validate` |
|
|
248
|
-
| Maximum protection mode | `npx cc-safe-setup --safe-mode` |
|
|
249
|
-
| Migrate from Cursor/Windsurf | [Migration Guide](https://yurukusa.github.io/cc-safe-setup/migration-guide.html) |
|
|
250
|
-
|
|
251
|
-
## Plugin Marketplace
|
|
252
|
-
|
|
253
|
-
Install safety hooks as Claude Code plugins — no npm required:
|
|
35
|
+
The core guard sets are also published as Claude Code plugins from this repository. They install from inside Claude Code and track the default branch, so they do not depend on the npm release at all.
|
|
254
36
|
|
|
255
|
-
```
|
|
37
|
+
```sh
|
|
256
38
|
/plugin marketplace add yurukusa/cc-safe-setup
|
|
257
39
|
/plugin install safety-essentials@cc-safe-setup
|
|
258
40
|
```
|
|
259
41
|
|
|
260
42
|
| Plugin | What it blocks |
|
|
261
|
-
|
|
262
|
-
| `safety-essentials` | rm -rf
|
|
263
|
-
| `git-protection` |
|
|
264
|
-
| `credential-guard` |
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `safety-essentials` | `rm -rf`, force-push, `git reset --hard`, writes to `.env`, package publish |
|
|
45
|
+
| `git-protection` | force-push, direct pushes to `main`/`master`, hard reset, interactive rebase, `git clean -fd` |
|
|
46
|
+
| `credential-guard` | `Write`/`Edit` to paths matching `.env`, `.env.*`, `credentials`, `secret`, `serviceaccount*.json`, `key.json`. API keys in Bash commands are **warned about, not blocked** — see the limits below |
|
|
47
|
+
| `token-guard` | reads over 100KB, a per-session read budget, subagent fan-out, a token budget that asks for `/compact` |
|
|
48
|
+
|
|
49
|
+
These are the guards only. The example-hook library, `--doctor`, `--audit`, and the rest of the CLI come from the npm package or from this repository directly.
|
|
50
|
+
|
|
51
|
+
### Measured limits of `credential-guard` (2026-09-04, against npm 29.8.0)
|
|
52
|
+
|
|
53
|
+
These are the exit codes, not the intent. Read them before trusting the row above.
|
|
54
|
+
|
|
55
|
+
- **Bash is never blocked by this plugin.** Both of its `Bash` hooks print a warning to stderr
|
|
56
|
+
and return 0. `export ANTHROPIC_API_KEY=…`, `curl -H "Authorization: Bearer …"`, and
|
|
57
|
+
`git commit -m "… <key> …"` all run. 0 of 6 shapes were blocked.
|
|
58
|
+
- **The same write through Bash is invisible.** `Write` to `~/app/.env` is blocked, but
|
|
59
|
+
`cp k.env ~/app/.env`, `sed -i … ~/app/.env`, `printf … >> ~/app/.env` and `tee` are not.
|
|
60
|
+
Install `examples/secret-file-write-guard.sh` for that (it covers 9 of 11 such shapes;
|
|
61
|
+
`git add .env` belongs to `dotenv-commit-guard.sh`, and writes made inside an interpreter,
|
|
62
|
+
e.g. `python3 -c "open('.env','w')…"`, cannot be seen from the command string at all).
|
|
63
|
+
- **"Service-account files" is narrower than it sounds, and case-sensitive.** The patterns are
|
|
64
|
+
`serviceaccount.*\.json`, `key\.json`, `credentials\.json`. So `credentials.json` and
|
|
65
|
+
`application_default_credentials.json` are blocked, but `gcp-service-account.json`,
|
|
66
|
+
`service_account.json`, `serviceAccountKey.json` and `firebase-adminsdk.json` are **not**
|
|
67
|
+
(2 of 7 shapes blocked). A hyphen, an underscore or a capital letter is enough to pass.
|
|
68
|
+
- `.env` itself holds up: `.env`, `.env.production`, `.env.local` and `Edit` on `.env` were all
|
|
69
|
+
blocked (4 of 4).
|
|
70
|
+
|
|
71
|
+
Hooks stop a tool call before it runs. They are not a permission boundary — pair them with
|
|
72
|
+
`permissions.deny` and keep secrets outside the repository.
|
|
73
|
+
|
|
74
|
+
## The npm release is behind this repository
|
|
75
|
+
|
|
76
|
+
`npx cc-safe-setup` currently installs **29.8.0**, published 2026-04-20. This repository is at **30.0.4**. Publishing is blocked on renewing an npm credential, so npm keeps serving 29.8.0 until that is done.
|
|
77
|
+
|
|
78
|
+
The gap is not cosmetic. I fired twenty-two command shapes at both versions on 2026-09-03, feeding each guard the same JSON on stdin and running it with `bash` — the shell the installer names when it registers the hook. The guards shipped in 29.8.0 allow **nine** of those shapes that 30.0.4 refuses. Nothing went the other way: there is no shape 29.8.0 blocks and 30.0.4 lets through, and two harmless controls (`rm -rf node_modules`, `git push origin feature`) are allowed by both. Only `exit 2` counts as blocked here; `exit 1`, `exit 127` and a crash all let the command run.
|
|
79
|
+
|
|
80
|
+
The other thirteen behaved identically in both versions, and they are the plain forms: `rm -rf /`, `cd /tmp && sudo rm -rf /var/log`, `find . -name '*.log' | xargs rm -rf /`, `rm -rf ~/Documents/`, `git reset --hard HEAD~5`, `git clean -fd`, `chmod -R 777 /`, `git push --force origin main`, `git push origin +main`, `git push origin main`, `git add .env`, and the two controls. In other words, 29.8.0 stops the shape you would write in a tutorial and misses the shape a shell actually produces.
|
|
81
|
+
|
|
82
|
+
All nine:
|
|
83
|
+
|
|
84
|
+
| Command seen by the hook | Guard | 29.8.0 | 30.0.4 |
|
|
85
|
+
| --- | --- | --- | --- |
|
|
86
|
+
| `rm -rf \` with `~/Documents` on the next line — one deletion split over two lines | destructive-guard | allowed | blocked |
|
|
87
|
+
| `rm --recursive --force /` — long-form spelling of `-rf` | destructive-guard | allowed | blocked |
|
|
88
|
+
| a base64 blob decoded and piped into `sh`, carrying `rm -rf ~` | destructive-guard | allowed | blocked |
|
|
89
|
+
| `rm -rf "$HOME"` — home directory reached through a quoted variable | destructive-guard | allowed | blocked |
|
|
90
|
+
| `git push -uf origin feature` — force bundled into a short-flag cluster | branch-guard | allowed | blocked |
|
|
91
|
+
| `cd repo && git push --force origin main` — force push after a separator | branch-guard | allowed | blocked |
|
|
92
|
+
| `git -C /repo push --force` — git's own option placed before the verb | branch-guard | allowed | blocked |
|
|
93
|
+
| `cd app && git add .env` — a secret staged after a separator | secret-guard | allowed | blocked |
|
|
94
|
+
| `git add \` with `.env` on the next line — the same, split over two lines | secret-guard | allowed | blocked |
|
|
95
|
+
|
|
96
|
+
### Re-measured 2026-09-14: twenty-five, not nine
|
|
97
|
+
|
|
98
|
+
Two fixes landed here on 2026-09-14 ([#1120](https://github.com/yurukusa/cc-safe-setup/pull/1120),
|
|
99
|
+
[#1121](https://github.com/yurukusa/cc-safe-setup/pull/1121), and the follow-up that
|
|
100
|
+
carried #1121 into `branch-guard` and `secret-guard`), so the sentence above — written in
|
|
101
|
+
the present tense about "the current code" — went stale the same morning it was true.
|
|
102
|
+
|
|
103
|
+
Fired again that evening, same method, same `bash`, same JSON on stdin. The original
|
|
104
|
+
twenty-two shapes still split nine and thirteen: 29.8.0 cannot move. What moved is the
|
|
105
|
+
list. Widening it to forty-one shapes puts the gap at **twenty-five**, and nothing still
|
|
106
|
+
goes the other way.
|
|
107
|
+
|
|
108
|
+
The sixteen new ones:
|
|
109
|
+
|
|
110
|
+
| Shape family | Example | Guard |
|
|
111
|
+
| --- | --- | --- |
|
|
112
|
+
| git reached through a path | `/usr/bin/git push --force origin main`, `./git push --force origin main`, `/usr/bin/git clean -fd` | branch-guard, destructive-guard |
|
|
113
|
+
| git behind a wrapper | `sudo git push --force origin main`, `time …`, `nohup …` | branch-guard |
|
|
114
|
+
| git behind an assignment | `env FOO=1 git push --force origin main`, `FOO=1 git push --force origin main` | branch-guard |
|
|
115
|
+
| a global option whose value is not a `.git` path | `git --git-dir=/tmp/r/repo.d push --force`, `git --work-tree=/tmp/w --git-dir=… push --force`, `git -c user.name=x push --force`, `git --namespace=ns push --force` | branch-guard |
|
|
116
|
+
| the plumbing spelling of a push | `git send-pack --force origin main` | branch-guard |
|
|
117
|
+
| `-C` in front of the other verbs | `git -C /repo add .env`, `git -C /repo reset --hard HEAD~5`, `git -C /repo clean -fd` | secret-guard, destructive-guard |
|
|
118
|
+
|
|
119
|
+
The script that produces this comparison is checked in as
|
|
120
|
+
`tests/git-invocation-prefixes-all-guards.test.sh` for the current code; the
|
|
121
|
+
version-against-version run is in the book's evidence folder.
|
|
122
|
+
|
|
123
|
+
If you are reading this to decide whether the gap matters to you: the number is not the
|
|
124
|
+
point. The point is that it grows every time this repository improves and never shrinks,
|
|
125
|
+
because the published package is frozen.
|
|
126
|
+
|
|
127
|
+
29.8.0 on npm ships **698** example hooks; this repository has **916**. The 218 that are missing from the published package include `agents-md-sync-checker`. (Counted 2026-08-26 from the published tarball and this tree; the tree was recounted on 2026-09-20 and had gained two since.)
|
|
128
|
+
|
|
129
|
+
To install the current code directly from this repository:
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
npx github:yurukusa/cc-safe-setup
|
|
133
|
+
```
|
|
269
134
|
|
|
270
|
-
|
|
271
|
-
|---|---|---|
|
|
272
|
-
| Claude uses `cat`/`grep`/`sed` instead of built-in Read/Edit/Grep | [#19649](https://github.com/anthropics/claude-code/issues/19649) (48👍) | `npx cc-safe-setup --install-example prefer-builtin-tools` |
|
|
273
|
-
| `cd /path && cmd` bypasses permission allowlist | [#28240](https://github.com/anthropics/claude-code/issues/28240) (88👍) | `npx cc-safe-setup --install-example compound-command-approver` |
|
|
274
|
-
| Multiline commands skip pattern matching | [#11932](https://github.com/anthropics/claude-code/issues/11932) (47👍) | Use hooks instead of allowlist patterns for complex commands |
|
|
275
|
-
| No notification when Claude asks a question | [#13024](https://github.com/anthropics/claude-code/issues/13024) (52👍) | `npx cc-safe-setup --install-example notify-waiting` |
|
|
276
|
-
| `allow` overrides `ask` in permissions | [#6527](https://github.com/anthropics/claude-code/issues/6527) (17👍) | Use hooks to block dangerous commands instead of `ask` rules |
|
|
277
|
-
| Plans stored in `~/.claude/` with random names | [#12619](https://github.com/anthropics/claude-code/issues/12619) (163👍) | `npx cc-safe-setup --install-example plan-repo-sync` |
|
|
135
|
+
That resolves to the default branch. To pin an exact revision, append a commit SHA — `npx github:yurukusa/cc-safe-setup#<sha>`. Pin by SHA rather than by tag: the tag names here come from an older numbering that no longer tracks `package.json`.
|
|
278
136
|
|
|
279
|
-
##
|
|
137
|
+
## Why this exists
|
|
280
138
|
|
|
281
|
-
|
|
282
|
-
2. Updates `~/.claude/settings.json` to register the hooks
|
|
283
|
-
3. Restart Claude Code — hooks are active
|
|
139
|
+
Claude Code can run shell commands, edit files, and call tools on your behalf. Most of the time that is fine. But a single command — `rm -rf`, a force-push, `terraform destroy`, `php artisan migrate:fresh`, a `git checkout --orphan` followed by `git rm -rf .` — can destroy work in a way that is not recoverable, and it can happen without an error or a warning.
|
|
284
140
|
|
|
285
|
-
|
|
141
|
+
Claude Code's built-in safety checks match shell-level danger patterns. Many destructive operations do not look like those patterns: a framework verb, a tool-call, or a config file poisoned from outside the tool boundary all slip past. These hooks add a second layer that inspects the operation at the tool boundary and refuses the dangerous ones, while letting normal work through.
|
|
286
142
|
|
|
287
|
-
|
|
143
|
+
## What you need installed
|
|
288
144
|
|
|
289
|
-
**
|
|
145
|
+
**Nothing from npm** — this package has no dependencies and installs none.
|
|
290
146
|
|
|
291
|
-
**
|
|
147
|
+
**One JSON reader, though.** A hook is handed its tool call as JSON on stdin, so it needs
|
|
148
|
+
something that can read JSON. The eight core hooks try `jq`, then `python3`, then `node`, and
|
|
149
|
+
if none of the three is present they print a warning that says they are **not** protecting you,
|
|
150
|
+
then allow the command (blocking every call would make Claude Code unusable, which is a
|
|
151
|
+
failure, not safety).
|
|
292
152
|
|
|
293
|
-
**
|
|
153
|
+
The example hooks are stricter about this than the core ones: **757 of the 916 mention `jq`
|
|
154
|
+
and contain no `python3` or `node` anywhere in the file** — 810 mention `jq` at all, and 53 of
|
|
155
|
+
those also mention a possible fallback. (Counted 2026-09-20 with `grep -l` over `examples/*.sh`;
|
|
156
|
+
an earlier edition claimed 798 of 914, which none of three plausible counting rules reproduced,
|
|
157
|
+
so the rule is spelled out here instead of the number being carried forward.) Without `jq` they
|
|
158
|
+
read an empty command and quietly do nothing — no error, no log line, and they still appear in
|
|
159
|
+
your `settings.json`. If you take examples from `examples/`, install `jq` first.
|
|
294
160
|
|
|
295
|
-
|
|
161
|
+
```sh
|
|
162
|
+
jq --version || sudo apt-get install -y jq # or: brew install jq
|
|
163
|
+
```
|
|
296
164
|
|
|
297
|
-
|
|
165
|
+
This used to be described as "dependency-free", which was wrong in the direction that matters:
|
|
166
|
+
it let someone on a minimal container believe they were protected when the hooks were reading
|
|
167
|
+
nothing. Corrected 2026-08-03 after counting the actual tool calls in the shipped scripts.
|
|
298
168
|
|
|
299
|
-
|
|
169
|
+
## What gets installed
|
|
300
170
|
|
|
301
|
-
|
|
171
|
+
Hooks are small shell scripts. Each is one file, does one thing, and exits with code `2` to block or `0` to allow. They fall into a few groups:
|
|
302
172
|
|
|
303
|
-
**
|
|
173
|
+
- **Destructive-operation guards** — refuse `rm -rf` on protected paths, force-push, `git reset --hard`, whole-tree `git rm`, framework database resets (`migrate:fresh`, `db:reset`, `prisma migrate reset`), cloud teardown verbs (`terraform destroy`, `aws … terminate`, `kubectl delete namespace`), and move-then-delete sequences.
|
|
174
|
+
- **Data-loss prevention** — a recycle bin for deleted files, backups before refactors, detection of NUL-corrupted writes, and guards for the `mv`/glob/`rm` and worktree failure modes.
|
|
175
|
+
- **Cost and quota** — token-spike early warnings, per-session budget limits, subagent fan-out limits, and warnings when usage is silently routed to API billing.
|
|
176
|
+
- **Silent-failure surfacing** — detectors for fabricated tool results, unverified "done" claims, forged system-reminder markup from sub-agents, and config poisoned from outside the tool boundary (read-only audits that warn, never edit).
|
|
177
|
+
- **Session and config protection** — backups of `settings.json`, drift detection, and recovery helpers.
|
|
178
|
+
- **Code-quality checks** (opt-in) — syntax checks, test-before-commit, and language-specific linters that run after edits.
|
|
304
179
|
|
|
305
|
-
|
|
180
|
+
Run `npx github:yurukusa/cc-safe-setup --list` to see every available hook with its description.
|
|
306
181
|
|
|
307
|
-
|
|
182
|
+
## How it works
|
|
308
183
|
|
|
309
|
-
|
|
184
|
+
Claude Code calls a hook before (or after) a tool runs and passes it JSON on stdin describing the tool call. The hook reads the command, decides, and communicates through its exit code:
|
|
310
185
|
|
|
311
|
-
|
|
312
|
-
|
|
186
|
+
```sh
|
|
187
|
+
#!/bin/sh
|
|
188
|
+
CMD=$(cat | jq -r '.tool_input.command // empty')
|
|
189
|
+
case "$CMD" in
|
|
190
|
+
*"migrate:fresh"*|*"db:wipe"*)
|
|
191
|
+
echo "Blocked: destructive database reset. Use an incremental migration." >&2
|
|
192
|
+
exit 2 ;; # exit 2 = block the tool call
|
|
193
|
+
esac
|
|
194
|
+
exit 0 # exit 0 = allow
|
|
195
|
+
```
|
|
313
196
|
|
|
314
|
-
|
|
197
|
+
Because the check happens at the tool boundary, it fires regardless of how the command was constructed, and it works in auto-accept mode where a human is not reviewing each step.
|
|
315
198
|
|
|
316
|
-
|
|
199
|
+
## Writing your own hook
|
|
317
200
|
|
|
318
|
-
|
|
319
|
-
|---|--------|-------|
|
|
320
|
-
| Safety Guards | 25% | **75%** |
|
|
321
|
-
| Overall Score | 50/100 | **95/100** |
|
|
322
|
-
| Destructive commands | Unprotected | Blocked |
|
|
323
|
-
| Force push | Allowed | Blocked |
|
|
324
|
-
| `.env` in git | Possible | Blocked |
|
|
325
|
-
| Context warnings | None | 4-stage alerts |
|
|
201
|
+
A hook is any executable that reads the tool-call JSON on stdin and returns `0` (allow) or `2` (block, with a message on stderr). Drop it in your hooks directory and reference it from `settings.json` under the matching trigger (`PreToolUse`, `PostToolUse`, `SessionStart`, `Stop`, `SubagentStop`, `PermissionRequest`) with a `matcher` for the tool it should watch. See `examples/` for working scripts to copy.
|
|
326
202
|
|
|
327
|
-
##
|
|
203
|
+
## Safety audit and CI
|
|
328
204
|
|
|
329
|
-
|
|
330
|
-
|----------|------|---------|
|
|
331
|
-
| `CC_ALLOW_DESTRUCTIVE=1` | destructive-guard | `0` (protection on) |
|
|
332
|
-
| `CC_SAFE_DELETE_DIRS` | destructive-guard | `node_modules:dist:build:.cache:__pycache__:coverage` |
|
|
333
|
-
| `CC_PROTECT_BRANCHES` | branch-guard | `main:master` |
|
|
334
|
-
| `CC_ALLOW_FORCE_PUSH=1` | branch-guard | `0` (protection on) |
|
|
335
|
-
| `CC_SECRET_PATTERNS` | secret-guard | `.env:.env.local:credentials:*.pem:*.key` |
|
|
336
|
-
| `CC_CONTEXT_MISSION_FILE` | context-monitor | `$HOME/mission.md` |
|
|
205
|
+
`npx github:yurukusa/cc-safe-setup --audit` reports which classes of danger are and are not guarded.
|
|
337
206
|
|
|
338
|
-
|
|
207
|
+
Most of what it checks lives inside `settings.json`. One check does not: it reads the safety nets your `CLAUDE.md` **names** against the hooks your settings files actually **register**, and reports the two mismatches that no single-file check can see — a rule naming a script that exists nowhere, and a hook sitting in your hooks directory that appears in no settings file at all. Both files are individually valid in that second case; the guard simply never runs.
|
|
339
208
|
|
|
340
|
-
|
|
209
|
+
You can run the same audit in CI to keep a project's safety posture from regressing:
|
|
341
210
|
|
|
342
|
-
```
|
|
343
|
-
|
|
211
|
+
```yaml
|
|
212
|
+
# .github/workflows/safety.yml
|
|
213
|
+
- run: npx github:yurukusa/cc-safe-setup --audit --ci
|
|
344
214
|
```
|
|
345
215
|
|
|
346
|
-
|
|
216
|
+
`--ci` exits `1` when the audit finds a `CRITICAL` or `HIGH` risk, and `0` otherwise. The line
|
|
217
|
+
is drawn there and not at "any risk" because a machine set up the way this tool recommends
|
|
218
|
+
still carries a `MEDIUM` finding, and a gate that reddens a correct setup gets deleted by the
|
|
219
|
+
first person who sees the build. Set `CC_AUDIT_THRESHOLD` to also fail below a score.
|
|
347
220
|
|
|
348
|
-
|
|
221
|
+
**If you added this step before 2026-09-03, it never failed.** `--ci` was in this README and
|
|
222
|
+
in nobody's code: the exit compared the score against a default threshold of `0`, and a score
|
|
223
|
+
cannot go below `0`, so the step passed whatever the audit found. That is worse than having no
|
|
224
|
+
step, because the belief that a regression would be caught is what stops you looking. It is
|
|
225
|
+
implemented now, and `tests/audit-ci-gate.test.sh` fails if it ever stops failing.
|
|
349
226
|
|
|
350
|
-
|
|
227
|
+
`--audit` is what a script can decide on its own. For the contradictions that need your
|
|
228
|
+
session logs and CI read alongside your config, there are
|
|
229
|
+
[written audits](#written-audits) below — asynchronous, and nothing is ever
|
|
230
|
+
run in your environment.
|
|
351
231
|
|
|
352
|
-
|
|
232
|
+
### Proving a hook fires
|
|
353
233
|
|
|
354
|
-
|
|
234
|
+
`--audit` reads configuration. It cannot tell you whether a registered hook actually
|
|
235
|
+
refuses anything, and that is where most of the damage in `examples/` came from: a
|
|
236
|
+
guard that is present, registered, and silent.
|
|
355
237
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
## Safety Audit
|
|
359
|
-
|
|
360
|
-
**[Try it in your browser](https://yurukusa.github.io/cc-safe-setup/)** — paste your settings.json, get a score instantly. Nothing leaves your browser.
|
|
361
|
-
|
|
362
|
-
Or from the CLI:
|
|
238
|
+
`audit/` holds four small scripts for the other half.
|
|
363
239
|
|
|
364
240
|
```bash
|
|
365
|
-
|
|
241
|
+
# does this guard refuse the operation it was written to refuse?
|
|
242
|
+
audit/fire.sh ~/.claude/hooks/YOUR-HOOK.sh Bash "command=<the dangerous command>"
|
|
243
|
+
# exit 2 = refused, exit 0 = Claude Code runs it
|
|
244
|
+
# (a hook that refuses through JSON exits 0 and still blocks — this line will call it
|
|
245
|
+
# "allowed". See "A refusal the tool never reads" below before rewriting such a hook.)
|
|
246
|
+
|
|
247
|
+
# same hook, on a machine with no jq, no python3 and no node
|
|
248
|
+
audit/fire.sh --bare ~/.claude/hooks/YOUR-HOOK.sh Bash "command=<the dangerous command>"
|
|
366
249
|
```
|
|
367
250
|
|
|
368
|
-
|
|
251
|
+
The `--bare` run is the one worth doing today. **757 of the 916 example hooks here mention
|
|
252
|
+
`jq` and contain no `python3` or `node` fallback anywhere in the file** (counted 2026-09-20).
|
|
253
|
+
Without a JSON parser they print a warning to stderr and exit `0` — and Claude Code stops for
|
|
254
|
+
exit code `2`, not for warnings.
|
|
369
255
|
|
|
370
|
-
|
|
256
|
+
`audit/count-hooks.py` counts registrations across all three settings files;
|
|
257
|
+
`audit/find-dead-hooks.sh` lists registrations whose script is not on disk (those fail to
|
|
258
|
+
launch, which Claude Code treats as non-blocking, so nothing surfaces);
|
|
259
|
+
`audit/selftest.sh` proves that detector really detects, because a detector that has never
|
|
260
|
+
found anything is not yet evidence of anything. `audit/audit-checklist.md` is a 50-point
|
|
261
|
+
sheet covering hooks, git, secrets, cost, autonomous operation and multi-agent work.
|
|
371
262
|
|
|
372
|
-
|
|
373
|
-
# .github/workflows/safety.yml
|
|
374
|
-
- uses: yurukusa/cc-safe-setup@main
|
|
375
|
-
with:
|
|
376
|
-
threshold: 70 # CI fails if score drops below this
|
|
377
|
-
```
|
|
263
|
+
## A refusal the tool never reads
|
|
378
264
|
|
|
379
|
-
|
|
265
|
+
A `PreToolUse` hook can run, compute the right decision, print it, and be ignored. Nothing
|
|
266
|
+
errors. The hook exits 0, there is no verdict, and the tool call proceeds — so the logs of a
|
|
267
|
+
guard that is silently open look exactly like the logs of one that is working.
|
|
380
268
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
269
|
+
Measured 2026-09-19 on Claude Code 2.1.278, one hook at a time on `PreToolUse` with matcher
|
|
270
|
+
`Write`, in a throwaway `HOME`. Each hook appended a line to its own log before printing, so
|
|
271
|
+
"never invoked" and "invoked and ignored" stay separable. The verdict is whether the file
|
|
272
|
+
exists on disk afterwards, not what the transcript says:
|
|
385
273
|
|
|
386
|
-
|
|
274
|
+
| What the hook printed | Hook ran | File created |
|
|
275
|
+
|---|---|---|
|
|
276
|
+
| nothing, `exit 0` *(control)* | yes | yes |
|
|
277
|
+
| `{"permissionDecision":"deny", …}` — **at the top level** | yes | **yes — ignored** |
|
|
278
|
+
| `{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny", …}}` | yes | no |
|
|
279
|
+
| `{"decision":"block","reason":…}`, `exit 0` — the older shape | yes | no |
|
|
280
|
+
| `{"decision":"deny"}` | yes | **yes — ignored** |
|
|
281
|
+
| stderr + `exit 2` | yes | no |
|
|
282
|
+
|
|
283
|
+
The uppercase `{"decision":"DENY"}` was measured the same day, but on matcher `Bash` and with
|
|
284
|
+
the verdict being whether the command actually ran; it was ignored there too. It is left out
|
|
285
|
+
of the table above because it was not fired under these conditions.
|
|
286
|
+
|
|
287
|
+
Two things fall out of that table.
|
|
288
|
+
|
|
289
|
+
**`permissionDecision` belongs inside `hookSpecificOutput`.** At the top level it is not read
|
|
290
|
+
here. The minimal repro in [anthropics/claude-code#91574](https://github.com/anthropics/claude-code/issues/91574)
|
|
291
|
+
(open since 2026-09-02, reported against 2.1.245 on macOS) uses the top-level shape, so this
|
|
292
|
+
is one thing worth ruling out before anything else. It is not a diagnosis of that report: the
|
|
293
|
+
same report also says `PreToolUse` never registers in the debug trace at all, and nothing
|
|
294
|
+
about an unreadable body explains a missing registration line.
|
|
295
|
+
|
|
296
|
+
**The older `{"decision": …}` field answers to `block`.** It still refuses on 2.1.278 — if you
|
|
297
|
+
have a working hook using it, leave it alone. `deny` and `DENY` are dropped in silence. Other
|
|
298
|
+
values were not fired, so treat this as two data points rather than a vocabulary. One of the guards in this repository's
|
|
299
|
+
example library did exactly that, on three branches that block irreversible deletions, from
|
|
300
|
+
the day it was written until it was measured. Its tests were green the whole time, because
|
|
301
|
+
they asserted that the string `"decision":"DENY"` appeared on stdout and never looked at the
|
|
302
|
+
exit code. It refuses with `exit 2` as of 2026-09-19. **If you copied that example before
|
|
303
|
+
then, take it again** — or run `--outdated`, which compares your installed copies against
|
|
304
|
+
what ships today.
|
|
305
|
+
|
|
306
|
+
### Checking your own, in two runs
|
|
307
|
+
|
|
308
|
+
`exit 2` carries no JSON, so it cannot be misparsed. Replace the line that prints your JSON
|
|
309
|
+
with these two — do not keep both, because printing a body *and* exiting 2 was not measured:
|
|
387
310
|
|
|
388
311
|
```bash
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
npx cc-safe-setup --create "block curl pipe to bash"
|
|
392
|
-
npx cc-safe-setup --create "block DROP TABLE and TRUNCATE"
|
|
312
|
+
echo "denied" >&2
|
|
313
|
+
exit 2
|
|
393
314
|
```
|
|
394
315
|
|
|
395
|
-
|
|
316
|
+
If the call is blocked now, your hook was always being consulted and the JSON shape was the
|
|
317
|
+
problem. If it still goes through, the shape is a red herring: either the hook is not
|
|
318
|
+
loaded at all, or it is loaded and your pattern never matches what you actually run. Go to
|
|
319
|
+
[Four ways your guards stop running at all](#four-ways-your-guards-stop-running-at-all) and
|
|
320
|
+
[A hook can be installed, current, registered — and still never see you](#a-hook-can-be-installed-current-registered--and-still-never-see-you).
|
|
396
321
|
|
|
397
|
-
|
|
322
|
+
Run it twice: once with a hook that only does `exit 0`, once with yours. The first run must
|
|
323
|
+
let the operation through. Without that control, "nothing happened" can mean the guard
|
|
324
|
+
worked, or that the command was broken, or that the harness never fired.
|
|
398
325
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
326
|
+
One practical difference, once you have a choice: both of the JSON shapes that do refuse —
|
|
327
|
+
the nested `permissionDecision` and `{"decision":"block"}` — reach the model as
|
|
328
|
+
`PreToolUse:Write hook error: <your reason>` (measured on `Write`), with nothing identifying
|
|
329
|
+
which hook produced it. `exit 2` arrives with the hook's absolute path in front of the
|
|
330
|
+
message. With more than a couple of hooks on the same tool, that is the difference between
|
|
331
|
+
opening one file and opening all of them.
|
|
403
332
|
|
|
404
|
-
##
|
|
405
|
-
|
|
406
|
-
Need custom hooks beyond the 8 built-in ones? Install any example with one command:
|
|
333
|
+
## A hook can be installed, current, registered — and still never see you
|
|
407
334
|
|
|
408
335
|
```bash
|
|
409
|
-
npx cc-safe-setup --
|
|
336
|
+
npx github:yurukusa/cc-safe-setup --blindspots
|
|
410
337
|
```
|
|
411
338
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
- **
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
- **
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
339
|
+
Every other check here reads one layer. `--status` reads the scripts on disk, `--lint` the
|
|
340
|
+
settings file, `--stats` the block log, `--outdated` the shipped bodies. A guard can pass all
|
|
341
|
+
four and still never fire, because the shape of the commands you actually run never reaches
|
|
342
|
+
it. That gap does not live inside any one layer, so no single-layer check can report it.
|
|
343
|
+
|
|
344
|
+
`--blindspots` reads your own session transcripts next to your own guards and reports what
|
|
345
|
+
each start-anchored pattern really matches. On the machine it was written on: 38,066 Bash
|
|
346
|
+
calls, **89.1% of them compound** and **32.0% beginning with `cd`** — and `branch-guard.sh`
|
|
347
|
+
examining 47 of 377 `git push` calls, because the other 330 came after a `cd … &&`.
|
|
348
|
+
|
|
349
|
+
It reads only. Nothing is sent anywhere and nothing is written back. Patterns that are allow
|
|
350
|
+
tests rather than gates are excluded, and a verb is counted only where it starts a command
|
|
351
|
+
segment, so a `git add` inside a quoted string is not mistaken for one that ran.
|
|
352
|
+
|
|
353
|
+
## Four ways your guards stop running at all
|
|
354
|
+
|
|
355
|
+
`--blindspots` finds guards that are loaded but never matched. There is a harder case it cannot
|
|
356
|
+
see: the guard is **never loaded**, or the tool it watches **no longer exists**. Four documented
|
|
357
|
+
ways to start Claude Code do that, and none of them reports it.
|
|
358
|
+
|
|
359
|
+
Measured 2026-09-19 on Claude Code **2.1.278**, Linux under WSL2, with a disposable `HOME` and a
|
|
360
|
+
scratch working directory. Arrival was measured on `UserPromptSubmit` — deliberately not
|
|
361
|
+
`PreToolUse` on `Bash`, because `--restricted` removes Bash, and then "the hook was ignored" and
|
|
362
|
+
"nothing pulled the trigger" look identical.
|
|
363
|
+
|
|
364
|
+
| How you start it | Your hooks | Bash |
|
|
365
|
+
| --- | --- | --- |
|
|
366
|
+
| *(control)* no flags | user, project and local all fire | present |
|
|
367
|
+
| `--dangerously-skip-permissions` | still fire — the guard refused, exit 2 | present |
|
|
368
|
+
| `claude --restricted` | **none load**; `--settings` is the only way back in I measured | **removed** |
|
|
369
|
+
| `claude --safe-mode` | **none load**, and `--settings` does **not** bring them back | **present** |
|
|
370
|
+
| `CLAUDE_CODE_RESTRICTED=1` | same as `--restricted` | removed |
|
|
371
|
+
| `CLAUDE_CODE_SAFE_MODE=1` | same as `--safe-mode` | **present** |
|
|
372
|
+
|
|
373
|
+
The control row matters: without it, "the guard stayed quiet" and "the guard is broken" are the
|
|
374
|
+
same observation. It fired and refused, so the guard works — it simply was not asked in the rows
|
|
375
|
+
where it is silent.
|
|
376
|
+
|
|
377
|
+
`--dangerously-skip-permissions` is in the table because people expect it to be the worst row for
|
|
378
|
+
their hooks. It is not: what that flag removes is the human prompt, not your guards. This table is
|
|
379
|
+
only about whether your hooks load, so do not read the second column as "this flag is safe."
|
|
380
|
+
|
|
381
|
+
### `claude --safe-mode` is not our `--safe-mode`
|
|
382
|
+
|
|
383
|
+
These are two different things with the same name, and one of them is ours:
|
|
384
|
+
|
|
385
|
+
- **`npx github:yurukusa/cc-safe-setup --safe-mode`** — *this tool*, and it is blunter than its
|
|
386
|
+
name suggests: it moves **every** `.sh` in `~/.claude/hooks` aside and empties the `hooks` block
|
|
387
|
+
of your `settings.json` — not just ours, yours and anyone else's too. It backs the file up
|
|
388
|
+
first, it tells you what it did, and **it stays off until you run `--safe-mode off`**, which
|
|
389
|
+
restores the hooks and copies the backup back over `settings.json` (so edits you make to that
|
|
390
|
+
file while safe mode is on are lost). Being honest about that: ours is the one you set once and
|
|
391
|
+
can forget, which is exactly the shape this section warns about.
|
|
392
|
+
- **`claude --safe-mode`** — *Claude Code*. Per invocation, for troubleshooting a broken
|
|
393
|
+
configuration. Its own help says auth, model selection, **built-in tools and permissions work
|
|
394
|
+
normally** — so your guards are gone and everything they guard against is still there.
|
|
395
|
+
|
|
396
|
+
We tell you to reach for our `--safe-mode` when a hook locks you out. Do not let that make
|
|
397
|
+
`claude --safe-mode` sound like the cautious choice. Of the ways to start Claude Code listed
|
|
398
|
+
above, the one whose name sounds safest is the only one that removes your hooks while leaving
|
|
399
|
+
the dangerous tools in place.
|
|
400
|
+
|
|
401
|
+
### The environment variables are the quiet ones
|
|
402
|
+
|
|
403
|
+
A flag is retyped every time you start. A line in your shell profile is read once and never seen
|
|
404
|
+
again. Under `--restricted` there is at least a tell — asked to run a shell command, the model
|
|
405
|
+
said in substance that the shell tool was missing and that the absence looked deliberate. Under
|
|
406
|
+
`--safe-mode` there is nothing to notice in the reply: every tool is present, the command runs,
|
|
407
|
+
the answer reads normally, and only the guard is quiet.
|
|
408
|
+
|
|
409
|
+
That was measured non-interactively (`claude -p`). Interactively you would likely notice, because
|
|
410
|
+
`--safe-mode` also drops `CLAUDE.md`, skills, plugins and MCP servers. The dangerous case is the
|
|
411
|
+
automated one — a script, a cron job, an unattended loop — where nobody reads the session.
|
|
412
|
+
|
|
413
|
+
**Check this first, it takes one command:**
|
|
475
414
|
|
|
476
415
|
```bash
|
|
477
|
-
|
|
416
|
+
grep -rn "CLAUDE_CODE_RESTRICTED\|CLAUDE_CODE_SAFE_MODE" \
|
|
417
|
+
~/.bashrc ~/.bash_profile ~/.profile ~/.zshrc ~/.zshenv 2>/dev/null
|
|
478
418
|
```
|
|
479
419
|
|
|
480
|
-
|
|
420
|
+
That covers the usual shell files. It will not find a variable set anywhere else your shell,
|
|
421
|
+
editor, terminal profile, container image or service manager can set one — check those too if the
|
|
422
|
+
grep comes back empty and something still looks wrong.
|
|
481
423
|
|
|
482
|
-
|
|
424
|
+
### Getting the hooks back is not the same as being guarded
|
|
483
425
|
|
|
484
|
-
|
|
426
|
+
Under `--restricted` you can pass them in with `--settings`, and they load. They still only cover
|
|
427
|
+
tools that survive. **Of the 24 `PreToolUse` registrations this repository installs by default —
|
|
428
|
+
six in `hooks/hooks.json` plus eighteen across the four plugins — 16 are matched on `Bash`**, and
|
|
429
|
+
`--restricted` is exactly the mode with no Bash. (The 916 files under `examples/` are not
|
|
430
|
+
registered; these 24 are what actually runs after an install.) The file tools remain, confined to
|
|
431
|
+
the working directories; both `Write` and `Edit` were measured modifying a file with no guard
|
|
432
|
+
consulted.
|
|
485
433
|
|
|
486
|
-
|
|
434
|
+
The five that already watch the file tools are the ones still standing in that mode: the
|
|
435
|
+
`Write|Edit` guard in `hooks/hooks.json`, three in `credential-guard` (`Write`, `Edit`, `Write`),
|
|
436
|
+
and one `Write` guard in `safety-essentials`. If you run `--restricted`, those five are your
|
|
437
|
+
coverage — check they cover what you care about, because the other sixteen cannot fire.
|
|
487
438
|
|
|
488
|
-
|
|
439
|
+
To be fair to the flag: `--restricted` did not create that gap. In the control run, with Bash
|
|
440
|
+
available, the model went straight to `Write` anyway — a Bash-only guard never covered that path.
|
|
441
|
+
What `--restricted` changes is that `Write` stops being one option among several and becomes the
|
|
442
|
+
only one. If you run `--restricted`, your guards need to be on `Write` and `Edit`.
|
|
489
443
|
|
|
490
|
-
**
|
|
444
|
+
**Not measured:** managed (policy) settings. The help says they survive both flags. There is no
|
|
445
|
+
`/etc/claude-code/` on the machine this was measured on, so that one is documentation, not
|
|
446
|
+
measurement.
|
|
491
447
|
|
|
492
|
-
##
|
|
448
|
+
## Your installed hooks do not update themselves
|
|
493
449
|
|
|
494
|
-
|
|
450
|
+
Installing a hook copies the file. **Nothing ever copies it back.** A hook installed in March
|
|
451
|
+
keeps running its March logic forever, including bugs fixed here months later.
|
|
495
452
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
- **[Token Book (¥2,500)](https://zenn.dev/yurukusa/books/token-savings-guide)** — Cut token consumption in half. CLAUDE.md optimization, hook-based guards, context management, workflow design. 44,000 words with copy-paste templates. Intro + Ch.1 free. [Details](https://yurukusa.github.io/cc-safe-setup/token-book.html)
|
|
500
|
-
- **[Safety Guide (¥800)](https://zenn.dev/yurukusa/books/6076c23b1cb18b)** — Token consumption diagnosis, file loss prevention, autonomous operation safety. From 800+ hours of real incidents. [Chapter 3 free](https://zenn.dev/yurukusa/books/6076c23b1cb18b/viewer/3-code-quality)
|
|
501
|
-
- **[800 Hours Operation Record (¥800)](https://zenn.dev/yurukusa/books/3c3c3baee85f0a19)** — Non-engineer running Claude Code autonomously for 800 hours. Failures, recovery, revenue reality. [Chapter 2 free](https://zenn.dev/yurukusa/books/3c3c3baee85f0a19/viewer/2-first-failures)
|
|
502
|
-
- **Wiki Guides**: [Token FAQ](https://github.com/yurukusa/cc-safe-setup/wiki/Claude-Code-Token-FAQ) · [CLAUDE.md Best Practices](https://github.com/yurukusa/cc-safe-setup/wiki/CLAUDE-md-Best-Practices) · [Token Optimization](https://github.com/yurukusa/cc-safe-setup/wiki/Token-Optimization-Guide)
|
|
503
|
-
- [Cookbook](COOKBOOK.md) — 26 practical recipes (block, approve, protect, monitor, diagnose)
|
|
504
|
-
- [Official Hooks Reference](https://code.claude.com/docs/en/hooks) — Claude Code hooks documentation
|
|
505
|
-
- [Hooks Cookbook](https://github.com/yurukusa/claude-code-hooks/blob/main/COOKBOOK.md) — 25 recipes from real GitHub Issues ([interactive version](https://yurukusa.github.io/claude-code-hooks/))
|
|
506
|
-
- [Skills Guide deep-dive (Qiita, 19K+ views)](https://qiita.com/yurukusa/items/f69920b4a02cf7e2988c) — Anthropic's official Skills PDF analyzed with 40% token reduction
|
|
507
|
-
- [Japanese guide (Qiita)](https://qiita.com/yurukusa/items/a9714b33f5d974e8f1e8) — この記事の日本語解説
|
|
508
|
-
- [v2.1.85 `if` field guide (Qiita)](https://qiita.com/yurukusa/items/7079866e9dc239fcdd57) — Reduce hook overhead with conditional execution
|
|
509
|
-
- [Deny rules bypass vulnerability (Qiita)](https://qiita.com/yurukusa/items/f9c48bb44569bbf4492e) — 50+ subcommands disable all deny rules; hook-based defense
|
|
510
|
-
- [Hook Test Runner](https://github.com/yurukusa/cc-hook-test) — `npx cc-hook-test <hook.sh>` to auto-test any hook
|
|
511
|
-
- [Hook Registry](https://github.com/yurukusa/cc-hook-registry) — `npx cc-hook-registry search database` ([browse online](https://yurukusa.github.io/cc-hook-registry/))
|
|
512
|
-
- [Hooks Cheat Sheet](https://yurukusa.github.io/cc-safe-setup/cheatsheet.html) — printable A4 quick reference
|
|
513
|
-
- [Ecosystem Comparison](https://yurukusa.github.io/cc-safe-setup/ecosystem.html) — all Claude Code hook projects compared
|
|
514
|
-
- [The incident that inspired this tool](https://github.com/anthropics/claude-code/issues/36339) — NTFS junction rm -rf
|
|
515
|
-
- [How to prevent rm -rf disasters](https://yurukusa.github.io/cc-safe-setup/prevent-rm-rf.html) — real incidents and the hook that stops them
|
|
516
|
-
- [How to prevent force-push to main](https://yurukusa.github.io/cc-safe-setup/prevent-force-push.html) — branch protection via hooks
|
|
517
|
-
- [How to prevent secret leaks](https://yurukusa.github.io/cc-safe-setup/prevent-secret-leaks.html) — stop git add . from committing .env
|
|
518
|
-
|
|
519
|
-
### Free Gists
|
|
520
|
-
|
|
521
|
-
- [settings.json Complete Template](https://gist.github.com/yurukusa/8ec367cf65042bf9fbd83c35931e7ed1) — copy-paste ready safety configuration
|
|
522
|
-
- [First 3 Safety Steps](https://gist.github.com/yurukusa/72513272be9a4ee29b058e2b08453e1a) — 5-minute safety setup from scratch
|
|
523
|
-
- [CLAUDE.md Before/After](https://gist.github.com/yurukusa/f9d7df5930bfb6d36a25673e69720f7e) — 40% token reduction through better writing patterns
|
|
524
|
-
- [Token Savings Cheat Card](https://gist.github.com/yurukusa/cfe44bfbb3756eccaf51660466913a2d) — 5 techniques to cut consumption in half
|
|
525
|
-
- [Token Consumption Checklist](https://gist.github.com/yurukusa/db8700a9f9fa331d36664df2868274cb) — 10-item diagnostic
|
|
526
|
-
- [Outage Survival Kit](https://gist.github.com/yurukusa/a0e31171eecb527d0df1d5498bf5f5d0) — what to do when Claude Code is down
|
|
527
|
-
- [CLAUDE.md Token Optimizer](https://gist.github.com/yurukusa/2b98fd2e90c0c13f6918c9f915e08e27) — 35-line template, 40% token reduction (800h tested)
|
|
528
|
-
- [Worktree Safety Hooks](https://gist.github.com/yurukusa/98bd43c5d0d8a6ebbf2cf21bfc1e2907) — 3 hooks to protect against worktree deletion and cross-tree destruction
|
|
529
|
-
- [Opus 4.7 Emergency Checklist](https://gist.github.com/yurukusa/c95efaee4b670e067369ece08092960c) — token burn diagnosis + immediate fixes
|
|
530
|
-
- [Cache TTL Mitigation Guide](https://gist.github.com/yurukusa/178d3949cd2bd6fbfc275b408f9711d4) — #46829 cache TTL change (1h→5m) impact and 4 mitigations
|
|
531
|
-
- [Security Checkup Hooks](https://gist.github.com/yurukusa/81f79ae6d760b27c17f2cd642ea846d7) — 4 hooks for financial, PII, deny bypass, and background task protection
|
|
532
|
-
- [Cache Breakage Fix](https://gist.github.com/yurukusa/fe6ba0a6aee14207f27ecc84419878b4) — 2 root causes of prompt cache invalidation (#47107 git status, #47098 session restart)
|
|
533
|
-
- [CLAUDE.md Token Optimization Cheat Sheet](https://gist.github.com/yurukusa/556f67c493a2729ce9b1703f5003a227) — 5 CLAUDE.md patterns that reduce token consumption with before/after examples
|
|
534
|
-
- [Token Troubleshooting Guide](https://gist.github.com/yurukusa/47b8c3eadb77cf74946f450f992ddac2) — fix quota drain, cache bugs, 1M context trap. Symptom-based diagnosis with latest issue references
|
|
535
|
-
- [Token Optimization Guide (English)](https://gist.github.com/yurukusa/70ff830c0ad3dff83e53be26cd80bd0a) — 3 biggest token levers with hook code, practical walkthrough
|
|
536
|
-
- [Token Book Sampler: 5 Techniques](https://gist.github.com/yurukusa/4a867ba301b480f996c5b76e4b6a6fbc) — free preview of the Token Book — 5 immediate techniques to reduce consumption
|
|
537
|
-
- [Token Optimization Checklist](https://gist.github.com/yurukusa/4b75025beee916f9904f56b79eeb1217) — 10-step checklist to cut token consumption in half, with hook configs
|
|
538
|
-
- [3 Things That Actually Work](https://gist.github.com/yurukusa/621f6d1cc35816df3da2e07876b44e16) — CLAUDE.md sizing, cache TTL, subagent control — based on 800h data
|
|
539
|
-
- [Cache TTL Diagnostic](https://gist.github.com/yurukusa/3a5bdcfdd295bef17b3ee00978b299f2) — 3 patterns that break prompt cache + fixes
|
|
540
|
-
- [Token Book Ch.1 Free Preview](https://gist.github.com/yurukusa/de862573f18d1a0a68d411b696dbcb73) — Where are your Claude Code tokens going? The 4 layers of token consumption explained
|
|
541
|
-
- [Deny Rules Break After 50 Subcommands](https://gist.github.com/yurukusa/0463d240d7b725218289a556414c72a5) — the hook that fixes Claude Code's deny rule bypass vulnerability
|
|
542
|
-
- [Opus 4.7 Emergency Kit](https://gist.github.com/yurukusa/1970b20fed95a682b72eb6e857e61d30) — 5 commands to protect your data from Opus 4.7 regressions (auto mode broken, 23+ data loss incidents)
|
|
543
|
-
- [cache_read Billing Bug Guide](https://gist.github.com/yurukusa/d5dc731dbc69e3ca92d69832bed641cb) — Opus 4.7 cache_read billed at full rate. Anthropic confirmed. Max plan users losing quota 3-6x faster
|
|
544
|
-
- [Opus 4.7 Survival Guide Summary](https://gist.github.com/yurukusa/5d66f0bcfe3fbfc73e6db106e10c533d) — 50 known issues with quick reference table, free diagnostic tools, and one-command fix
|
|
545
|
-
- [Opus 4.7 Known Issues Quick Reference](https://gist.github.com/yurukusa/2c1effab34a7554130d2704fdac59dff) — 26 issues / 43+ GitHub bugs in one table. Severity ratings and direct issue links
|
|
546
|
-
- [4 New Critical Issues (April 18)](https://gist.github.com/yurukusa/37c19b5b7f50fd8bbbeda5e1336c352e) — DoS via recursive spawn, subagent OOM, billing mismatch, UI/CLI model mismatch
|
|
547
|
-
- [トークン消費を半分にする方法](https://gist.github.com/yurukusa/bf4040a905148d9ca02898a53185fae1) — 800時間の実測データ+設定テンプレート(日本語)
|
|
548
|
-
- [How to Cut Token Usage in Half](https://gist.github.com/yurukusa/704d5cf9874f553dad5c46fccf53b09f) — 800h real data + config templates (English)
|
|
549
|
-
- [Compaction Triple Threat](https://gist.github.com/yurukusa/aa15f2065199c6fac4dcd3796fbaf90f) — 3 compaction bugs active simultaneously (#50402 + #50467 + #50492)
|
|
550
|
-
- [Sandbox Relative Path Bug (CRITICAL)](https://gist.github.com/yurukusa/a98efb6c561f92c82bcd49125af3b32a) — denyWrite/denyRead silently ignores relative paths (#50454)
|
|
551
|
-
- [27 Token Symptoms Quick Reference](https://gist.github.com/yurukusa/03a379854fa0f8eca091a75f7aab593b) — all 27 known token failure modes with top 5 killers table and April 2026 new symptoms
|
|
552
|
-
- [Token Saving Checklist (15 Items)](https://gist.github.com/yurukusa/6bd0d0a38a4887fc36475dd1f765ecd1) — ordered by impact: critical (30-50%), important (10-20%), good practice (5-10%)
|
|
553
|
-
- [Opus 4.7 Survival Cheatsheet](https://gist.github.com/yurukusa/f2d6e261338eeda70f0ed9507f995c13) — 46 known problems, quick fixes under 60 seconds, full reference table
|
|
554
|
-
|
|
555
|
-
### Professional Services
|
|
556
|
-
|
|
557
|
-
Need help configuring Claude Code safely? [**Safety Setup Service**](https://yurukusa.github.io/cc-safe-setup/services.html) — audit, token optimization, and custom hooks by the cc-safe-setup team.
|
|
558
|
-
|
|
559
|
-
## FAQ
|
|
560
|
-
|
|
561
|
-
**Q: I installed hooks but Claude says "Unknown skill: claude-code-hooks:setup"**
|
|
453
|
+
```bash
|
|
454
|
+
npx github:yurukusa/cc-safe-setup --outdated
|
|
455
|
+
```
|
|
562
456
|
|
|
563
|
-
|
|
457
|
+
This reports which of your installed hooks no longer match what ships today, and exits `1`
|
|
458
|
+
if any do, so it can run in CI. It only reports — it never overwrites, because a file that
|
|
459
|
+
differs may be your own edit.
|
|
564
460
|
|
|
565
|
-
**
|
|
461
|
+
**If you ran this before 2026-08-12, run it again.** Until then it compared your hooks
|
|
462
|
+
directory against `examples/` only, and the core guards — the ones `--install` writes by
|
|
463
|
+
default — are not files under `examples/`; they live in `scripts.json`. So every core guard
|
|
464
|
+
was reported as *"not shipped by this project — not checked"*, whatever its state.
|
|
566
465
|
|
|
567
|
-
|
|
466
|
+
That mattered. On the machine where this was found, three core guards were two and a half
|
|
467
|
+
months behind, and feeding the same input to the installed and shipped copies showed **six
|
|
468
|
+
dangerous command shapes that the shipped version blocks and the installed one let
|
|
469
|
+
through** — among them `cd /tmp && git push --force origin main` and `cd /tmp && git add
|
|
470
|
+
.env`. Each of those commands *on its own* was blocked by both copies, which is what makes
|
|
471
|
+
it a real gap rather than a bad measurement.
|
|
568
472
|
|
|
569
|
-
|
|
473
|
+
Core guards are not in `examples/`, so `--install-example` cannot fetch one. To see what
|
|
474
|
+
ships today and compare it yourself:
|
|
570
475
|
|
|
571
|
-
|
|
476
|
+
```bash
|
|
477
|
+
npx github:yurukusa/cc-safe-setup --show-core branch-guard > /tmp/shipped.sh
|
|
478
|
+
diff ~/.claude/hooks/branch-guard.sh /tmp/shipped.sh
|
|
479
|
+
```
|
|
572
480
|
|
|
573
|
-
|
|
481
|
+
`--show-core` prints to stdout and writes nothing.
|
|
574
482
|
|
|
575
|
-
|
|
483
|
+
## Rolling this out to a team
|
|
576
484
|
|
|
577
|
-
|
|
485
|
+
If you are the person who has to justify Claude Code to the rest of your organization, these are written for that job. All free, all usable as-is — no sign-up, no inquiry.
|
|
578
486
|
|
|
579
|
-
|
|
487
|
+
| | What it answers |
|
|
488
|
+
|---|---|
|
|
489
|
+
| [Team adoption safety checklist](https://htmlpreview.github.io/?https://gist.githubusercontent.com/yurukusa/75a565d9582fd31860f7c1a2e4cc938e/raw/team-adoption-checklist-jp.html) | The 7 things to settle before you hand this to developers, plus a shared policy template and a CI gate you can paste (JP) |
|
|
490
|
+
| [Settings reference](https://yurukusa.github.io/cc-safe-setup/settings-reference.html) | What each `settings.json` key actually does, and the ones that silently do nothing when written in the wrong place |
|
|
491
|
+
| [Cost governance for teams](https://yurukusa.github.io/cc-safe-setup/team-cost-governance-jp.html) | The three gaps the official usage limits don't cover, and how to close them with free hooks — cited to the official docs (JP) · [EN](https://yurukusa.github.io/cc-safe-setup/team-cost-governance.html) |
|
|
492
|
+
| [Monthly compliance report sample](https://yurukusa.github.io/cc-safe-setup/org-guard-monthly-report-sample.html) | What a monthly "is it actually working" report looks like, for SOC2 or a customer audit answer (fictional company, marked as such) |
|
|
493
|
+
| [Safety audit](https://yurukusa.github.io/cc-safe-setup/safety-audit.html) | Which classes of danger your current setup does and does not guard |
|
|
580
494
|
|
|
581
|
-
|
|
495
|
+
The hooks themselves stay free (MIT), always, and bug reports and questions are always welcome in issues and discussions.
|
|
582
496
|
|
|
583
|
-
|
|
497
|
+
## Written audits
|
|
584
498
|
|
|
585
|
-
|
|
499
|
+
Three asynchronous written audits exist ($29 and $219): no call, no meeting, and nothing is ever
|
|
500
|
+
run in your environment. Each publishes its full deliverable before you buy, run against my own
|
|
501
|
+
setup. Scope, prices and the samples are in [SERVICES.md](SERVICES.md). Corporate audits,
|
|
502
|
+
training, rollout consulting and monthly retainers are **not** offered.
|
|
586
503
|
|
|
587
|
-
|
|
504
|
+
## Windows
|
|
588
505
|
|
|
589
|
-
|
|
506
|
+
The hooks run under WSL2 and Git Bash. A few guards are Windows-specific (path handling, CJK-write corruption, the `ext4.vhdx` growth case). See `docs/windows.md`.
|
|
590
507
|
|
|
591
|
-
|
|
508
|
+
## Troubleshooting
|
|
592
509
|
|
|
593
|
-
|
|
510
|
+
If a hook does not fire, check that it is executable, that its path in `settings.json` is correct, and that the `matcher` names the right tool. `npx github:yurukusa/cc-safe-setup --doctor` checks these and reports what is misconfigured.
|
|
594
511
|
|
|
595
512
|
## Contributing
|
|
596
513
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
**Request a hook:** Describe the problem you're trying to prevent (not the solution). We'll figure out the hook together.
|
|
600
|
-
|
|
601
|
-
**Write a hook:** Fork, add your `.sh` file to `examples/`, add tests to `test.sh`, and open a PR. Every hook needs:
|
|
602
|
-
- A comment header explaining what it blocks and why
|
|
603
|
-
- At least 7 test cases (block, allow, empty input, edge cases)
|
|
604
|
-
- `bash -n` syntax validation passing
|
|
605
|
-
|
|
606
|
-
**Share your experience:** Used cc-safe-setup and have feedback? Open a discussion or comment on any issue. We read everything.
|
|
607
|
-
|
|
608
|
-
If cc-safe-setup saved you from a disaster (or just saved you time), a ⭐ helps others find it too.
|
|
514
|
+
Contributions are welcome. Each hook should be a single shell script with a test, and should not pull anything from npm. See [CONTRIBUTING.md](CONTRIBUTING.md) for the layout, the test harness, and how to handle the JSON reader.
|
|
609
515
|
|
|
610
|
-
##
|
|
516
|
+
## Where these hooks came from
|
|
611
517
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
518
|
+
Every hook here exists because something broke first — a destroyed working tree, a credential
|
|
519
|
+
read that should not have happened, an overnight cost spike. The incident behind each one, what
|
|
520
|
+
the logs actually looked like, and what finally stopped it, are written up at length. Those
|
|
521
|
+
write-ups are books, and they are listed in [docs/books.md](docs/books.md).
|
|
615
522
|
|
|
616
523
|
## License
|
|
617
524
|
|
|
618
|
-
MIT
|
|
525
|
+
MIT. See [LICENSE](LICENSE).
|