cc-safe-setup 28.3.2 → 28.3.4
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 +7 -2
- package/examples/auto-approve-test.sh +35 -0
- package/examples/no-commit-fixup.sh +15 -0
- package/examples/no-push-without-ci.sh +27 -0
- package/index.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ Claude Code ships with no safety hooks by default. This tool fixes that.
|
|
|
64
64
|
|
|
65
65
|
Each hook exists because a real incident happened without it.
|
|
66
66
|
|
|
67
|
-
## All
|
|
67
|
+
## All 45 Commands
|
|
68
68
|
|
|
69
69
|
| Command | What It Does |
|
|
70
70
|
|---------|-------------|
|
|
@@ -87,7 +87,7 @@ Each hook exists because a real incident happened without it.
|
|
|
87
87
|
| `--scan [--apply]` | Tech stack detection |
|
|
88
88
|
| `--export / --import` | Team config sharing |
|
|
89
89
|
| `--verify` | Test each hook |
|
|
90
|
-
| `--install-example <name>` | Install from
|
|
90
|
+
| `--install-example <name>` | Install from 316 examples |
|
|
91
91
|
| `--examples [filter]` | Browse examples by keyword |
|
|
92
92
|
| `--full` | All-in-one setup |
|
|
93
93
|
| `--status` | Check installed hooks |
|
|
@@ -107,6 +107,11 @@ Each hook exists because a real incident happened without it.
|
|
|
107
107
|
| `--why <hook>` | Show real incident behind hook |
|
|
108
108
|
| `--migrate-from <tool>` | Migrate from other hook tools |
|
|
109
109
|
| `--diff-hooks [path]` | Compare hook configurations |
|
|
110
|
+
| `--init-project` | Full project setup (hooks + CLAUDE.md + CI) |
|
|
111
|
+
| `--score` | CI-friendly safety score (exit 1 if below threshold) |
|
|
112
|
+
| `--test-hook <name>` | Test a specific hook with sample input |
|
|
113
|
+
| `--changelog` | Show what changed in each version |
|
|
114
|
+
| `--report` | Generate safety report |
|
|
110
115
|
| `--help` | Show help |
|
|
111
116
|
|
|
112
117
|
## Quick Start by Scenario
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
COMMAND=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
2
|
+
[ -z "$COMMAND" ] && exit 0
|
|
3
|
+
if echo "$COMMAND" | grep -qE '^\s*(npm\s+test|npm\s+run\s+test|npx\s+(jest|vitest|mocha|ava|tap|playwright\s+test|cypress\s+run)|yarn\s+test|pnpm\s+test|bun\s+test)\b'; then
|
|
4
|
+
echo '{"decision":"approve","reason":"Test runner command"}'
|
|
5
|
+
exit 0
|
|
6
|
+
fi
|
|
7
|
+
if echo "$COMMAND" | grep -qE '^\s*(pytest|python\s+-m\s+(pytest|unittest)|tox)\b'; then
|
|
8
|
+
echo '{"decision":"approve","reason":"Python test runner"}'
|
|
9
|
+
exit 0
|
|
10
|
+
fi
|
|
11
|
+
if echo "$COMMAND" | grep -qE '^\s*go\s+test\b'; then
|
|
12
|
+
echo '{"decision":"approve","reason":"Go test runner"}'
|
|
13
|
+
exit 0
|
|
14
|
+
fi
|
|
15
|
+
if echo "$COMMAND" | grep -qE '^\s*cargo\s+test\b'; then
|
|
16
|
+
echo '{"decision":"approve","reason":"Cargo test runner"}'
|
|
17
|
+
exit 0
|
|
18
|
+
fi
|
|
19
|
+
if echo "$COMMAND" | grep -qE '^\s*(phpunit|vendor/bin/phpunit|php\s+artisan\s+test)\b'; then
|
|
20
|
+
echo '{"decision":"approve","reason":"PHP test runner"}'
|
|
21
|
+
exit 0
|
|
22
|
+
fi
|
|
23
|
+
if echo "$COMMAND" | grep -qE '^\s*(rspec|bundle\s+exec\s+rspec|rake\s+test|rails\s+test)\b'; then
|
|
24
|
+
echo '{"decision":"approve","reason":"Ruby test runner"}'
|
|
25
|
+
exit 0
|
|
26
|
+
fi
|
|
27
|
+
if echo "$COMMAND" | grep -qE '^\s*(mvn\s+test|gradle\s+test|./gradlew\s+test)\b'; then
|
|
28
|
+
echo '{"decision":"approve","reason":"Java test runner"}'
|
|
29
|
+
exit 0
|
|
30
|
+
fi
|
|
31
|
+
if echo "$COMMAND" | grep -qE '^\s*dotnet\s+test\b'; then
|
|
32
|
+
echo '{"decision":"approve","reason":".NET test runner"}'
|
|
33
|
+
exit 0
|
|
34
|
+
fi
|
|
35
|
+
exit 0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
INPUT=$(cat)
|
|
2
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
3
|
+
[ -z "$COMMAND" ] && exit 0
|
|
4
|
+
echo "$COMMAND" | grep -qE '^\s*git\s+push\b' || exit 0
|
|
5
|
+
BASE=$(git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null)
|
|
6
|
+
if [ -n "$BASE" ]; then
|
|
7
|
+
BAD_COMMITS=$(git log --oneline "$BASE"..HEAD 2>/dev/null | grep -iE '^[a-f0-9]+ (fixup!|squash!|amend!|WIP:?|wip:?|FIXME:?|TODO:?) ')
|
|
8
|
+
if [ -n "$BAD_COMMITS" ]; then
|
|
9
|
+
echo "WARNING: Branch contains uncommitted fixup/WIP commits:" >&2
|
|
10
|
+
echo "$BAD_COMMITS" | head -5 >&2
|
|
11
|
+
echo "" >&2
|
|
12
|
+
echo "Consider: git rebase -i $BASE to squash these before pushing." >&2
|
|
13
|
+
fi
|
|
14
|
+
fi
|
|
15
|
+
exit 0
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
INPUT=$(cat)
|
|
2
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
3
|
+
[ -z "$COMMAND" ] && exit 0
|
|
4
|
+
echo "$COMMAND" | grep -qE '^\s*git\s+push\b' || exit 0
|
|
5
|
+
if [ -f "package.json" ]; then
|
|
6
|
+
HAS_TEST=$(jq -r '.scripts.test // empty' package.json 2>/dev/null)
|
|
7
|
+
if [ -n "$HAS_TEST" ] && [ "$HAS_TEST" != "echo \"Error: no test specified\" && exit 1" ]; then
|
|
8
|
+
RECENT_TEST=0
|
|
9
|
+
for marker in coverage/.last-run.json test-results junit.xml .nyc_output; do
|
|
10
|
+
if [ -e "$marker" ]; then
|
|
11
|
+
AGE=$(( $(date +%s) - $(stat -c %Y "$marker" 2>/dev/null || echo 0) ))
|
|
12
|
+
if [ "$AGE" -lt 600 ]; then
|
|
13
|
+
RECENT_TEST=1
|
|
14
|
+
break
|
|
15
|
+
fi
|
|
16
|
+
fi
|
|
17
|
+
done
|
|
18
|
+
if [ "$RECENT_TEST" -eq 0 ]; then
|
|
19
|
+
echo "WARNING: Pushing without recent test run." >&2
|
|
20
|
+
echo "Run 'npm test' before pushing to verify changes." >&2
|
|
21
|
+
fi
|
|
22
|
+
fi
|
|
23
|
+
fi
|
|
24
|
+
if [ -f "Makefile" ] && grep -q "^test:" Makefile 2>/dev/null; then
|
|
25
|
+
: # Could check make test recency, but keeping it simple
|
|
26
|
+
fi
|
|
27
|
+
exit 0
|
package/index.mjs
CHANGED
|
@@ -2391,7 +2391,7 @@ async function shield() {
|
|
|
2391
2391
|
if (existsSync(join(cwd, '.env'))) extras.push('env-source-guard');
|
|
2392
2392
|
|
|
2393
2393
|
// Always include these for maximum safety
|
|
2394
|
-
extras.push('scope-guard', 'no-sudo-guard', 'protect-claudemd');
|
|
2394
|
+
extras.push('scope-guard', 'no-sudo-guard', 'protect-claudemd', 'memory-write-guard', 'skill-gate', 'auto-approve-test', 'auto-approve-readonly');
|
|
2395
2395
|
|
|
2396
2396
|
for (const ex of extras) {
|
|
2397
2397
|
const exPath = join(__dirname, 'examples', `${ex}.sh`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safe-setup",
|
|
3
|
-
"version": "28.3.
|
|
4
|
-
"description": "One command to make Claude Code safe.
|
|
3
|
+
"version": "28.3.4",
|
|
4
|
+
"description": "One command to make Claude Code safe. 324 hooks (8 built-in + 316 examples). 45 CLI commands. 941 tests. 5 languages.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cc-safe-setup": "index.mjs"
|