Skip to content

Commit a479f27

Browse files
committed
chore: Add .claude/scripts/rm-tmp.sh wrapper for tmp cleanup
1 parent 4b61735 commit a479f27

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

.claude/scripts/rm-tmp.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
# rm-tmp.sh — Delete files under .claude/tmp/ only.
3+
# Usage: bash <path>/rm-tmp.sh <path> [<path> ...]
4+
#
5+
# Restricts deletion to files under the project's .claude/tmp/ directory
6+
# so that Bash(rm:*) need not be added to the permission allowlist.
7+
# Rejects: paths outside .claude/tmp/, paths containing '..', and directories.
8+
9+
set -euo pipefail
10+
11+
if [ $# -eq 0 ]; then
12+
echo "Error: at least one file path is required" >&2
13+
exit 2
14+
fi
15+
16+
ALLOWED_PREFIX=".claude/tmp/"
17+
18+
for target in "$@"; do
19+
normalized="${target#./}"
20+
21+
if [[ "${normalized}" == *..* ]]; then
22+
echo "Error: path containing '..' is not allowed: ${target}" >&2
23+
exit 1
24+
fi
25+
26+
if [[ "${normalized}" != "${ALLOWED_PREFIX}"* ]]; then
27+
echo "Error: path is not under ${ALLOWED_PREFIX}: ${target}" >&2
28+
exit 1
29+
fi
30+
31+
if [ -d "${normalized}" ]; then
32+
echo "Error: directory deletion is not allowed: ${target}" >&2
33+
exit 1
34+
fi
35+
36+
rm -f -- "${normalized}"
37+
done

.claude/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"Bash(clang-format:*)",
2525
"Bash(cmake-format:*)",
2626
"Bash(.claude/scripts/fetch-diff.sh:*)",
27+
"Bash(.claude/scripts/rm-tmp.sh:*)",
2728
"Bash(python .claude/scripts/render-review.py:*)",
2829
"Read(.claude/tmp/**)",
2930
"Write(.claude/tmp/**)",

0 commit comments

Comments
 (0)