cc-safe-setup 1.9.1 → 1.9.3

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
@@ -154,7 +154,7 @@ Or browse all available examples in [`examples/`](examples/):
154
154
  ## Learn More
155
155
 
156
156
  - [Official Hooks Reference](https://code.claude.com/docs/en/hooks) — Claude Code hooks documentation
157
- - [Hooks Cookbook](https://github.com/yurukusa/claude-code-hooks/blob/main/COOKBOOK.md) — 13 ready-to-use recipes from real GitHub Issues
157
+ - [Hooks Cookbook](https://github.com/yurukusa/claude-code-hooks/blob/main/COOKBOOK.md) — 14 ready-to-use recipes from real GitHub Issues
158
158
  - [Japanese guide (Qiita)](https://qiita.com/yurukusa/items/a9714b33f5d974e8f1e8) — この記事の日本語解説
159
159
  - [The incident that inspired this tool](https://github.com/anthropics/claude-code/issues/36339) — NTFS junction rm -rf
160
160
 
@@ -15,6 +15,7 @@ Custom hooks beyond the 8 built-in ones. Copy any file to `~/.claude/hooks/` and
15
15
  | **block-database-wipe.sh** | Block destructive DB commands (Laravel, Django, Rails) | [#37405](https://github.com/anthropics/claude-code/issues/37405) |
16
16
  | **edit-guard.sh** | Block Edit/Write to protected files | [#37210](https://github.com/anthropics/claude-code/issues/37210) |
17
17
  | **enforce-tests.sh** | Warn when source changes without test changes | |
18
+ | **git-config-guard.sh** | Block git config --global modifications | [#37201](https://github.com/anthropics/claude-code/issues/37201) |
18
19
  | **notify-waiting.sh** | Desktop notification when Claude waits for input | |
19
20
  | **protect-dotfiles.sh** | Block modifications to ~/.bashrc, ~/.aws/, ~/.ssh/ | [#37478](https://github.com/anthropics/claude-code/issues/37478) |
20
21
  | **scope-guard.sh** | Block file operations outside project directory | [#36233](https://github.com/anthropics/claude-code/issues/36233) |
@@ -0,0 +1,36 @@
1
+ #!/bin/bash
2
+ # git-config-guard.sh — Block git config --global modifications
3
+ #
4
+ # Solves: Claude modifying global git config (user.email, user.name)
5
+ # without user consent (#37201)
6
+ #
7
+ # Usage: Add to settings.json as a PreToolUse hook
8
+ #
9
+ # {
10
+ # "hooks": {
11
+ # "PreToolUse": [{
12
+ # "matcher": "Bash",
13
+ # "hooks": [{ "type": "command", "command": "~/.claude/hooks/git-config-guard.sh" }]
14
+ # }]
15
+ # }
16
+ # }
17
+
18
+ INPUT=$(cat)
19
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
20
+
21
+ [[ -z "$COMMAND" ]] && exit 0
22
+
23
+ # Block git config --global (any subcommand)
24
+ if echo "$COMMAND" | grep -qE '\bgit\s+config\s+--global\b'; then
25
+ echo "BLOCKED: git config --global is not allowed" >&2
26
+ echo "Use --local for project-specific config instead" >&2
27
+ exit 2
28
+ fi
29
+
30
+ # Block git config --system
31
+ if echo "$COMMAND" | grep -qE '\bgit\s+config\s+--system\b'; then
32
+ echo "BLOCKED: git config --system is not allowed" >&2
33
+ exit 2
34
+ fi
35
+
36
+ exit 0
package/index.mjs CHANGED
@@ -179,6 +179,23 @@ function status() {
179
179
  console.log();
180
180
  console.log(' ' + (settingsOk ? c.green + '✓' : c.red + '✗') + c.reset + ' settings.json ' + (settingsOk ? 'has hooks configured' : 'missing hook configuration'));
181
181
 
182
+ // Check installed examples
183
+ const exampleFiles = [
184
+ 'allowlist.sh', 'auto-approve-build.sh', 'auto-approve-docker.sh',
185
+ 'auto-approve-git-read.sh', 'auto-approve-python.sh', 'auto-approve-ssh.sh',
186
+ 'auto-checkpoint.sh', 'auto-snapshot.sh', 'block-database-wipe.sh',
187
+ 'edit-guard.sh', 'enforce-tests.sh', 'notify-waiting.sh',
188
+ 'protect-dotfiles.sh', 'scope-guard.sh',
189
+ ];
190
+ const installedExamples = exampleFiles.filter(f => existsSync(join(HOOKS_DIR, f)));
191
+ if (installedExamples.length > 0) {
192
+ console.log();
193
+ console.log(' ' + c.bold + 'Example hooks installed:' + c.reset);
194
+ for (const f of installedExamples) {
195
+ console.log(' ' + c.green + '✓' + c.reset + ' ' + f);
196
+ }
197
+ }
198
+
182
199
  console.log();
183
200
  if (missing === 0) {
184
201
  console.log(c.bold + ' All ' + installed + ' hooks installed.' + c.reset);
@@ -186,6 +203,9 @@ function status() {
186
203
  console.log(c.bold + ' ' + installed + '/' + Object.keys(HOOKS).length + ' hooks installed.' + c.reset);
187
204
  console.log(' ' + c.dim + 'Run: npx cc-safe-setup' + c.reset);
188
205
  }
206
+ if (installedExamples.length > 0) {
207
+ console.log(' ' + c.dim + '+ ' + installedExamples.length + ' example hooks' + c.reset);
208
+ }
189
209
  console.log();
190
210
 
191
211
  // Exit code for CI: 0 = all installed, 1 = missing hooks
@@ -270,6 +290,7 @@ function examples() {
270
290
  'protect-dotfiles.sh': 'Block modifications to ~/.bashrc, ~/.aws/, ~/.ssh/',
271
291
  'scope-guard.sh': 'Block file operations outside project directory',
272
292
  'auto-checkpoint.sh': 'Auto-commit after edits for rollback protection',
293
+ 'git-config-guard.sh': 'Block git config --global modifications',
273
294
  };
274
295
 
275
296
  console.log();
@@ -380,6 +401,8 @@ async function main() {
380
401
  console.log(c.red + ' x' + c.reset + ' Syntax errors cascading through 30+ files');
381
402
  console.log(c.red + ' x' + c.reset + ' Sessions losing all context with no warning');
382
403
  console.log(c.red + ' x' + c.reset + ' git checkout --force discarding uncommitted changes');
404
+ console.log(c.red + ' x' + c.reset + ' Remove-Item -Recurse -Force destroying unpushed source code');
405
+ console.log(c.red + ' x' + c.reset + ' prisma migrate reset / migrate:fresh wiping databases');
383
406
  console.log();
384
407
 
385
408
  console.log(c.bold + ' Hooks to install:' + c.reset);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cc-safe-setup",
3
- "version": "1.9.1",
4
- "description": "One command to make Claude Code safe for autonomous operation. 8 hooks: destructive blocker, branch guard, force-push protection, secret leak prevention, syntax checks, and more.",
3
+ "version": "1.9.3",
4
+ "description": "One command to make Claude Code safe for autonomous operation. 8 built-in hooks + 14 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"