cc-safe-setup 2.3.0 → 2.5.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 +31 -1
- package/SAFETY_CHECKLIST.md +53 -0
- package/action.yml +34 -0
- package/audit-web/index.html +494 -38
- package/docs/index.html +603 -0
- package/examples/case-sensitive-guard.sh +145 -0
- package/examples/session-checkpoint.sh +54 -0
- package/index.mjs +57 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -130,7 +130,9 @@ Or start with the free hooks: [claude-code-hooks](https://github.com/yurukusa/cl
|
|
|
130
130
|
|
|
131
131
|
## Safety Audit
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
**[Try it in your browser](https://yurukusa.github.io/cc-safe-setup/)** — paste your settings.json, get a score instantly. Nothing leaves your browser.
|
|
134
|
+
|
|
135
|
+
Or from the CLI:
|
|
134
136
|
|
|
135
137
|
```bash
|
|
136
138
|
npx cc-safe-setup --audit
|
|
@@ -138,6 +140,29 @@ npx cc-safe-setup --audit
|
|
|
138
140
|
|
|
139
141
|
Analyzes 9 safety dimensions and gives you a score (0-100) with one-command fixes for each risk.
|
|
140
142
|
|
|
143
|
+
### CI Integration (GitHub Action)
|
|
144
|
+
|
|
145
|
+
```yaml
|
|
146
|
+
# .github/workflows/safety.yml
|
|
147
|
+
- uses: yurukusa/cc-safe-setup@main
|
|
148
|
+
with:
|
|
149
|
+
threshold: 70 # CI fails if score drops below this
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Project Scanner
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npx cc-safe-setup --scan # detect tech stack, recommend hooks
|
|
156
|
+
npx cc-safe-setup --scan --apply # auto-create CLAUDE.md with project rules
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Self-Learning Safety
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
npx cc-safe-setup --learn # analyze your block history for patterns
|
|
163
|
+
npx cc-safe-setup --learn --apply # auto-generate custom hooks from patterns
|
|
164
|
+
```
|
|
165
|
+
|
|
141
166
|
## Examples
|
|
142
167
|
|
|
143
168
|
Need custom hooks beyond the 8 built-in ones? Install any example with one command:
|
|
@@ -173,6 +198,11 @@ Or browse all available examples in [`examples/`](examples/):
|
|
|
173
198
|
- **branch-name-check.sh** — Warn on non-conventional branch names (feature/, fix/, etc.)
|
|
174
199
|
- **todo-check.sh** — Warn when committing files with TODO/FIXME/HACK markers
|
|
175
200
|
- **path-traversal-guard.sh** — Block Edit/Write with `../../` path traversal and system directories
|
|
201
|
+
- **case-sensitive-guard.sh** — Detect case-insensitive filesystems (exFAT, NTFS, HFS+) and block rm/mkdir that would collide due to case folding ([#37875](https://github.com/anthropics/claude-code/issues/37875))
|
|
202
|
+
|
|
203
|
+
## Safety Checklist
|
|
204
|
+
|
|
205
|
+
**[SAFETY_CHECKLIST.md](SAFETY_CHECKLIST.md)** — Copy-paste checklist for before/during/after autonomous sessions.
|
|
176
206
|
|
|
177
207
|
## Learn More
|
|
178
208
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Claude Code Safety Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist before running Claude Code autonomously. Copy to your project or CLAUDE.md.
|
|
4
|
+
|
|
5
|
+
## Before First Session
|
|
6
|
+
|
|
7
|
+
- [ ] Install safety hooks: `npx cc-safe-setup`
|
|
8
|
+
- [ ] Run safety audit: `npx cc-safe-setup --audit` (target: score ≥ 80)
|
|
9
|
+
- [ ] Create CLAUDE.md with project-specific rules
|
|
10
|
+
- [ ] Verify .env files are in .gitignore
|
|
11
|
+
- [ ] Ensure git remote is set (so work can be recovered)
|
|
12
|
+
|
|
13
|
+
## Before Autonomous Mode
|
|
14
|
+
|
|
15
|
+
- [ ] Create backup branch: `git checkout -b backup/before-autonomous-$(date +%Y%m%d)`
|
|
16
|
+
- [ ] Commit all current work
|
|
17
|
+
- [ ] Verify destructive-guard is blocking: `npx cc-safe-setup --verify`
|
|
18
|
+
- [ ] Check branch-guard protects main/master
|
|
19
|
+
- [ ] If using database: install `block-database-wipe`
|
|
20
|
+
- [ ] If sensitive configs: install `protect-dotfiles`
|
|
21
|
+
|
|
22
|
+
## During Session
|
|
23
|
+
|
|
24
|
+
- [ ] Monitor context usage (context-monitor hook warns at 40%)
|
|
25
|
+
- [ ] Check blocked-commands.log periodically
|
|
26
|
+
- [ ] Verify commits have meaningful messages
|
|
27
|
+
|
|
28
|
+
## After Session
|
|
29
|
+
|
|
30
|
+
- [ ] Review git log for unexpected changes
|
|
31
|
+
- [ ] Run test suite to catch regressions
|
|
32
|
+
- [ ] Check if any .env files were modified
|
|
33
|
+
- [ ] Review blocked-commands.log for patterns: `npx cc-safe-setup --learn`
|
|
34
|
+
|
|
35
|
+
## Team Setup
|
|
36
|
+
|
|
37
|
+
- [ ] Add GitHub Action to CI: `uses: yurukusa/cc-safe-setup@main`
|
|
38
|
+
- [ ] Set threshold ≥ 70 for CI safety gate
|
|
39
|
+
- [ ] Share `.safety-net.json` or hooks config across team
|
|
40
|
+
- [ ] Document which hooks are required vs optional
|
|
41
|
+
|
|
42
|
+
## Quick Reference
|
|
43
|
+
|
|
44
|
+
| Risk | Prevention | Install |
|
|
45
|
+
|------|-----------|---------|
|
|
46
|
+
| `rm -rf /` | destructive-guard | `npx cc-safe-setup` |
|
|
47
|
+
| Push to main | branch-guard | `npx cc-safe-setup` |
|
|
48
|
+
| .env committed | secret-guard | `npx cc-safe-setup` |
|
|
49
|
+
| Database wiped | block-database-wipe | `--install-example block-database-wipe` |
|
|
50
|
+
| Dotfiles modified | protect-dotfiles | `--install-example protect-dotfiles` |
|
|
51
|
+
| Deploy without commit | deploy-guard | `--install-example deploy-guard` |
|
|
52
|
+
| Commit without tests | verify-before-commit | `--install-example verify-before-commit` |
|
|
53
|
+
| Session crash data loss | session-checkpoint | `--install-example session-checkpoint` |
|
package/action.yml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: 'Claude Code Safety Audit'
|
|
2
|
+
description: 'Check your Claude Code safety setup and fail CI if score is below threshold'
|
|
3
|
+
branding:
|
|
4
|
+
icon: 'shield'
|
|
5
|
+
color: 'green'
|
|
6
|
+
|
|
7
|
+
inputs:
|
|
8
|
+
threshold:
|
|
9
|
+
description: 'Minimum safety score (0-100). CI fails if below this.'
|
|
10
|
+
required: false
|
|
11
|
+
default: '70'
|
|
12
|
+
|
|
13
|
+
runs:
|
|
14
|
+
using: 'composite'
|
|
15
|
+
steps:
|
|
16
|
+
- name: Run safety audit
|
|
17
|
+
shell: bash
|
|
18
|
+
run: |
|
|
19
|
+
echo "::group::Claude Code Safety Audit"
|
|
20
|
+
npx cc-safe-setup@latest --audit 2>&1 | tee /tmp/audit-output.txt
|
|
21
|
+
echo "::endgroup::"
|
|
22
|
+
|
|
23
|
+
# Extract score
|
|
24
|
+
SCORE=$(grep -oP 'Safety Score: \K\d+' /tmp/audit-output.txt || echo "0")
|
|
25
|
+
THRESHOLD="${{ inputs.threshold }}"
|
|
26
|
+
|
|
27
|
+
echo "Safety Score: $SCORE / 100 (threshold: $THRESHOLD)"
|
|
28
|
+
|
|
29
|
+
if [ "$SCORE" -lt "$THRESHOLD" ]; then
|
|
30
|
+
echo "::error::Safety score $SCORE is below threshold $THRESHOLD. Run 'npx cc-safe-setup --audit --fix' to improve."
|
|
31
|
+
exit 1
|
|
32
|
+
else
|
|
33
|
+
echo "::notice::Safety score $SCORE meets threshold $THRESHOLD ✓"
|
|
34
|
+
fi
|