cc-safe-setup 8.9.0 → 9.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 +1 -1
- package/examples/env-drift-guard.sh +40 -0
- package/examples/package-script-guard.sh +41 -0
- package/package.json +1 -1
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 +
|
|
9
|
+
8 built-in + 104 examples = **112 hooks**. 34 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) · [Examples](https://yurukusa.github.io/cc-safe-setup/by-example.html) · [Migration](https://yurukusa.github.io/cc-safe-setup/migration-guide.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,40 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ================================================================
|
|
3
|
+
# env-drift-guard.sh — Detect .env vs .env.example drift
|
|
4
|
+
# ================================================================
|
|
5
|
+
# PURPOSE:
|
|
6
|
+
# When Claude edits .env.example (adding new required vars),
|
|
7
|
+
# warn if .env is missing those variables. Prevents deploy
|
|
8
|
+
# failures from missing environment configuration.
|
|
9
|
+
#
|
|
10
|
+
# TRIGGER: PostToolUse MATCHER: "Edit|Write"
|
|
11
|
+
# ================================================================
|
|
12
|
+
|
|
13
|
+
FILE=$(cat | jq -r '.tool_input.file_path // empty' 2>/dev/null)
|
|
14
|
+
[ -z "$FILE" ] && exit 0
|
|
15
|
+
|
|
16
|
+
# Only trigger when .env.example or .env is edited
|
|
17
|
+
case "$FILE" in
|
|
18
|
+
*.env.example|*.env.sample|*.env.template) ;;
|
|
19
|
+
*) exit 0 ;;
|
|
20
|
+
esac
|
|
21
|
+
|
|
22
|
+
# Compare keys in .env.example vs .env
|
|
23
|
+
EXAMPLE="$FILE"
|
|
24
|
+
ENV_FILE="$(dirname "$FILE")/.env"
|
|
25
|
+
[ -f "$EXAMPLE" ] || exit 0
|
|
26
|
+
[ -f "$ENV_FILE" ] || { echo "WARNING: $ENV_FILE does not exist but $EXAMPLE was updated." >&2; exit 0; }
|
|
27
|
+
|
|
28
|
+
# Extract variable names (KEY=... lines, skip comments)
|
|
29
|
+
EXAMPLE_KEYS=$(grep -E '^[A-Z_]+=' "$EXAMPLE" 2>/dev/null | cut -d= -f1 | sort)
|
|
30
|
+
ENV_KEYS=$(grep -E '^[A-Z_]+=' "$ENV_FILE" 2>/dev/null | cut -d= -f1 | sort)
|
|
31
|
+
|
|
32
|
+
MISSING=$(comm -23 <(echo "$EXAMPLE_KEYS") <(echo "$ENV_KEYS"))
|
|
33
|
+
if [ -n "$MISSING" ]; then
|
|
34
|
+
COUNT=$(echo "$MISSING" | wc -l)
|
|
35
|
+
echo "WARNING: $COUNT variable(s) in $EXAMPLE missing from .env:" >&2
|
|
36
|
+
echo "$MISSING" | head -5 | sed 's/^/ /' >&2
|
|
37
|
+
echo "Update .env to match $EXAMPLE." >&2
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
exit 0
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ================================================================
|
|
3
|
+
# package-script-guard.sh — Warn when package.json scripts change
|
|
4
|
+
# ================================================================
|
|
5
|
+
# PURPOSE:
|
|
6
|
+
# package.json scripts are critical infrastructure — they're
|
|
7
|
+
# often wired into CI/CD. Claude sometimes modifies them without
|
|
8
|
+
# understanding the downstream impact. This hook warns on changes.
|
|
9
|
+
#
|
|
10
|
+
# TRIGGER: PreToolUse MATCHER: "Edit"
|
|
11
|
+
# ================================================================
|
|
12
|
+
|
|
13
|
+
INPUT=$(cat)
|
|
14
|
+
FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
|
|
15
|
+
[ -z "$FILE" ] && exit 0
|
|
16
|
+
|
|
17
|
+
# Only check package.json
|
|
18
|
+
case "$FILE" in
|
|
19
|
+
*/package.json|package.json) ;;
|
|
20
|
+
*) exit 0 ;;
|
|
21
|
+
esac
|
|
22
|
+
|
|
23
|
+
OLD=$(echo "$INPUT" | jq -r '.tool_input.old_string // empty' 2>/dev/null)
|
|
24
|
+
NEW=$(echo "$INPUT" | jq -r '.tool_input.new_string // empty' 2>/dev/null)
|
|
25
|
+
[ -z "$OLD" ] && exit 0
|
|
26
|
+
|
|
27
|
+
# Check if scripts section is being modified
|
|
28
|
+
if echo "$OLD" | grep -q '"scripts"' || echo "$NEW" | grep -q '"scripts"'; then
|
|
29
|
+
echo "NOTE: Modifying package.json scripts section." >&2
|
|
30
|
+
echo "These are often wired into CI/CD pipelines." >&2
|
|
31
|
+
echo "Verify: npm test, npm run build still work after this change." >&2
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# Check if dependencies are being modified
|
|
35
|
+
if echo "$OLD" | grep -qE '"(dependencies|devDependencies|peerDependencies)"' || \
|
|
36
|
+
echo "$NEW" | grep -qE '"(dependencies|devDependencies|peerDependencies)"'; then
|
|
37
|
+
echo "NOTE: Modifying package.json dependencies." >&2
|
|
38
|
+
echo "Run npm install after this change." >&2
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
exit 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safe-setup",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.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": {
|