-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskill_disable_not_delete.py
More file actions
39 lines (30 loc) · 995 Bytes
/
skill_disable_not_delete.py
File metadata and controls
39 lines (30 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
"""PreToolUse hook: warn to rename SKILL.md to .disabled instead of deleting."""
import json
import re
import sys
def main():
try:
input_data = json.load(sys.stdin)
except (json.JSONDecodeError, EOFError):
print("{}")
return
tool_name = input_data.get("tool_name", "")
tool_input = input_data.get("tool_input", {})
if tool_name != "Bash":
print("{}")
return
cmd = tool_input.get("command", "")
# Detect rm of SKILL.md or entire skill directory
if re.search(r'rm\s+.*SKILL\.md|rm\s+-r.*skills/', cmd):
print(json.dumps({
"systemMessage": (
"⚠️ **Don't delete skills.** Rename to `.disabled` instead:\n"
"`mv SKILL.md SKILL.md.disabled`\n"
"This preserves the skill for future re-enable. Only delete if permanently replaced."
)
}))
return
print("{}")
if __name__ == "__main__":
main()