teardown
它能做什么
提供一份清单和脚本,用于停止某个会话中的所有 smolvm 虚拟机、清理其文件,并检查电脑是否已清理干净。它适合在个人或共享电脑上使用过 smolvm 的任何人。
适用场景
- ✓当你结束一次 smolvm 会话,并希望之后没有任何东西仍在运行时。
- ✓当虚拟机似乎在 Ctrl-C 或崩溃后仍然存活时。
- ✓当你使用过 smolvm 之后,磁盘空间不见了的时候。
技能链接
https://github.com/smol-machines/smolvm/blob/main/docs/teardown/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的 smolvm 测试已经完成。请停止它们启动的所有虚拟机,并清理它们留下的内容。”
每周 5 个新技能,1 分钟读完。
工作原理
预检脚本会列出 smolvm 在电脑上留下的内容。随后,清理脚本会停止该会话创建的虚拟机,删除其状态,并检查结果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Leaving nothing running and nothing behind
Verified on smolvm v1.29.0 on macOS arm64, 2026-10-15, and on v1.18.2 on Linux aarch64, 2026-09-24. This packet exists on its own because the obvious cleanup steps fail here: the obvious assertion gives a false failure, the obvious reaper matches the wrong process or nothing at all, and killing a wrapper around a run does not stop its machine. Anything that starts machines needs this more than it needs any single feature. The Linux runs used the scripts of their date; this version's preflight and cleanup scripts ran on Linux aarch64 on v1.22.2 on 2026-10-03.
The cleanup scripts of credentials, dev-env, docker-in-machine, gpu-cuda and install are this
packet's scripts/cleanup.sh with the PACKET= line changed; branch-and-checkpoint, local-api, pack
and throwaway-machine build on it and add flags of their own.
Procedure
The commands below are relative to this packet's directory; its scripts write nothing to the working directory, so running them from there is safe.
1. See what is there. Read-only: deletes nothing, starts no VM.
scripts/preflight.sh
It reports each state directory with its size, whether an --oci-cache bake cache exists,
whether the launcher symlink and the PATH block are present, and whether state can be relocated
on this platform.
2. Delete the machines your scripts created, and report the rest.
scripts/cleanup.sh # report leftover VM processes
scripts/cleanup.sh --reap # and kill them
--reap kills every VM process under this HOME, a running machine you meant to keep included, so
run plain cleanup.sh first to read the list, and reap only when nothing there should keep running.
cleanup.sh waits up to 20 seconds, polling the machine list, and prints waiting=up to 20s
first: an ephemeral machine's entry retires after its run returns.
Only machines recorded in the state file are deleted, so a machine you or another session created
by hand is never deleted. A script records what it creates with
scripts/cleanup.sh --record <name>, and names must carry the smolskill- prefix or the delete
is skipped. --purge removes the state file once the list is empty.
When the user asks you to clean up machines they made themselves, which is what "clean up
after me" usually means, nothing is recorded and the script reports them as machines=remaining
and leaves them. That is the guard working, not the end of the job. List them, confirm they are
the user's and not another session's, and delete each by name. smolvm machine list --json gives
each machine's created_at, in Unix seconds, and its image: one created before the user's session
began, or under a name they do not recognise, is not theirs to delete without asking.
machine stop on a machine that is already stopped prints Machine '<name>' is not running and
exits 0, so the stop line is safe either way:
smolvm machine list
smolvm machine stop --name <NAME>
smolvm machine delete --name <NAME> --force --cascade
Then run scripts/cleanup.sh again for the process check, and step 3.
The state file lives under ${XDG_STATE_HOME:-$HOME/.local/state}/smolvm-skills/, outside
~/.smolvm and outside smolvm's own caches. Nothing here edits smolvm configuration.
3. Prove it.
scripts/verify-clean.sh
HOME=/tmp/sk SMOLVM=/tmp/sk/.local/bin/smolvm scripts/verify-clean.sh --protected "$HOME/.smolvm" \
--protected "$HOME/.local/share/smolvm" --protected "$HOME/.cache/smolvm" # typed in your real shell
Typed in your real shell, $HOME expands to the real profile before HOME=/tmp/sk applies, so the
checks audit the scratch profile and the three --protected directories are the real
installation's binary, data and cache. On macOS the last two are
~/Library/Application Support/smolvm and ~/Library/Caches/smolvm; a --protected directory
that does not exist fails rather than passing. SMOLVM= points the scan at the scratch install's
binary; on Linux, run it with XDG_DATA_HOME and XDG_CACHE_HOME unset, as the install was.
Anything the real installation wrote today counts, and a running real machine writes to its cache
directory. Stop the real machines first, and pass --since with the time the test began, such as
--since "2026-10-03 14:00".
Every check here is scoped to the HOME it runs under, and the audited_home= line says
which profile the result describes. Run it under a
常见问题
它会删除我仍需要的东西吗?
清理针对的是该会话创建的虚拟机。请先阅读预检列表,查看将被删除的内容。
关闭终端会停止虚拟机吗?
不一定。该技能说明,终止某次运行的包装程序并不会停止其虚拟机,因此它改用清理脚本。
可以在共享电脑上使用吗?
可以。该技能适用于归还借用或共享的电脑,并确保不留下任何东西。
详情
作者的原始描述
Stops every smolvm machine a session started, removes smolvm's state, and proves the host is clean. Use after any smolvm session; when a machine seems to have survived a Ctrl-C or a crash; when disk space has disappeared; when uninstalling smolvm; when tearing down the Kubernetes runtime from a node; or when a borrowed or shared host has to be handed back with nothing left behind. Also use it as the cleanup step for other smolvm work, because the obvious assertions here give false results. Do not use it to delete machines another session created: it removes only what a script recorded under it
repo: smol-machines/smolvm
热度
- GitHub 星标
- 6.9k
- 排名
- #13723
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
branch-and-checkpoint
6.9k帮你的智能体将正在运行的 smolvm 虚拟机保存为检查点,之后恢复,暂停并继续运行,或分支为多个副本。
coding-agent
6.9k帮你的智能体在安全的 smolvm 虚拟机中运行 Claude Code 等编程智能体,并挂载你的项目文件夹。
credentials
6.9k让你的智能体使用你的密钥调用 API,而密钥本身永远不会进入其虚拟机,因此不受信任的代码无法读取它。
dev-env
6.9k教你的智能体保持一个已安装工具的 smolvm 开发虚拟机,使其能快速重启,并在会话之间保留软件包。