Skip to content

Commit 5f16753

Browse files
DarkaMaulclaude
andcommitted
Add safety prompt to devc sync before copying from containers
Warns users that sync copies files from devcontainers to the host filesystem. Adds --trusted flag to skip the prompt for automation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 31ffca2 commit 5f16753

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

install.sh

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Commands:
3737
exec <cmd> Execute a command in the running container
3838
upgrade Upgrade Claude Code to latest version
3939
mount <host> <cont> Add a mount to the devcontainer (recreates container)
40-
sync [project] Sync Claude Code sessions from devcontainers to host
40+
sync [project] [--trusted] Sync sessions from devcontainers to host
4141
cp <cont> <host> Copy files/directories from container to host
4242
help Show this help message
4343
@@ -334,9 +334,36 @@ cmd_mount() {
334334
}
335335

336336
cmd_sync() {
337-
local filter="${1:-}"
337+
local filter=""
338+
local trusted=false
339+
340+
while [[ $# -gt 0 ]]; do
341+
case "$1" in
342+
--trusted)
343+
trusted=true
344+
shift
345+
;;
346+
*)
347+
filter="$1"
348+
shift
349+
;;
350+
esac
351+
done
352+
338353
local host_projects="${HOME}/.claude/projects"
339354

355+
if [[ "$trusted" == false ]]; then
356+
log_warn "This copies files from devcontainers to your host filesystem."
357+
log_warn "Only proceed if you trust the container contents."
358+
log_info "Use --trusted to skip this prompt."
359+
read -p "Continue? [y/N] " -n 1 -r
360+
echo
361+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
362+
log_info "Aborted."
363+
exit 0
364+
fi
365+
fi
366+
340367
# Discover all devcontainers (running + stopped) by label.
341368
local container_ids
342369
container_ids=$(docker ps -a -q \

0 commit comments

Comments
 (0)