- Bash Hook - Evaluates commands against regex patterns and path restrictions
- Edit Hook - Validates file paths before modifications
- Write Hook - Checks paths before file creation
Exit codes:
0 = Allow operation
0 + JSON = Ask for confirmation (triggers dialog)
2 = Block operation (stderr fed back to Claude)
Ask patterns: Some operations trigger confirmation dialogs instead of blocking:
git checkout -- . (discards changes)
git stash drop (deletes stash)
DELETE FROM table WHERE id=X (SQL with specific ID)
Or ask Claude:
"Install damage control security hooks"
"Set up protection for my project"
- Install - Set up damage control hooks (global, project, or personal)
- Modify - Add/remove protected paths or blocked commands
- Test - Validate hooks are working correctly
- List - View all active protections across all levels
Wait for response before proceeding.
Direct command routing (skip menu):
- "add ~/.credentials to zero access" → Execute directly, then restart reminder
- "block npm publish command" → Execute directly, then restart reminder
- "protect /secrets folder" → Execute directly, then restart reminder
After reading the workflow, follow it exactly.
Git destructive:
git reset --hard, git push --force (not --force-with-lease)
git clean -fd, git stash clear, git filter-branch
Cloud destructive:
- AWS:
terminate-instances, delete-db-instance, delete-stack
- GCP:
projects delete, instances delete, clusters delete
- Docker:
system prune -a, volume rm
- Kubernetes:
delete namespace, delete all --all
Database destructive:
DELETE FROM table; (no WHERE clause)
DROP TABLE, DROP DATABASE, TRUNCATE TABLE
redis-cli FLUSHALL, dropdb
See scripts/patterns.yaml for complete list.
Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
**TypeScript with Bun (Alternative):**
```bash
# macOS/Linux
curl -fsSL https://bun.sh/install | bash && bun add yaml
# Windows
powershell -c "irm bun.sh/install.ps1 | iex" && bun add yaml
Restart your agent for changes to take effect.
Hooks are only loaded at agent startup. Run /hooks after restart to verify.
| Script |
Purpose |
| scripts/bash-tool-damage-control.py |
PreToolUse hook for Bash commands |
| scripts/edit-tool-damage-control.py |
PreToolUse hook for Edit tool |
| scripts/write-tool-damage-control.py |
PreToolUse hook for Write tool |
| scripts/test-damage-control.py |
Test runner for hook validation |
| scripts/patterns.yaml |
Security patterns and protected paths |
| scripts/settings-template.json |
Hook configuration template |
|
|
- Hooks installed at chosen level (global/project/personal)
patterns.yaml copied alongside hook scripts
settings.json updated with PreToolUse hook configuration
- UV (or Bun) runtime installed
- Agent restarted to load hooks
- Verified with
/hooks command showing damage-control hooks
- Tested with
rm -rf /tmp/test (should be blocked)
1---
2name: damage-control
3description: Install, configure, and manage Claude Code security hooks that block dangerous commands and protect sensitive files. Use when setting up security protection, blocking destructive commands (rm -rf, git reset --hard), protecting sensitive paths (.env, credentials), or managing PreToolUse hooks.
4metadata:
5 source: https://skillmd.com/skills/cfircoo/damage-control
6---
7
8<objective>
9Defense-in-depth protection system for Claude Code. Uses PreToolUse hooks to intercept and validate tool calls before execution, blocking dangerous commands and protecting sensitive files.
10</objective>
11
12<protection_levels>
13| Level | Read | Write | Edit | Delete | Use Case |
14|-------|------|-------|------|--------|----------|
15| **zeroAccessPaths** | No | No | No | No | Secrets, credentials, .env files |
16| **readOnlyPaths** | Yes | No | No | No | System configs, lock files, build artifacts |
17| **noDeletePaths** | Yes | Yes | Yes | No | Important project files, .git/, LICENSE |
18</protection_levels>
19
20<how_it_works>
21PreToolUse hooks intercept tool calls at three points:
22
231. **Bash Hook** - Evaluates commands against regex patterns and path restrictions
242. **Edit Hook** - Validates file paths before modifications
253. **Write Hook** - Checks paths before file creation
26
27**Exit codes:**
28- `0` = Allow operation
29- `0` + JSON = Ask for confirmation (triggers dialog)
30- `2` = Block operation (stderr fed back to Claude)
31
32**Ask patterns:** Some operations trigger confirmation dialogs instead of blocking:
33- `git checkout -- .` (discards changes)
34- `git stash drop` (deletes stash)
35- `DELETE FROM table WHERE id=X` (SQL with specific ID)
36</how_it_works>
37
38<quick_start>
39**Interactive installation:**
40```
41/damage-control install
42```
43
44**Or ask Claude:**
45> "Install damage control security hooks"
46> "Set up protection for my project"
47</quick_start>
48
49<intake>
50What would you like to do?
51
521. **Install** - Set up damage control hooks (global, project, or personal)
532. **Modify** - Add/remove protected paths or blocked commands
543. **Test** - Validate hooks are working correctly
554. **List** - View all active protections across all levels
56
57**Wait for response before proceeding.**
58</intake>
59
60<routing>
61| Response | Workflow |
62|----------|----------|
63| 1, "install", "setup", "deploy" | [workflows/install.md](workflows/install.md) |
64| 2, "modify", "add", "remove", "change" | [workflows/modify.md](workflows/modify.md) |
65| 3, "test", "verify", "check" | [workflows/test.md](workflows/test.md) |
66| 4, "list", "view", "show" | [workflows/list.md](workflows/list.md) |
67
68**Direct command routing (skip menu):**
69- "add ~/.credentials to zero access" → Execute directly, then restart reminder
70- "block npm publish command" → Execute directly, then restart reminder
71- "protect /secrets folder" → Execute directly, then restart reminder
72
73**After reading the workflow, follow it exactly.**
74</routing>
75
76<blocked_commands_summary>
77**Destructive file operations:**
78- `rm -rf`, `rm --recursive`, `sudo rm`
79- `chmod 777`, `chown -R root`
80
81**Git destructive:**
82- `git reset --hard`, `git push --force` (not --force-with-lease)
83- `git clean -fd`, `git stash clear`, `git filter-branch`
84
85**Cloud destructive:**
86- AWS: `terminate-instances`, `delete-db-instance`, `delete-stack`
87- GCP: `projects delete`, `instances delete`, `clusters delete`
88- Docker: `system prune -a`, `volume rm`
89- Kubernetes: `delete namespace`, `delete all --all`
90
91**Database destructive:**
92- `DELETE FROM table;` (no WHERE clause)
93- `DROP TABLE`, `DROP DATABASE`, `TRUNCATE TABLE`
94- `redis-cli FLUSHALL`, `dropdb`
95
96See [scripts/patterns.yaml](scripts/patterns.yaml) for complete list.
97</blocked_commands_summary>
98
99<settings_locations>
100| Level | Settings Path | Hooks Path | Scope |
101|-------|--------------|------------|-------|
102| Global | `~/.claude/settings.json` | `~/.claude/hooks/damage-control/` | All projects |
103| Project | `.claude/settings.json` | `.claude/hooks/damage-control/` | Team-shared |
104| Personal | `.claude/settings.local.json` | `.claude/hooks/damage-control/` | Just you |
105</settings_locations>
106
107<runtime_requirements>
108**Python with UV (Recommended):**
109```bash
110# macOS/Linux
111curl -LsSf https://astral.sh/uv/install.sh | sh
112
113# Windows
114powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
115```
116
117**TypeScript with Bun (Alternative):**
118```bash
119# macOS/Linux
120curl -fsSL https://bun.sh/install | bash && bun add yaml
121
122# Windows
123powershell -c "irm bun.sh/install.ps1 | iex" && bun add yaml
124```
125</runtime_requirements>
126
127<critical_reminder>
128**IMPORTANT:** After any installation or modification:
129
130> **Restart your agent for changes to take effect.**
131
132Hooks are only loaded at agent startup. Run `/hooks` after restart to verify.
133</critical_reminder>
134
135<workflows_index>
136| Workflow | Purpose |
137|----------|---------|
138| [workflows/install.md](workflows/install.md) | Interactive installation at any settings level |
139| [workflows/modify.md](workflows/modify.md) | Add/remove protected paths and blocked commands |
140| [workflows/test.md](workflows/test.md) | Validate all hooks are working correctly |
141| [workflows/list.md](workflows/list.md) | View all active protections |
142</workflows_index>
143
144<scripts_index>
145| Script | Purpose |
146|--------|---------|
147| [scripts/bash-tool-damage-control.py](scripts/bash-tool-damage-control.py) | PreToolUse hook for Bash commands |
148| [scripts/edit-tool-damage-control.py](scripts/edit-tool-damage-control.py) | PreToolUse hook for Edit tool |
149| [scripts/write-tool-damage-control.py](scripts/write-tool-damage-control.py) | PreToolUse hook for Write tool |
150| [scripts/test-damage-control.py](scripts/test-damage-control.py) | Test runner for hook validation |
151| [scripts/patterns.yaml](scripts/patterns.yaml) | Security patterns and protected paths |
152| [scripts/settings-template.json](scripts/settings-template.json) | Hook configuration template |
153</scripts_index>
154
155<success_criteria>
156A working damage-control installation has:
157
158- Hooks installed at chosen level (global/project/personal)
159- `patterns.yaml` copied alongside hook scripts
160- `settings.json` updated with PreToolUse hook configuration
161- UV (or Bun) runtime installed
162- Agent restarted to load hooks
163- Verified with `/hooks` command showing damage-control hooks
164- Tested with `rm -rf /tmp/test` (should be blocked)
165</success_criteria>