cc-safe-setup 28.4.9 → 28.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/COOKBOOK.md +143 -0
- package/README.md +1 -0
- package/index.mjs +1 -1
- package/package.json +1 -1
package/COOKBOOK.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Cookbook — cc-safe-setup Recipes
|
|
2
|
+
|
|
3
|
+
Real-world recipes for common safety scenarios. Each recipe is a single command.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
| I want to... | Command |
|
|
8
|
+
|---|---|
|
|
9
|
+
| Install basic safety | `npx cc-safe-setup` |
|
|
10
|
+
| Maximum protection | `npx cc-safe-setup --shield` |
|
|
11
|
+
| Check my setup | `npx cc-safe-setup --doctor` |
|
|
12
|
+
| See my safety score | `npx cc-safe-setup --audit` |
|
|
13
|
+
|
|
14
|
+
## Blocking Dangerous Commands
|
|
15
|
+
|
|
16
|
+
### Block rm -rf on home/root
|
|
17
|
+
Already included in the default install. To verify:
|
|
18
|
+
```bash
|
|
19
|
+
npx cc-safe-setup --simulate "rm -rf ~"
|
|
20
|
+
# Expected: BLOCKED
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Block database wipes
|
|
24
|
+
```bash
|
|
25
|
+
npx cc-safe-setup --install-example block-database-wipe
|
|
26
|
+
```
|
|
27
|
+
Blocks: `prisma migrate reset`, `rails db:drop`, `DROP TABLE`, etc.
|
|
28
|
+
|
|
29
|
+
### Block npm publish accidents
|
|
30
|
+
```bash
|
|
31
|
+
npx cc-safe-setup --install-example npm-publish-guard
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Auto-Approving Safe Commands
|
|
35
|
+
|
|
36
|
+
### Approve read-only commands (cat, ls, grep)
|
|
37
|
+
```bash
|
|
38
|
+
npx cc-safe-setup --install-example auto-approve-readonly
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Approve test runners
|
|
42
|
+
```bash
|
|
43
|
+
npx cc-safe-setup --install-example auto-approve-test
|
|
44
|
+
```
|
|
45
|
+
Covers: `npm test`, `pytest`, `go test`, `cargo test`, `jest`, `vitest`
|
|
46
|
+
|
|
47
|
+
### Approve git read commands (status, log, diff)
|
|
48
|
+
```bash
|
|
49
|
+
npx cc-safe-setup --install-example auto-approve-git-read
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## File Protection
|
|
53
|
+
|
|
54
|
+
### Protect .env files from edits
|
|
55
|
+
```bash
|
|
56
|
+
npx cc-safe-setup --protect .env
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Protect CLAUDE.md from unauthorized changes
|
|
60
|
+
```bash
|
|
61
|
+
npx cc-safe-setup --install-example protect-claudemd
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Protect dotfiles (~/.bashrc, ~/.aws/)
|
|
65
|
+
```bash
|
|
66
|
+
npx cc-safe-setup --install-example protect-dotfiles
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## YAML Rules (No Coding)
|
|
70
|
+
|
|
71
|
+
Write rules in YAML, compile to hooks:
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
# rules.yaml
|
|
75
|
+
- block: "rm -rf on root"
|
|
76
|
+
pattern: "rm\s+-rf\s+(\/$|~)"
|
|
77
|
+
|
|
78
|
+
- approve: "read-only commands"
|
|
79
|
+
commands: [cat, ls, grep, head, tail]
|
|
80
|
+
|
|
81
|
+
- protect: ".env"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx cc-safe-setup --rules rules.yaml
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Monitoring & Recovery
|
|
89
|
+
|
|
90
|
+
### Auto-save checkpoint before compaction
|
|
91
|
+
```bash
|
|
92
|
+
npx cc-safe-setup --install-example auto-compact-prep
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Track context window usage
|
|
96
|
+
```bash
|
|
97
|
+
npx cc-safe-setup --install-example compact-reminder
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Fix hook permissions on Windows/plugins
|
|
101
|
+
```bash
|
|
102
|
+
npx cc-safe-setup --install-example hook-permission-fixer
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Prevent tool call loops
|
|
106
|
+
```bash
|
|
107
|
+
npx cc-safe-setup --install-example response-budget-guard
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Diagnosing Problems
|
|
111
|
+
|
|
112
|
+
### Why isn't my hook working?
|
|
113
|
+
```bash
|
|
114
|
+
npx cc-safe-setup --doctor
|
|
115
|
+
```
|
|
116
|
+
Checks: jq, settings.json, file existence, permissions, shebangs, exit codes.
|
|
117
|
+
|
|
118
|
+
### Test a specific hook
|
|
119
|
+
```bash
|
|
120
|
+
npx cc-safe-setup --test-hook destructive-guard
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Preview how hooks react to a command
|
|
124
|
+
```bash
|
|
125
|
+
npx cc-safe-setup --simulate "git push --force origin main"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Web Tools
|
|
129
|
+
|
|
130
|
+
All browser-based, nothing leaves your machine:
|
|
131
|
+
|
|
132
|
+
- [Safety Hub](https://yurukusa.github.io/cc-safe-setup/hub.html) — All 23 tools
|
|
133
|
+
- [Validator](https://yurukusa.github.io/cc-safe-setup/validator.html) — Paste settings.json, get score
|
|
134
|
+
- [Permission Checker](https://yurukusa.github.io/cc-safe-setup/permission-checker.html) — Find broken paths
|
|
135
|
+
- [Playground](https://yurukusa.github.io/cc-safe-setup/playground.html) — Write and test hooks
|
|
136
|
+
- [Hook Builder](https://yurukusa.github.io/cc-safe-setup/builder.html) — Generate hooks from English
|
|
137
|
+
|
|
138
|
+
## Further Reading
|
|
139
|
+
|
|
140
|
+
- [Getting Started](https://yurukusa.github.io/cc-safe-setup/getting-started.html)
|
|
141
|
+
- [Common Mistakes](https://yurukusa.github.io/cc-safe-setup/common-mistakes.html)
|
|
142
|
+
- [Troubleshooting](TROUBLESHOOTING.md)
|
|
143
|
+
- [Settings Reference](SETTINGS_REFERENCE.md)
|
package/README.md
CHANGED
|
@@ -356,6 +356,7 @@ See [Issue #1](https://github.com/yurukusa/cc-safe-setup/issues/1) for details.
|
|
|
356
356
|
|
|
357
357
|
## Learn More
|
|
358
358
|
|
|
359
|
+
- [Cookbook](COOKBOOK.md) — 26 practical recipes (block, approve, protect, monitor, diagnose)
|
|
359
360
|
- [Official Hooks Reference](https://docs.anthropic.com/en/docs/claude-code/hooks) — Claude Code hooks documentation
|
|
360
361
|
- [Hooks Cookbook](https://github.com/yurukusa/claude-code-hooks/blob/main/COOKBOOK.md) — 25 recipes from real GitHub Issues ([interactive version](https://yurukusa.github.io/claude-code-hooks/))
|
|
361
362
|
- [Japanese guide (Qiita)](https://qiita.com/yurukusa/items/a9714b33f5d974e8f1e8) — この記事の日本語解説
|
package/index.mjs
CHANGED
|
@@ -5350,7 +5350,7 @@ async function main() {
|
|
|
5350
5350
|
console.log(' ' + c.blue + ' --simulate "cmd"' + c.reset + ' Test how hooks react');
|
|
5351
5351
|
console.log(' ' + c.blue + ' --shield' + c.reset + ' Maximum safety (recommended)');
|
|
5352
5352
|
console.log();
|
|
5353
|
-
console.log(' ' + c.dim + '
|
|
5353
|
+
console.log(' ' + c.dim + '23 web tools: https://yurukusa.github.io/cc-safe-setup/hub.html' + c.reset);
|
|
5354
5354
|
console.log();
|
|
5355
5355
|
}
|
|
5356
5356
|
|
package/package.json
CHANGED