cc-safe-setup 1.9.6 → 1.9.7

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
@@ -153,6 +153,7 @@ Or browse all available examples in [`examples/`](examples/):
153
153
  - **git-config-guard.sh** — Block `git config --global` modifications without consent ([#37201](https://github.com/anthropics/claude-code/issues/37201))
154
154
  - **deploy-guard.sh** — Block deploy commands when uncommitted changes exist ([#37314](https://github.com/anthropics/claude-code/issues/37314))
155
155
  - **network-guard.sh** — Warn on suspicious network commands sending file contents ([#37420](https://github.com/anthropics/claude-code/issues/37420))
156
+ - **test-before-push.sh** — Block `git push` when tests haven't been run ([#36970](https://github.com/anthropics/claude-code/issues/36970))
156
157
 
157
158
  ## Learn More
158
159
 
@@ -17,6 +17,7 @@ Custom hooks beyond the 8 built-in ones. Copy any file to `~/.claude/hooks/` and
17
17
  | **edit-guard.sh** | Block Edit/Write to protected files | [#37210](https://github.com/anthropics/claude-code/issues/37210) |
18
18
  | **enforce-tests.sh** | Warn when source changes without test changes | |
19
19
  | **git-config-guard.sh** | Block git config --global modifications | [#37201](https://github.com/anthropics/claude-code/issues/37201) |
20
+ | **large-file-guard.sh** | Warn when Write creates oversized files (>500KB) | |
20
21
  | **network-guard.sh** | Warn on suspicious network commands (data exfiltration) | [#37420](https://github.com/anthropics/claude-code/issues/37420) |
21
22
  | **notify-waiting.sh** | Desktop notification when Claude waits for input | |
22
23
  | **protect-dotfiles.sh** | Block modifications to ~/.bashrc, ~/.aws/, ~/.ssh/ | [#37478](https://github.com/anthropics/claude-code/issues/37478) |
@@ -0,0 +1,40 @@
1
+ #!/bin/bash
2
+ # large-file-guard.sh — Warn when Write tool creates oversized files
3
+ #
4
+ # Solves: Claude generating multi-MB files that bloat the repo,
5
+ # or accidentally writing binary/base64 data to source files.
6
+ #
7
+ # This is a PostToolUse hook — it checks AFTER the write happens
8
+ # and warns if the file is suspiciously large.
9
+ #
10
+ # Usage: Add to settings.json as a PostToolUse hook
11
+ #
12
+ # {
13
+ # "hooks": {
14
+ # "PostToolUse": [{
15
+ # "matcher": "Write",
16
+ # "hooks": [{ "type": "command", "command": "~/.claude/hooks/large-file-guard.sh" }]
17
+ # }]
18
+ # }
19
+ # }
20
+
21
+ INPUT=$(cat)
22
+ TOOL=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
23
+ FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
24
+
25
+ [[ "$TOOL" != "Write" ]] && exit 0
26
+ [[ -z "$FILE" || ! -f "$FILE" ]] && exit 0
27
+
28
+ # Check file size (default threshold: 500KB)
29
+ MAX_SIZE=${CC_MAX_FILE_SIZE:-512000}
30
+ FILE_SIZE=$(stat -c %s "$FILE" 2>/dev/null || stat -f %z "$FILE" 2>/dev/null || echo 0)
31
+
32
+ if (( FILE_SIZE > MAX_SIZE )); then
33
+ SIZE_KB=$((FILE_SIZE / 1024))
34
+ echo "" >&2
35
+ echo "WARNING: Large file written: $FILE (${SIZE_KB}KB)" >&2
36
+ echo "This may indicate generated binary/base64 data in a source file." >&2
37
+ echo "Threshold: $((MAX_SIZE / 1024))KB (set CC_MAX_FILE_SIZE to adjust)" >&2
38
+ fi
39
+
40
+ exit 0
package/index.mjs CHANGED
@@ -294,6 +294,7 @@ function examples() {
294
294
  'deploy-guard.sh': 'Block deploy when uncommitted changes exist',
295
295
  'network-guard.sh': 'Warn on suspicious network commands (data exfiltration)',
296
296
  'test-before-push.sh': 'Block git push when tests have not passed',
297
+ 'large-file-guard.sh': 'Warn when Write creates files over 500KB',
297
298
  };
298
299
 
299
300
  console.log();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cc-safe-setup",
3
- "version": "1.9.6",
4
- "description": "One command to make Claude Code safe for autonomous operation. 8 built-in hooks + 18 installable examples. Destructive blocker, branch guard, database wipe protection, dotfile guard, and more.",
3
+ "version": "1.9.7",
4
+ "description": "One command to make Claude Code safe for autonomous operation. 8 built-in hooks + 19 installable examples. Destructive blocker, branch guard, database wipe protection, dotfile guard, and more.",
5
5
  "main": "index.mjs",
6
6
  "bin": {
7
7
  "cc-safe-setup": "index.mjs"