cc-safe-setup 8.5.0 → 8.6.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
@@ -6,7 +6,7 @@
6
6
 
7
7
  **One command to make Claude Code safe for autonomous operation.** [日本語](docs/README.ja.md)
8
8
 
9
- 8 built-in + 92 examples = **100 hooks**. 32 CLI commands. 457 tests. [Web Tool](https://yurukusa.github.io/cc-safe-setup/) · [Cheat Sheet](https://yurukusa.github.io/cc-safe-setup/hooks-cheatsheet.html) · [Builder](https://yurukusa.github.io/cc-safe-setup/builder.html) · [FAQ](https://yurukusa.github.io/cc-safe-setup/faq.html) · [Playground](https://yurukusa.github.io/cc-hook-registry/playground.html)
9
+ 8 built-in + 95 examples = **103 hooks**. 33 CLI commands. 457 tests. 4 languages. [Web Tool](https://yurukusa.github.io/cc-safe-setup/) · [Cheat Sheet](https://yurukusa.github.io/cc-safe-setup/hooks-cheatsheet.html) · [Builder](https://yurukusa.github.io/cc-safe-setup/builder.html) · [FAQ](https://yurukusa.github.io/cc-safe-setup/faq.html) · [Playground](https://yurukusa.github.io/cc-hook-registry/playground.html)
10
10
 
11
11
  ```bash
12
12
  npx cc-safe-setup
@@ -0,0 +1,58 @@
1
+ #!/bin/bash
2
+ # ================================================================
3
+ # context-snapshot.sh — Save session state before context loss
4
+ # ================================================================
5
+ # PURPOSE:
6
+ # After /compact or when context is low, Claude loses track of
7
+ # what files were being edited, which branch it's on, and what
8
+ # the current task was. This hook saves a snapshot of the session
9
+ # state after every Stop event, so the next message can recover.
10
+ #
11
+ # TRIGGER: Stop MATCHER: ""
12
+ #
13
+ # Creates: .claude/session-snapshot.md (overwritten each time)
14
+ # ================================================================
15
+
16
+ SNAPSHOT=".claude/session-snapshot.md"
17
+ mkdir -p .claude 2>/dev/null
18
+
19
+ {
20
+ echo "# Session Snapshot (auto-generated)"
21
+ echo "Updated: $(date -Iseconds)"
22
+ echo ""
23
+
24
+ # Git state
25
+ BRANCH=$(git branch --show-current 2>/dev/null)
26
+ if [ -n "$BRANCH" ]; then
27
+ echo "## Git"
28
+ echo "- Branch: \`$BRANCH\`"
29
+ DIRTY=$(git status --porcelain 2>/dev/null | wc -l)
30
+ echo "- Uncommitted changes: $DIRTY file(s)"
31
+ if [ "$DIRTY" -gt 0 ]; then
32
+ echo '```'
33
+ git status --short 2>/dev/null | head -15
34
+ echo '```'
35
+ fi
36
+ echo "- Last commit: $(git log --oneline -1 2>/dev/null)"
37
+ echo ""
38
+ fi
39
+
40
+ # Recently modified files
41
+ echo "## Recent Files"
42
+ echo '```'
43
+ find . -name '*.js' -o -name '*.ts' -o -name '*.py' -o -name '*.go' -o -name '*.rs' \
44
+ -o -name '*.java' -o -name '*.sh' -o -name '*.md' 2>/dev/null \
45
+ | xargs ls -lt 2>/dev/null | head -10 | awk '{print $NF}'
46
+ echo '```'
47
+ echo ""
48
+
49
+ # Active TODO/FIXME
50
+ TODOS=$(grep -rl 'TODO\|FIXME' --include='*.js' --include='*.ts' --include='*.py' . 2>/dev/null | wc -l)
51
+ if [ "$TODOS" -gt 0 ]; then
52
+ echo "## Active TODOs: $TODOS file(s)"
53
+ echo ""
54
+ fi
55
+
56
+ } > "$SNAPSHOT" 2>/dev/null
57
+
58
+ exit 0
@@ -0,0 +1,37 @@
1
+ #!/bin/bash
2
+ # ================================================================
3
+ # git-lfs-guard.sh — Suggest Git LFS for large binary files
4
+ # ================================================================
5
+ # PURPOSE:
6
+ # Claude sometimes git-adds large binary files (images, videos,
7
+ # compiled binaries) that bloat the repository. This hook warns
8
+ # when staging files larger than a threshold and suggests LFS.
9
+ #
10
+ # TRIGGER: PreToolUse MATCHER: "Bash"
11
+ #
12
+ # CONFIG:
13
+ # CC_LFS_THRESHOLD_KB=500 (warn above 500KB)
14
+ # ================================================================
15
+
16
+ COMMAND=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null)
17
+ [ -z "$COMMAND" ] && exit 0
18
+
19
+ echo "$COMMAND" | grep -qE '^\s*git\s+add' || exit 0
20
+
21
+ THRESHOLD="${CC_LFS_THRESHOLD_KB:-500}"
22
+
23
+ # Extract files being added
24
+ FILES=$(echo "$COMMAND" | sed 's/git add//' | tr ' ' '\n' | grep -v '^-' | grep -v '^$')
25
+
26
+ for f in $FILES; do
27
+ [ -f "$f" ] || continue
28
+ SIZE_KB=$(du -k "$f" 2>/dev/null | cut -f1)
29
+ [ -z "$SIZE_KB" ] && continue
30
+
31
+ if [ "$SIZE_KB" -gt "$THRESHOLD" ]; then
32
+ echo "WARNING: $f is ${SIZE_KB}KB — consider Git LFS." >&2
33
+ echo " git lfs track '$f' && git add .gitattributes $f" >&2
34
+ fi
35
+ done
36
+
37
+ exit 0
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+ # ================================================================
3
+ # lockfile-guard.sh — Warn when lockfiles are modified unexpectedly
4
+ # ================================================================
5
+ # PURPOSE:
6
+ # Claude sometimes runs npm install or pip install that modifies
7
+ # lockfiles (package-lock.json, yarn.lock, Cargo.lock, etc.)
8
+ # without the user intending a dependency change. This hook warns
9
+ # when a lockfile appears in staged changes.
10
+ #
11
+ # TRIGGER: PreToolUse MATCHER: "Bash"
12
+ # ================================================================
13
+
14
+ COMMAND=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null)
15
+ [ -z "$COMMAND" ] && exit 0
16
+
17
+ # Only check git commit
18
+ echo "$COMMAND" | grep -qE '^\s*git\s+(commit|add)' || exit 0
19
+
20
+ # Check for lockfile changes
21
+ LOCKFILES=$(git diff --cached --name-only 2>/dev/null | grep -E '(package-lock\.json|yarn\.lock|pnpm-lock\.yaml|Cargo\.lock|Gemfile\.lock|poetry\.lock|composer\.lock|go\.sum)' 2>/dev/null)
22
+
23
+ if [ -n "$LOCKFILES" ]; then
24
+ COUNT=$(echo "$LOCKFILES" | wc -l)
25
+ echo "WARNING: $COUNT lockfile(s) modified:" >&2
26
+ echo "$LOCKFILES" | sed 's/^/ /' >&2
27
+ echo "Verify the dependency change was intentional." >&2
28
+ fi
29
+
30
+ exit 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-safe-setup",
3
- "version": "8.5.0",
3
+ "version": "8.6.0",
4
4
  "description": "One command to make Claude Code safe. 59 hooks (8 built-in + 51 examples). 26 CLI commands: dashboard, create, audit, lint, diff, migrate, compare, generate-ci. 284 tests.",
5
5
  "main": "index.mjs",
6
6
  "bin": {