Parallel and scheduled work
Scale Claude Code with background sessions, worktrees, batch agents, goals, loops, and cloud routines.
Claude Code now has several ways to keep work moving. They differ in isolation, lifetime, and where execution happens; choose deliberately rather than calling all of them “background agents.”
Background and forked sessions
- Press Ctrl+B to background the current task.
- Use
/tasksto inspect task state. /background <prompt>(alias/bg) detaches a session./fork <prompt>creates an independent background copy./branch <prompt>branches the conversation and switches to that direction.claude agentsopens Agent view for background sessions.
These flows are useful for independent test runs, investigations, and long commands while you continue another thread. See Agent view.
Worktree isolation
Start a session in an isolated Git worktree:
claude --worktree feature-authThe short alias is -w. Custom subagents can request the same boundary with
isolation: worktree in frontmatter. Use .worktreeinclude for required
gitignored inputs that should be copied into new worktrees.
Worktrees isolate files, not external systems. Two agents can still collide in the same database, cloud account, port, queue, or test environment. See Worktrees.
Batch work
For a large task that splits cleanly:
/batch migrate the independent API handlers to the new validation pattern and
run each handler's tests/batch creates a plan and dispatches roughly 5–30 worktree-isolated
subagents. Use it only when file ownership and verification can be partitioned;
a tightly coupled refactor usually benefits from one coordinated session.
Agent teams (experimental)
Agent teams let teammates coordinate directly, but they are experimental, token-heavy, and not automatically isolated in separate worktrees.
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1Use them for research or genuinely separable ownership, not as a default for every multi-file task. See Agent teams.
Continue until a goal
Set an explicit completion condition:
/goal Keep working until the unit tests and production build both pass.Clear it with:
/goal clearA goal continues turns toward a condition; it does not prove the condition. Require command output and independent checks. See Goal.
Loop, session schedule, or routine?
/loop 5m check the deployment and report only state changes/loop repeats while the session stays active. Session scheduling uses
CronCreate, CronList, and CronDelete and also depends on that session.
Routines are persistent cloud automation. Create or manage them with:
/schedule check the release pull request every weekday and summarize blockers
/schedule list
/schedule run/routines is an alias. Routines can respond to schedules, API calls, and
GitHub events without your terminal staying open. See
Scheduled tasks and
Routines.
Decision guide
| Need | Use |
|---|---|
| Keep one local task running | Ctrl+B or /background |
| Create a separate background copy | /fork |
| Branch and switch conversational direction | /branch |
| Isolate concurrent code changes | --worktree |
| Split many independent code units | /batch |
| Continue until a testable condition | /goal |
| Poll while this session is open | /loop |
| Persistent remote trigger or schedule | Routine |