cc-safe-setup 6.0.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 +9 -0
- package/examples/protect-claudemd.sh +45 -0
- package/index.mjs +9 -0
- package/package.json +1 -1
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)
|
|
@@ -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": "6.
|
|
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": {
|