Verified Claude Code
Run long tasks in the background with --bg
What it does
--bg returns a session id immediately while the task keeps running. List with claude agents; manage with claude attach, logs, stop.
How
claude --bg "Migrate all tests to pytest"
claude agents
claude attach <id>
How much to trust this
| Applies to | ≥ 2.1.140 |
|---|---|
| Verified | Oct 17, 2026 · v2.1.296 · tested locally 2.1.296 的 --help 中存在;changelog 最早在 2.1.140 提到 |
| Depends on | --bgclaude agentsclaude attach |
| Source | https://code.claude.com/docs/en/cli-reference (official_docs) |