cc-safe-setup 5.4.0 → 6.1.0

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/README.md CHANGED
@@ -226,6 +226,15 @@ Or browse all available examples in [`examples/`](examples/):
226
226
  - **dependency-audit.sh** — Warn when installing packages not in manifest (npm/pip/cargo supply chain awareness)
227
227
  - **env-source-guard.sh** — Block sourcing .env files into shell environment ([#401](https://github.com/anthropics/claude-code/issues/401))
228
228
  - **symlink-guard.sh** — Detect symlink/junction traversal in rm targets ([#36339](https://github.com/anthropics/claude-code/issues/36339) [#764](https://github.com/anthropics/claude-code/issues/764))
229
+ - **no-sudo-guard.sh** — Block all sudo commands
230
+ - **no-install-global.sh** — Block npm -g and system-wide pip
231
+ - **no-curl-upload.sh** — Warn on curl POST/upload (data exfiltration)
232
+ - **no-port-bind.sh** — Warn on network port binding
233
+ - **git-tag-guard.sh** — Block pushing all tags at once
234
+ - **npm-publish-guard.sh** — Version check before npm publish
235
+ - **max-file-count-guard.sh** — Warn when 20+ new files created per session
236
+ - **protect-claudemd.sh** — Block edits to CLAUDE.md and settings files
237
+ - **reinject-claudemd.sh** — Re-inject CLAUDE.md rules after compaction ([#6354](https://github.com/anthropics/claude-code/issues/6354))
229
238
  - **binary-file-guard.sh** — Warn when Write targets binary file types (images, archives)
230
239
  - **stale-branch-guard.sh** — Warn when working branch is far behind default
231
240
  - **cost-tracker.sh** — Estimate session token cost and warn at thresholds ($1, $5)
@@ -253,7 +262,7 @@ Or browse all available examples in [`examples/`](examples/):
253
262
  - [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/))
254
263
  - [Japanese guide (Qiita)](https://qiita.com/yurukusa/items/a9714b33f5d974e8f1e8) — この記事の日本語解説
255
264
  - [Hook Test Runner](https://github.com/yurukusa/cc-hook-test) — `npx cc-hook-test <hook.sh>` to auto-test any hook
256
- - [Hook Registry](https://github.com/yurukusa/cc-hook-registry) — `npx cc-hook-registry search database` to find community hooks
265
+ - [Hook Registry](https://github.com/yurukusa/cc-hook-registry) — `npx cc-hook-registry search database` ([browse online](https://yurukusa.github.io/cc-hook-registry/))
257
266
  - [Hooks Cheat Sheet](https://yurukusa.github.io/cc-safe-setup/cheatsheet.html) — printable A4 quick reference
258
267
  - [Ecosystem Comparison](https://yurukusa.github.io/cc-safe-setup/ecosystem.html) — all Claude Code hook projects compared
259
268
  - [The incident that inspired this tool](https://github.com/anthropics/claude-code/issues/36339) — NTFS junction rm -rf
@@ -0,0 +1,10 @@
1
+ COMMAND=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null)
2
+ [ -z "$COMMAND" ] && exit 0
3
+ if echo "$COMMAND" | grep -qE 'git\s+tag\s+(-a\s+|-d\s+)?v'; then
4
+ echo "WARNING: Creating git tag. Verify version number." >&2
5
+ fi
6
+ if echo "$COMMAND" | grep -qE 'git\s+push.*--tags'; then
7
+ echo "BLOCKED: Pushing all tags. Push specific tags instead." >&2
8
+ exit 2
9
+ fi
10
+ exit 0
@@ -0,0 +1,8 @@
1
+ INPUT=$(cat)
2
+ FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
3
+ [ -z "$FILE" ] && exit 0
4
+ STATE="/tmp/cc-new-files-count"
5
+ echo "$FILE" >> "$STATE"
6
+ COUNT=$(wc -l < "$STATE" 2>/dev/null || echo 0)
7
+ [ "$COUNT" -ge 20 ] && echo "WARNING: $COUNT new files created this session." >&2
8
+ exit 0
@@ -0,0 +1,6 @@
1
+ COMMAND=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null)
2
+ [ -z "$COMMAND" ] && exit 0
3
+ if echo "$COMMAND" | grep -qE 'curl\s+.*(-X\s+POST|-d\s+@|--data-binary|--upload-file)'; then
4
+ echo "WARNING: curl upload/POST detected. Verify no sensitive data." >&2
5
+ fi
6
+ exit 0
@@ -0,0 +1,11 @@
1
+ COMMAND=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null)
2
+ [ -z "$COMMAND" ] && exit 0
3
+ if echo "$COMMAND" | grep -qE 'npm\s+install\s+-g\s|npm\s+i\s+-g\s'; then
4
+ echo "BLOCKED: Global npm install. Use npx or local install." >&2
5
+ exit 2
6
+ fi
7
+ if echo "$COMMAND" | grep -qE 'sudo\s+pip\s+install|pip\s+install\s+--system'; then
8
+ echo "BLOCKED: System-wide pip install. Use virtualenv." >&2
9
+ exit 2
10
+ fi
11
+ exit 0
@@ -0,0 +1,7 @@
1
+ COMMAND=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null)
2
+ [ -z "$COMMAND" ] && exit 0
3
+ if echo "$COMMAND" | grep -qE '(--port|--listen|-p\s+\d|0\.0\.0\.0|INADDR_ANY|nc\s+-l)'; then
4
+ echo "WARNING: Command may bind to a network port." >&2
5
+ echo "Command: $COMMAND" >&2
6
+ fi
7
+ exit 0
@@ -0,0 +1,8 @@
1
+ COMMAND=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null)
2
+ [ -z "$COMMAND" ] && exit 0
3
+ if echo "$COMMAND" | grep -qE '^\s*sudo\s'; then
4
+ echo "BLOCKED: sudo command detected." >&2
5
+ echo "Command: $COMMAND" >&2
6
+ exit 2
7
+ fi
8
+ exit 0
@@ -0,0 +1,9 @@
1
+ COMMAND=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null)
2
+ [ -z "$COMMAND" ] && exit 0
3
+ if echo "$COMMAND" | grep -qE '^\s*npm\s+publish'; then
4
+ if [ -f "package.json" ]; then
5
+ VER=$(python3 -c "import json; print(json.load(open('package.json')).get('version','?'))" 2>/dev/null)
6
+ echo "NOTE: Publishing version $VER to npm." >&2
7
+ fi
8
+ fi
9
+ exit 0
@@ -0,0 +1,45 @@
1
+ #!/bin/bash
2
+ # ================================================================
3
+ # protect-claudemd.sh — Block edits to CLAUDE.md and settings files
4
+ # ================================================================
5
+ # PURPOSE:
6
+ # Claude Code sometimes modifies CLAUDE.md, settings.json, or
7
+ # other configuration files without permission. This hook blocks
8
+ # Edit/Write to these critical files.
9
+ #
10
+ # TRIGGER: PreToolUse
11
+ # MATCHER: "Edit|Write"
12
+ # ================================================================
13
+
14
+ INPUT=$(cat)
15
+ TOOL=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
16
+ FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
17
+
18
+ if [[ "$TOOL" != "Edit" && "$TOOL" != "Write" ]]; then
19
+ exit 0
20
+ fi
21
+
22
+ if [[ -z "$FILE" ]]; then
23
+ exit 0
24
+ fi
25
+
26
+ BASENAME=$(basename "$FILE")
27
+
28
+ # Protected files
29
+ case "$BASENAME" in
30
+ CLAUDE.md|.claude.json|settings.json|settings.local.json)
31
+ echo "BLOCKED: Cannot modify configuration file: $BASENAME" >&2
32
+ echo "File: $FILE" >&2
33
+ echo "" >&2
34
+ echo "Configuration files should be edited manually, not by Claude." >&2
35
+ exit 2
36
+ ;;
37
+ esac
38
+
39
+ # Protected directories
40
+ if echo "$FILE" | grep -qE '\.claude/(hooks|settings|plugins)/'; then
41
+ echo "BLOCKED: Cannot modify .claude system directory: $FILE" >&2
42
+ exit 2
43
+ fi
44
+
45
+ exit 0
package/index.mjs CHANGED
@@ -370,6 +370,15 @@ function examples() {
370
370
  'symlink-guard.sh': 'Detect symlink/junction traversal in rm targets',
371
371
  'cost-tracker.sh': 'Estimate session token cost ($1 warn, $5 alert)',
372
372
  'read-before-edit.sh': 'Warn when editing files not recently read',
373
+ 'no-sudo-guard.sh': 'Block all sudo commands',
374
+ 'no-install-global.sh': 'Block npm -g and system-wide pip',
375
+ 'no-curl-upload.sh': 'Warn on curl POST/upload',
376
+ 'no-port-bind.sh': 'Warn on network port binding',
377
+ 'git-tag-guard.sh': 'Block pushing all tags at once',
378
+ 'npm-publish-guard.sh': 'Version check before npm publish',
379
+ 'max-file-count-guard.sh': 'Warn when 20+ files created per session',
380
+ 'protect-claudemd.sh': 'Block edits to CLAUDE.md and settings files',
381
+ 'reinject-claudemd.sh': 'Re-inject CLAUDE.md rules after compaction',
373
382
  },
374
383
  };
375
384
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-safe-setup",
3
- "version": "5.4.0",
3
+ "version": "6.1.0",
4
4
  "description": "One command to make Claude Code safe for autonomous operation. 8 built-in + 39 examples. 23 commands including dashboard, issues, create, audit, lint, diff. 260 tests. 2,500+ daily npm downloads.",
5
5
  "main": "index.mjs",
6
6
  "bin": {