cc-safe-setup 1.9.6 → 2.0.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
@@ -153,6 +153,8 @@ 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))
157
+ - **large-file-guard.sh** — Warn when Write tool creates files over 500KB
156
158
 
157
159
  ## Learn More
158
160
 
@@ -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
@@ -275,37 +275,50 @@ async function verify() {
275
275
 
276
276
  function examples() {
277
277
  const examplesDir = join(__dirname, 'examples');
278
- const EXAMPLE_DESCRIPTIONS = {
279
- 'auto-approve-build.sh': 'Auto-approve npm/yarn/cargo/go build, test, lint commands',
280
- 'auto-approve-docker.sh': 'Auto-approve docker build, compose, ps, logs commands',
281
- 'auto-approve-git-read.sh': 'Auto-approve git status/log/diff even with -C flags',
282
- 'auto-approve-ssh.sh': 'Auto-approve safe SSH commands (uptime, whoami, etc.)',
283
- 'block-database-wipe.sh': 'Block destructive DB commands (migrate:fresh, DROP DATABASE)',
284
- 'edit-guard.sh': 'Block Edit/Write to protected files (.env, credentials)',
285
- 'enforce-tests.sh': 'Warn when source files change without test files',
286
- 'notify-waiting.sh': 'Desktop notification when Claude waits for input',
287
- 'auto-approve-python.sh': 'Auto-approve pytest, mypy, ruff, black, isort commands',
288
- 'auto-snapshot.sh': 'Auto-save file snapshots before edits (rollback protection)',
289
- 'allowlist.sh': 'Block everything not in allowlist (inverse permission model)',
290
- 'protect-dotfiles.sh': 'Block modifications to ~/.bashrc, ~/.aws/, ~/.ssh/',
291
- 'scope-guard.sh': 'Block file operations outside project directory',
292
- 'auto-checkpoint.sh': 'Auto-commit after edits for rollback protection',
293
- 'git-config-guard.sh': 'Block git config --global modifications',
294
- 'deploy-guard.sh': 'Block deploy when uncommitted changes exist',
295
- 'network-guard.sh': 'Warn on suspicious network commands (data exfiltration)',
296
- 'test-before-push.sh': 'Block git push when tests have not passed',
278
+ const CATEGORIES = {
279
+ 'Safety Guards': {
280
+ 'allowlist.sh': 'Block everything not in allowlist (inverse permission model)',
281
+ 'block-database-wipe.sh': 'Block destructive DB commands (migrate:fresh, DROP DATABASE, Prisma)',
282
+ 'deploy-guard.sh': 'Block deploy when uncommitted changes exist',
283
+ 'network-guard.sh': 'Warn on suspicious network commands (data exfiltration)',
284
+ 'protect-dotfiles.sh': 'Block modifications to ~/.bashrc, ~/.aws/, ~/.ssh/',
285
+ 'scope-guard.sh': 'Block file operations outside project directory',
286
+ 'test-before-push.sh': 'Block git push when tests have not passed',
287
+ 'git-config-guard.sh': 'Block git config --global modifications',
288
+ },
289
+ 'Auto-Approve': {
290
+ 'auto-approve-build.sh': 'Auto-approve npm/yarn/cargo/go build, test, lint',
291
+ 'auto-approve-docker.sh': 'Auto-approve docker build, compose, ps, logs',
292
+ 'auto-approve-git-read.sh': 'Auto-approve git status/log/diff even with -C flags',
293
+ 'auto-approve-python.sh': 'Auto-approve pytest, mypy, ruff, black, isort',
294
+ 'auto-approve-ssh.sh': 'Auto-approve safe SSH commands (uptime, whoami)',
295
+ },
296
+ 'Quality': {
297
+ 'edit-guard.sh': 'Block Edit/Write to protected files (.env, credentials)',
298
+ 'enforce-tests.sh': 'Warn when source files change without test files',
299
+ 'large-file-guard.sh': 'Warn when Write creates files over 500KB',
300
+ },
301
+ 'Recovery': {
302
+ 'auto-checkpoint.sh': 'Auto-commit after edits for rollback protection',
303
+ 'auto-snapshot.sh': 'Auto-save file snapshots before edits (rollback protection)',
304
+ },
305
+ 'UX': {
306
+ 'notify-waiting.sh': 'Desktop notification when Claude waits for input',
307
+ },
297
308
  };
298
309
 
299
310
  console.log();
300
311
  console.log(c.bold + ' cc-safe-setup --examples' + c.reset);
301
- console.log(c.dim + ' Custom hooks beyond the 8 built-in ones' + c.reset);
312
+ console.log(c.dim + ' 19 hooks beyond the 8 built-in ones' + c.reset);
302
313
  console.log();
303
314
 
304
- for (const [file, desc] of Object.entries(EXAMPLE_DESCRIPTIONS)) {
305
- const fullPath = join(examplesDir, file);
306
- const exists = existsSync(fullPath);
307
- console.log(' ' + c.green + '*' + c.reset + ' ' + c.bold + file + c.reset);
308
- console.log(' ' + c.dim + desc + c.reset);
315
+ for (const [cat, hooks] of Object.entries(CATEGORIES)) {
316
+ console.log(' ' + c.bold + c.blue + cat + c.reset);
317
+ for (const [file, desc] of Object.entries(hooks)) {
318
+ console.log(' ' + c.green + '*' + c.reset + ' ' + c.bold + file + c.reset);
319
+ console.log(' ' + c.dim + desc + c.reset);
320
+ }
321
+ console.log();
309
322
  }
310
323
 
311
324
  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": "2.0.0",
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"