feat: drop the claude- instance-name prefix; tag boxes instead

Instance names now equal the box name (claudebox new --name work -> 'work',
not 'claude-work'). To still tell claudebox's instances apart from any other
incus instances, tag each on creation with user.claudebox=1 and filter status
+ teardown by that tag instead of a name prefix. Clones (new --from) inherit
the tag.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
claude-hdb 2026-07-10 17:09:45 +00:00
parent 0628ac81b6
commit d956614269
2 changed files with 6 additions and 5 deletions

View file

@ -27,7 +27,7 @@ while [ $# -gt 0 ]; do
done
die() { echo "claudebox: $*" >&2; exit 1; }
iname_of() { echo "$remote"claude-"$1"; }
iname_of() { echo "$remote$1"; } # instance name = box name; claudebox tags them with user.claudebox=1
need_name() {
[ "${#args[@]}" -ge 1 ] && [ -n "${args[0]}" ] || die "usage: claudebox $cmd <box>"
}
@ -66,6 +66,7 @@ new() {
# shellcheck disable=SC2054 # "root,size=60GiB" is a single incus argument
if [ "$m" = vm ]; then extra+=(--vm --device root,size=60GiB); else extra+=(--config security.nesting=true); fi
incus launch images:debian/13/cloud "$instance" --profile claude-dev \
--config user.claudebox=1 \
--config cloud-init.user-data="$(cat "$root/cloud-init/user-data.yaml")" \
"${extra[@]}"
wait_agent "$instance"
@ -84,6 +85,6 @@ case "$cmd" in
down) need_name; incus stop "$(iname_of "${args[0]}")" ;;
start) need_name; incus start "$(iname_of "${args[0]}")" ;;
rm) need_name; incus delete -f "$(iname_of "${args[0]}")"; echo "claudebox: removed $(iname_of "${args[0]}")" ;;
status) incus list "${remote}claude-" ;;
status) incus list ${remote:+"$remote"} "user.claudebox=1" ;;
help|*) sed -n '2,9p' "$0" | sed 's/^# \{0,1\}//' ;;
esac

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Reverse everything host/setup-host.sh created: all claude-* instances, the
# Reverse everything host/setup-host.sh created: all claudebox instances, the
# claudenet network + ACL, the claude-dev profile, and the firewall rules.
# Usage: ./host/teardown-host.sh [--purge-incus]
# --purge-incus also apt-purge Incus itself (skipped if non-claudebox
@ -9,14 +9,14 @@ set -euo pipefail
purge=false
[ "${1:-}" = "--purge-incus" ] && purge=true
echo "This removes ALL claude-* instances (uncommitted work in them is lost),"
echo "This removes ALL claudebox instances (uncommitted work in them is lost),"
echo "the claudenet network/ACL/profile, and the claudebox firewall rules."
$purge && echo "Incus itself will also be uninstalled (--purge-incus)."
read -rp "Continue? [y/N] " a
case "$a" in y|Y) ;; *) echo "aborted"; exit 1 ;; esac
# Instances
for i in $(incus list -f csv -c n | grep '^claude-' || true); do
for i in $(incus list "user.claudebox=1" -f csv -c n || true); do
echo "deleting instance $i"
incus delete -f "$i"
done