Push long builds, test suites, and dev servers to the background and check progress with the monitor tool.
把 build / 测试套件 / dev server 丢到后台,再随时查看进度——不再被一条命令卡死整轮。
Pass run_in_background: true to the bash tool. It returns a handle bg-N immediately instead of blocking:
给 bash 传 run_in_background: true,它立即返回句柄 bg-N:
bash(command="go build ./...", run_in_background=true)
→ [bg: started bg-1] $ go build ./...
Track with: monitor(job="bg-1", action=poll|wait|kill).
timeout_ms. The job runs until it exits, is killed, or the session ends.monitorpoll (default) — incremental output since last checkmonitor(job="bg-1")
→ [bg-1: running, elapsed=12s]
<new output since last poll>
Cursor is server-side — each poll returns only incremental output. No new output = (no new output).
游标是服务端记的——每次 poll 只给你增量输出。
wait — block until exit / match / timeoutmonitor(job="bg-1", action=wait, timeout_ms=60000)
→ [bg-1: exited code=0, elapsed=43s]
<final output>
Three exit paths: task exits, until_regex matches ("Listening on" for a dev server), or timeout.
三条退出路径:任务退出、until_regex 命中(如 dev server 的 "Listening on")、超时。
Cancelling a wait (Esc) stops observing but leaves the job running.
取消 wait(Esc)停止观察但让任务继续跑。
kill — terminatemonitor(job="bg-1", action=kill)
→ [bg-1: killed, elapsed=67s]
Design: PRD feature-bash-monitor.md