cc-safe-setup 1.9.0 → 1.9.1
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 +8 -1
- package/examples/README.md +9 -6
- package/examples/auto-checkpoint.sh +38 -0
- package/index.mjs +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -128,7 +128,13 @@ Or start with the free hooks: [claude-code-hooks](https://github.com/yurukusa/cl
|
|
|
128
128
|
|
|
129
129
|
## Examples
|
|
130
130
|
|
|
131
|
-
Need custom hooks beyond the 8 built-in ones?
|
|
131
|
+
Need custom hooks beyond the 8 built-in ones? Install any example with one command:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npx cc-safe-setup --install-example block-database-wipe
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Or browse all available examples in [`examples/`](examples/):
|
|
132
138
|
|
|
133
139
|
- **auto-approve-git-read.sh** — Auto-approve `git status`, `git log`, even with `-C` flags
|
|
134
140
|
- **auto-approve-ssh.sh** — Auto-approve safe SSH commands (`uptime`, `whoami`, etc.)
|
|
@@ -143,6 +149,7 @@ Need custom hooks beyond the 8 built-in ones? See [`examples/`](examples/) for r
|
|
|
143
149
|
- **allowlist.sh** — Block everything not explicitly approved — inverse permission model ([#37471](https://github.com/anthropics/claude-code/issues/37471))
|
|
144
150
|
- **protect-dotfiles.sh** — Block modifications to `~/.bashrc`, `~/.aws/`, `~/.ssh/` and chezmoi without diff ([#37478](https://github.com/anthropics/claude-code/issues/37478))
|
|
145
151
|
- **scope-guard.sh** — Block file operations outside project directory — absolute paths, home, parent escapes ([#36233](https://github.com/anthropics/claude-code/issues/36233))
|
|
152
|
+
- **auto-checkpoint.sh** — Auto-commit after every edit for rollback protection ([#34674](https://github.com/anthropics/claude-code/issues/34674))
|
|
146
153
|
|
|
147
154
|
## Learn More
|
|
148
155
|
|
package/examples/README.md
CHANGED
|
@@ -5,6 +5,7 @@ Custom hooks beyond the 8 built-in ones. Copy any file to `~/.claude/hooks/` and
|
|
|
5
5
|
| Hook | Purpose | Related Issue |
|
|
6
6
|
|------|---------|---------------|
|
|
7
7
|
| **allowlist.sh** | Block everything not explicitly approved (inverse model) | [#37471](https://github.com/anthropics/claude-code/issues/37471) |
|
|
8
|
+
| **auto-checkpoint.sh** | Auto-commit after edits for rollback protection | [#34674](https://github.com/anthropics/claude-code/issues/34674) |
|
|
8
9
|
| **auto-approve-build.sh** | Auto-approve npm/yarn/cargo/go build, test, lint | |
|
|
9
10
|
| **auto-approve-docker.sh** | Auto-approve docker build, compose, ps, logs | |
|
|
10
11
|
| **auto-approve-git-read.sh** | Auto-approve `git status/log/diff` even with `-C` flags | [#36900](https://github.com/anthropics/claude-code/issues/36900) |
|
|
@@ -21,14 +22,16 @@ Custom hooks beyond the 8 built-in ones. Copy any file to `~/.claude/hooks/` and
|
|
|
21
22
|
## Quick Start
|
|
22
23
|
|
|
23
24
|
```bash
|
|
24
|
-
#
|
|
25
|
-
|
|
25
|
+
# One command — copies hook, updates settings.json, makes executable
|
|
26
|
+
npx cc-safe-setup --install-example block-database-wipe
|
|
27
|
+
```
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
chmod +x ~/.claude/hooks/block-database-wipe.sh
|
|
29
|
+
Or manually:
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
```bash
|
|
32
|
+
cp examples/block-database-wipe.sh ~/.claude/hooks/
|
|
33
|
+
chmod +x ~/.claude/hooks/block-database-wipe.sh
|
|
34
|
+
# Add to settings.json — see each file's header for the JSON config
|
|
32
35
|
```
|
|
33
36
|
|
|
34
37
|
## List from CLI
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# auto-checkpoint.sh — Auto-commit after every edit for rollback protection
|
|
3
|
+
#
|
|
4
|
+
# Solves: Context compaction silently reverting uncommitted edits (#34674)
|
|
5
|
+
# Also protects against: session crashes, token expiry, any unexpected death
|
|
6
|
+
#
|
|
7
|
+
# Creates lightweight checkpoint commits after every Edit/Write.
|
|
8
|
+
# If anything goes wrong, you can recover with `git log` and `git cherry-pick`.
|
|
9
|
+
#
|
|
10
|
+
# Usage: Add to settings.json as a PostToolUse hook
|
|
11
|
+
#
|
|
12
|
+
# {
|
|
13
|
+
# "hooks": {
|
|
14
|
+
# "PostToolUse": [{
|
|
15
|
+
# "matcher": "Edit|Write",
|
|
16
|
+
# "hooks": [{ "type": "command", "command": "~/.claude/hooks/auto-checkpoint.sh" }]
|
|
17
|
+
# }]
|
|
18
|
+
# }
|
|
19
|
+
# }
|
|
20
|
+
|
|
21
|
+
INPUT=$(cat)
|
|
22
|
+
TOOL=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
|
|
23
|
+
|
|
24
|
+
# Only checkpoint after Edit or Write
|
|
25
|
+
[[ "$TOOL" != "Edit" && "$TOOL" != "Write" ]] && exit 0
|
|
26
|
+
|
|
27
|
+
# Must be in a git repo
|
|
28
|
+
git rev-parse --git-dir &>/dev/null || exit 0
|
|
29
|
+
|
|
30
|
+
# Only commit if there are actual changes
|
|
31
|
+
DIRTY=$(git status --porcelain 2>/dev/null | head -1)
|
|
32
|
+
[[ -z "$DIRTY" ]] && exit 0
|
|
33
|
+
|
|
34
|
+
# Create checkpoint commit
|
|
35
|
+
git add -A 2>/dev/null
|
|
36
|
+
git commit -m "checkpoint: auto-save $(date +%H:%M:%S)" --no-verify 2>/dev/null
|
|
37
|
+
|
|
38
|
+
exit 0
|
package/index.mjs
CHANGED
|
@@ -269,6 +269,7 @@ function examples() {
|
|
|
269
269
|
'allowlist.sh': 'Block everything not in allowlist (inverse permission model)',
|
|
270
270
|
'protect-dotfiles.sh': 'Block modifications to ~/.bashrc, ~/.aws/, ~/.ssh/',
|
|
271
271
|
'scope-guard.sh': 'Block file operations outside project directory',
|
|
272
|
+
'auto-checkpoint.sh': 'Auto-commit after edits for rollback protection',
|
|
272
273
|
};
|
|
273
274
|
|
|
274
275
|
console.log();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safe-setup",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "One command to make Claude Code safe for autonomous operation. 8 hooks: destructive blocker, branch guard, force-push protection, secret leak prevention, syntax checks, and more.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"bin": {
|