命令
coderemote 能做的一切,一次一个命令。
$ coderemote up # share this folder, print the pairing QR $ coderemote status # running agents and their terminal sessions $ coderemote kill <id>... | --all # end terminal sessions $ coderemote stop [--all] # stop the agent for this folder $ coderemote serve # share on 127.0.0.1 only, no tunnel $ coderemote requests [PORT] # requests that reached a previewed port $ coderemote request <ID> # headers and bodies of one request $ coderemote setup claude # follow Claude Code sessions in the app $ coderemote setup codex # the same for Codex $ coderemote devices # phones enrolled with this folder $ coderemote devices revoke <id> # remove one phone $ coderemote devices policy <level> # how strict Face ID is $ coderemote rotate-token # revoke every paired device $ coderemote tunnels # your Dev Tunnels account's tunnels $ coderemote tunnels delete <id> # delete ones nothing uses $ coderemote login # sign in to Dev Tunnels again $ coderemote update # install the latest version $ coderemote help # all options
up
通过私有的 Microsoft Dev Tunnel 共享当前文件夹,并打印配对二维码。这是你日常使用的命令。
$ coderemote up $ coderemote up --root ~/projects # share another folder $ coderemote up --web # also open it in VS Code on vscode.dev
它会在 127.0.0.1 上启动一个小型智能体,必要时让你登录 Dev Tunnels,向外连接到中继,并打印三样东西:正在共享的文件夹、谁可以访问,以及用于配对的链接。它会一直运行,直到你按下 Ctrl+C 或关闭终端。
| 选项 | 作用 |
|---|---|
--root DIR | 共享 DIR,而不是当前文件夹。 |
--port N | 监听本地端口 N(默认 31580)。当其他程序已占用该端口时修改它。 |
--allow-anonymous | 跳过手机上的账号登录:仅凭配对令牌即可访问。别名 --no-auth。 |
--web | 同时运行 VS Code 的 code tunnel,并打印一个 vscode.dev 链接,可在浏览器的完整编辑器中打开该文件夹。 |
--web 使用 VS Code 自己的隧道,而不是 Code Remote 的。它用自己的 GitHub 账号登录,并让浏览器访问整台机器,而不仅是共享文件夹。它需要 PATH 中有 VS Code 的 code 命令。
status
列出这台电脑上正在运行的智能体,以及每个智能体中的终端会话。别名为 ps。
$ coderemote status
/Users/you/projects/my-app (pid 4121, port 31580, up 2h)
https://…devtunnels.ms
3f9a2c1e zsh pid 4188 2h 1 attached
b71d04aa claude pid 5230 14m detached
每个会话显示它的 id、标题、进程 id、存续时间,以及此刻是否有手机连接。detached 的会话仍在运行,等待应用重新连接。
kill
结束终端会话。使用 status 中 id 的前几个字符就足够了。
$ coderemote kill b71d killed b71d04aa (claude) in /Users/you/projects/my-app $ coderemote kill --all # every session in every agent
智能体本身继续运行;要停止它,请使用 stop。
stop
停止共享当前文件夹的智能体,并结束它的隧道和终端会话。当 up 运行在你够不到的窗口中时很方便。
$ coderemote stop # the agent for this folder $ coderemote stop --all # every agent on this computer
serve
只在 127.0.0.1 上启动智能体,不使用隧道,也无需登录,并打印本地 URL 和令牌。用于本地测试和开发;你的手机无法访问它。
$ coderemote serve
coderemote agent on http://127.0.0.1:31580
Sharing: /Users/you/projects/my-app
Token: …
requests
打印到达你在应用中预览的端口的请求,与应用中显示的日志相同。它是为终端里的编程智能体(如 Claude Code 或 Codex)设计的:让它运行 coderemote requests,就能看到你的页面或 webhook 实际发送了什么,以及你的服务器回复了什么。需要 coderemote 0.3.0 或更高版本。
$ coderemote requests #41 200 GET /api/me 8 ms 212 B 10:20:31 #42 401 POST /api/orders 5 ms 38 B 10:20:33 $ coderemote request 42 #42 POST /api/orders -> 401 authorization: Bearer [redacted] …
在共享文件夹(或其子目录)中运行,以便找到该文件夹的智能体;只有一个智能体在运行时,在哪里运行都行。不指定端口时,会读取当前正在预览的所有端口。已停止的预览会保留日志:指定它的端口即可读取。
| 命令或选项 | 作用 |
|---|---|
requests [PORT] | 每个请求一行,最早的在前:id、状态、方法和路径、耗时、大小和时间。 |
request <ID> [PORT] | 某个请求的请求头和请求体。JSON 会缩进显示;超过 64 KB 的请求体不会保留。 |
requests clear [PORT] | 清空已记录的请求,与应用中的 Clear 相同。 |
--grep TEXT | 仅显示方法或路径包含 TEXT 的请求。 |
--failed | 仅显示错误以及 4xx/5xx 响应。 |
--limit N | 显示最近 N 个(默认 50)。 |
--json | 机器可读的输出,供脚本使用。 |
--show-secrets | 打印默认被遮蔽的值(见下文)。 |
除非你要求,否则机密信息会被遮蔽:Authorization 请求头(保留 Bearer 之类的方案)、Cookie 值(保留名称)、名称像 token、key 或 session 的请求头,以及查询字符串、JSON 和表单请求体中的 password、access_token 等字段。输出会说明隐藏了多少个值。当智能体需要某个值时(例如在测试中复用会话令牌),加上 --show-secrets。
不会向磁盘写入任何内容:该命令读取智能体保存在内存中的日志,每个端口最近 200 个请求。
setup claude, setup codex
把 Code Remote 插件安装到 Claude Code 或 Codex 中,让它们的会话显示在应用的 Agents 标签页,并让你在手机上回答它们的提示。Codex 只有在你信任一次之后才会运行插件的 hook:打开 Codex 并输入 /hooks。--remove 会卸载它。请参阅编程智能体。
$ coderemote setup claude $ coderemote setup codex
devices
列出已在该文件夹运行中的代理上登记的手机,以及每部手机的登记时间、最后一次出现的时间和 Face ID 设置。手机在扫描二维码后第一次连接时会自行登记。
$ coderemote devices $ coderemote devices revoke 94d5 # an id prefix is enough $ coderemote devices policy terminal+writes --window 30m
revoke 立即移除一部手机:它的会话和打开的终端会结束,除非重新配对,否则无法回来。policy 设置哪些操作需要 Face ID:none、terminal(默认:终端、编程代理和构建)或 terminal+writes(还包括文件和 git 更改),并用 --window 设置一次验证的有效时长:5m(默认)、30m 或 1h。应用可以让它更严格;在应用中放宽则需要 Face ID。
rotate-token
更换访问令牌和这台电脑的密钥,并忘记所有已登记的手机。所有已配对的手机会立即失去访问权限。如果你丢失了唯一的手机或配对链接泄露,请使用它。
$ coderemote rotate-token
Token rotated. Re-pair your devices, and restart running agents.
然后重启 coderemote up,并在你仍然信任的设备上扫描新的二维码。
tunnels
列出你的 Dev Tunnels 账号下的隧道,并删除不再使用的。一个账号最多保留 10 个隧道。每台运行 coderemote 的电脑占用一个,智能体运行期间还会为预览多占用一个,而旧电脑或重新安装会留下它们的隧道。需要 coderemote 0.3.6 或更高版本。
$ coderemote tunnels silent-lake-pqv9b80.usw2 online · this computer's agent on port 31580 · coderemote my-mac brave-hill-x7k2m41.usw2 online · this computer's previews on port 31580 · coderemote preview my-mac quiet-fox-3hd8w2c.usw2 coderemote old-laptop $ coderemote tunnels delete quiet-fox-3hd8w2c deleted quiet-fox-3hd8w2c.usw2
每一行显示隧道的 id;当有智能体正在提供服务时显示 online;这台电脑用它做什么;以及它的描述,其中写明了创建它的电脑。给出 id 时,区域后缀(.usw2)是可选的。
| 命令或选项 | 作用 |
|---|---|
tunnels | 你所登录账号下的每个隧道占一行。 |
tunnels delete <id>... | 删除这些隧道。在线的,或这台电脑正在使用的,会被保留,除非你加上 --force。 |
--force | 仍然删除。它的 URL 会失效,与它配对的手机必须重新配对;在这台电脑上,下一次 up 会创建一个新的。 |
你很少需要手动执行:账号已满时,up 和预览会先删除没有智能体在使用的预览隧道。只有这样仍腾不出空位时,up 才会停止,列出账号的隧道并请你删除一些。
login
登录 Microsoft Dev Tunnels。up 会在需要时自动完成,所以只有在切换账号或没有浏览器时才需要手动运行。
$ coderemote login # GitHub, in the browser $ coderemote login --microsoft # a Microsoft account $ coderemote login --device-code # no browser here: enter a code on another device
手机必须使用相同的账号登录,除非你运行 up --allow-anonymous。
update
以你安装时的方式安装最新的 coderemote:使用 npm(或 pnpm、yarn、bun)、使用 Homebrew,或安装到安装脚本下载的 Node.js 中。有新版本时,up 会在配对链接下方提示;它每天最多询问 npm 一次,绝不会拖慢启动。设置 CODEREMOTE_NO_UPDATE_CHECK=1 可关闭此功能。
$ coderemote update $ coderemote --version # the version you're running
已在运行的智能体在你重启之前仍是旧版本:先运行 coderemote stop --all,然后再次运行 coderemote up。
help
打印所有命令和选项。单独运行 coderemote,或在命令行任意位置加上 --help,效果相同,因此打错字绝不会意外开始共享文件夹。
选项
| 选项 | 命令 | 默认值 |
|---|---|---|
--root DIR | up, serve, stop | 当前文件夹 |
--port N | up, serve | 31580 |
--allow-anonymous | up | 关闭 |
--web | up | 关闭 |
--all | kill, stop | |
--force | tunnels delete | 关闭 |
--microsoft, --device-code | login | GitHub,在浏览器中 |