> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Process Multiple Tasks in Parallel

<div id="overview">
  # Overview
</div>

When you want to work on multiple tasks in the same repository simultaneously without them interfering with each other, you can use parallel collaboration. Qoder CLI provides several isolation methods: using **Worktree** to place different tasks into independent Git checkouts, using **Background Agents / Tasks** to run multiple subtasks in parallel, and using **Subagents** to delegate complex work to specialized subagents.

This way, each task has its own workspace and context, preventing multiple sessions from sharing the same directory and overwriting each other's changes.

<div id="worktree">
  # Worktree Isolation
</div>

Worktree allows each task to run in an independent Git working tree without affecting others. Start it with `--worktree`:

```shell theme={null}
qodercli --worktree feature-a
qodercli --worktree feature-a "Implement login fix"
qodercli --worktree
```

* When no name is provided, Qoder automatically generates a worktree name.
* New named worktrees are placed under `<repo>/.qoder/worktrees/<处理后的名称>`, and a corresponding temporary branch is created.
* If a worktree with the same name already exists, it is reused directly instead of being recreated.

This must be run within a Git repository and requires Git to be installed locally. For complete instructions on creating, copying files to, restoring, and cleaning up worktrees, see [Using the CLI](/en/cli/03-using-qoder-cli/01-starting-a-task/using-cli).

<div id="parallel-sessions">
  # Parallel Sessions
</div>

Using Worktree, you can start separate sessions for different tasks, allowing them to run in parallel within their own isolated directories:

```shell theme={null}
# Terminal 1: Work on Task A in the feature-a worktree
qodercli --worktree feature-a "Implement login fix"

# Terminal 2: Work on Task B in the feature-b worktree
qodercli --worktree feature-b "Refactor logging module"
```

Each session has its own working tree and branch, keeping changes isolated from one another. Once completed, they can be committed or merged separately.

<div id="subagents">
  # Background Agents and Subagents
</div>

For a single complex task, you can break it down and delegate parts to multiple Subagents for parallel processing. Use `/tasks` to view currently running background tasks:

```shell theme={null}
/tasks
```

Subagents also support worktree isolation: when a Markdown Subagent needs to modify files in an isolated checkout, add `isolation: worktree` to its definition. Clean Subagent worktrees are automatically deleted upon completion, while those with changes are retained.

For creating, configuring, and orchestrating Subagents, see [Subagent](/en/cli/04-extending-qoder-cli/subagent).

<div id="cleanup">
  # Restoration and Cleanup
</div>

When a session ends, Qoder prints the worktree path and the command to resume the session. When exiting interactively, it checks for uncommitted files and new commits in the worktree: clean worktrees can be automatically deleted, while those with local files or commits will prompt you to choose whether to keep or delete them.

To clean up manually:

```shell theme={null}
git worktree remove <worktree-path>
git branch -d worktree-<processed-name>
```

<div id="tips">
  # Tips
</div>

* **One task per worktree**: Place unrelated tasks in their own worktrees to avoid overlapping changes.
* **When local files are needed**: A new worktree is a clean checkout and does not include untracked files by default. To copy files like `.env`, declare them using `.worktreeinclude` at the repository root. For details, see [Using the CLI](/en/cli/03-using-qoder-cli/01-starting-a-task/using-cli).
* **Clean up promptly**: Delete unnecessary worktrees and temporary branches after tasks are completed and merged to keep the repository tidy.
