-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefresh-sandbox-claude.sh
More file actions
executable file
·40 lines (31 loc) · 1.12 KB
/
Copy pathrefresh-sandbox-claude.sh
File metadata and controls
executable file
·40 lines (31 loc) · 1.12 KB
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
40
#!/usr/bin/env bash
set -euo pipefail
# Regenerate .claude/CLAUDE.md by concatenating the global ~/.claude/CLAUDE.md
# with this repo's root CLAUDE.md. Docker sandboxes only read project-level
# config (not ~/.claude), so this keeps a self-contained copy in sync.
#
# Usage: scripts/refresh-sandbox-claude.sh
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
GLOBAL_CLAUDE_MD="${HOME}/.claude/CLAUDE.md"
ROOT_CLAUDE_MD="${PROJECT_ROOT}/CLAUDE.md"
OUTPUT="${PROJECT_ROOT}/.claude/CLAUDE.md"
TMP_OUTPUT="$(mktemp)"
trap 'rm -f "${TMP_OUTPUT}"' EXIT
echo "Global source: ${GLOBAL_CLAUDE_MD}"
echo "Repo source: ${ROOT_CLAUDE_MD}"
echo "Output: ${OUTPUT}"
if [[ ! -f "${GLOBAL_CLAUDE_MD}" ]]; then
echo "error: ${GLOBAL_CLAUDE_MD} not found" >&2
exit 1
fi
if [[ ! -f "${ROOT_CLAUDE_MD}" ]]; then
echo "error: ${ROOT_CLAUDE_MD} not found" >&2
exit 1
fi
cat "${GLOBAL_CLAUDE_MD}" > "${TMP_OUTPUT}"
printf '\n---\n\n' >> "${TMP_OUTPUT}"
cat "${ROOT_CLAUDE_MD}" >> "${TMP_OUTPUT}"
mv "${TMP_OUTPUT}" "${OUTPUT}"
trap - EXIT
echo "Regenerated $(wc -l < "${OUTPUT}") lines."