cc-safe-setup 11.8.0 → 12.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 +15 -0
- package/examples/git-remote-guard.sh +32 -0
- package/examples/subagent-scope-guard.sh +33 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,6 +109,21 @@ Each hook exists because a real incident happened without it.
|
|
|
109
109
|
| `--diff-hooks [path]` | Compare hook configurations |
|
|
110
110
|
| `--help` | Show help |
|
|
111
111
|
|
|
112
|
+
## Quick Start by Scenario
|
|
113
|
+
|
|
114
|
+
| I want to... | Command |
|
|
115
|
+
|---|---|
|
|
116
|
+
| Make Claude Code safe right now | `npx cc-safe-setup --shield` |
|
|
117
|
+
| Stop permission prompt spam | `npx cc-safe-setup --install-example auto-approve-readonly` |
|
|
118
|
+
| Enforce a rule instantly | `npx cc-safe-setup --guard "never delete production data"` |
|
|
119
|
+
| See what risks my project has | `npx cc-safe-setup --suggest` |
|
|
120
|
+
| Convert CLAUDE.md rules to hooks | `npx cc-safe-setup --from-claudemd` |
|
|
121
|
+
| Share hooks with my team | `npx cc-safe-setup --team && git add .claude/` |
|
|
122
|
+
| Choose a safety level | `npx cc-safe-setup --profile strict` |
|
|
123
|
+
| See what Claude blocked today | `npx cc-safe-setup --replay` |
|
|
124
|
+
| Know why a hook exists | `npx cc-safe-setup --why destructive-guard` |
|
|
125
|
+
| Migrate from Cursor/Windsurf | [Migration Guide](https://yurukusa.github.io/cc-safe-setup/migration-guide.html) |
|
|
126
|
+
|
|
112
127
|
## How It Works
|
|
113
128
|
|
|
114
129
|
1. Writes hook scripts to `~/.claude/hooks/`
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ================================================================
|
|
3
|
+
# git-remote-guard.sh — Block push/fetch to unknown git remotes
|
|
4
|
+
# ================================================================
|
|
5
|
+
# PURPOSE:
|
|
6
|
+
# Claude might add a new git remote and push code to it.
|
|
7
|
+
# This hook warns when git push/fetch targets a remote that
|
|
8
|
+
# wasn't in the original repo configuration.
|
|
9
|
+
#
|
|
10
|
+
# TRIGGER: PreToolUse MATCHER: "Bash"
|
|
11
|
+
# ================================================================
|
|
12
|
+
|
|
13
|
+
COMMAND=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
14
|
+
[ -z "$COMMAND" ] && exit 0
|
|
15
|
+
|
|
16
|
+
# Check for git remote add
|
|
17
|
+
if echo "$COMMAND" | grep -qE '\bgit\s+remote\s+add\b'; then
|
|
18
|
+
echo "WARNING: Adding a new git remote." >&2
|
|
19
|
+
echo "Command: $COMMAND" >&2
|
|
20
|
+
echo "Verify this is a trusted repository." >&2
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# Check for push to non-origin remote
|
|
24
|
+
if echo "$COMMAND" | grep -qE '\bgit\s+push\s+(?!origin\b)\w'; then
|
|
25
|
+
REMOTE=$(echo "$COMMAND" | grep -oE 'git\s+push\s+(\S+)' | awk '{print $3}')
|
|
26
|
+
if [ -n "$REMOTE" ] && [ "$REMOTE" != "origin" ]; then
|
|
27
|
+
echo "WARNING: Pushing to non-origin remote: $REMOTE" >&2
|
|
28
|
+
echo "Verify this remote is trusted." >&2
|
|
29
|
+
fi
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
exit 0
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ================================================================
|
|
3
|
+
# subagent-scope-guard.sh — Limit subagent file access scope
|
|
4
|
+
# ================================================================
|
|
5
|
+
# PURPOSE:
|
|
6
|
+
# In multi-agent setups, subagents should only modify files
|
|
7
|
+
# within their assigned directory. This hook reads a scope
|
|
8
|
+
# file (.claude/agent-scope.txt) and blocks writes outside it.
|
|
9
|
+
#
|
|
10
|
+
# TRIGGER: PreToolUse MATCHER: "Edit|Write"
|
|
11
|
+
#
|
|
12
|
+
# Setup: echo "src/auth/" > .claude/agent-scope.txt
|
|
13
|
+
# ================================================================
|
|
14
|
+
|
|
15
|
+
INPUT=$(cat)
|
|
16
|
+
FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
|
|
17
|
+
[ -z "$FILE" ] && exit 0
|
|
18
|
+
|
|
19
|
+
SCOPE_FILE=".claude/agent-scope.txt"
|
|
20
|
+
[ -f "$SCOPE_FILE" ] || exit 0
|
|
21
|
+
|
|
22
|
+
SCOPE=$(cat "$SCOPE_FILE" | head -1 | tr -d '\n')
|
|
23
|
+
[ -z "$SCOPE" ] && exit 0
|
|
24
|
+
|
|
25
|
+
# Check if file is within scope
|
|
26
|
+
case "$FILE" in
|
|
27
|
+
${SCOPE}*) exit 0 ;; # Within scope
|
|
28
|
+
*)
|
|
29
|
+
echo "BLOCKED: File $FILE is outside agent scope ($SCOPE)." >&2
|
|
30
|
+
echo "This agent should only modify files under $SCOPE" >&2
|
|
31
|
+
exit 2
|
|
32
|
+
;;
|
|
33
|
+
esac
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safe-setup",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.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": {
|