packages/kilo-docs/pages/automate/agent-manager-workflows.md
If you already use the sidebar chat and want to start running multiple agents in parallel, this page is the fastest path to productive. For the full reference of buttons and settings, see the Agent Manager reference.
Cmd+T / Ctrl+T) — same branch, separate conversations. Useful for planner + implementer splits or read-only investigations alongside the main agent.Rule of thumb: if you would stash or switch branches to do the work, create a worktree instead.
{% callout type="info" %} All Agent Manager sessions use the extension's embedded runtime. What each worktree isolates is the filesystem and git state: the branch, the directory, and the terminal. Providers, BYOK keys, custom providers, models, and extension settings are shared with the sidebar. {% /callout %}
{% callout type="warning" %} Git worktrees are lightweight compared with cloning the repository several times, but they are not free. Each worktree has its own checked-out files, and any dependencies, build artifacts, caches, local databases, or generated files created inside that directory count separately on disk. {% /callout %}
Parallel work pays off when sessions are independent — neither one's output depends on the other, and they are unlikely to edit the same files.
Every productive worktree session follows the same rhythm:
Cmd+N / Ctrl+N) and describe the task.Cmd+E / Ctrl+E) or open the worktree's terminal (Cmd+/ / Ctrl+/) and run the tests yourself.Cmd+D / Ctrl+D). Drop inline comments, then Send to chat to feed them back to the agent.The single biggest lever on this loop is keeping each worktree's scope small. A small diff tests quickly, reviews quickly, and PRs quickly.
Something unrelated came up while you are mid-task. Create a new worktree for it (Cmd+N), let the agent work, review when it is done. Your main work is unaffected.
For multi-part features where several pieces share a few core contracts — types, API boundaries, folder layout:
This mirrors how a human team works: agree the API contract first, then split backend and frontend in parallel. The contract removes the need to coordinate mid-flight.
For genuinely hard tasks where you do not know which approach will work:
Cmd+Shift+N / Ctrl+Shift+N) and pick 2–4 versions.A sidebar task grew bigger than planned. From the sidebar chat, choose Continue in Worktree — the session history and any uncommitted changes move into a new worktree, and the sidebar is free again.
A related pattern: use the sidebar as an investigation surface. Start two or three investigation chats in the sidebar, then promote only the ones worth pursuing into worktrees.
For a day of small fixes: one worktree per bug (Cmd+N), one branch per fix, merge each quickly so none drift. Close the worktree when the fix lands.
Press Cmd+T / Ctrl+T inside an existing worktree to open another session on the same branch. Useful for:
Sessions sharing a branch can see each other's commits, so write-heavy work on the same branch needs a little coordination.
Cmd+/ / Ctrl+/) — rooted at the worktree directory, so all commands scope to that branch. Use it for one-off tests, git status, reproducing a bug by hand..kilo/run-script (or .ps1 / .cmd / .bat on Windows) and trigger it with Cmd+E / Ctrl+E. Runs in whichever worktree is selected. Gets WORKTREE_PATH and REPO_PATH in the environment.The moment two worktrees both try to use the same external resource — a port, a cache, an emulator, a container — they collide. Only one process can bind to localhost:3000; only one simulator can be "the simulator".
Two fixes, in order of preference:
WORKTREE_PATH.The same applies to caches (avoid pointing CARGO_TARGET_DIR at a shared path), emulators (create a named simulator per worktree), and containers (use unique container names or COMPOSE_PROJECT_NAME).
A practical run script pattern is to derive a stable port from WORKTREE_PATH, then start the app with that value:
#!/bin/sh
set -e
sum=$(cksum <<EOF | cut -d ' ' -f 1
$WORKTREE_PATH
EOF
)
export PORT=$((4000 + (sum % 1000)))
npm run dev
For Docker Compose, do the same with COMPOSE_PROJECT_NAME so parallel worktrees get separate container names and volumes:
#!/bin/sh
set -e
name=$(basename "$WORKTREE_PATH" | tr -cd '[:alnum:]_-')
export COMPOSE_PROJECT_NAME="kilo_${name}"
docker compose up
If your app or framework supports PORT=0, that can be even simpler for local-only work because the OS chooses a free port. The tradeoff is that the URL changes each run.
Use .kilo/setup-script to make new worktrees runnable without manual setup. It runs after Kilo copies root-level .env and .env.* files, and before the agent starts in the new worktree.
Kilo's env copy is intentionally narrow:
.env or .env.*.envrc, .environment, .env-cmdrc, local certificates, local databases, or ignored tool-specific configPut the remaining project-specific setup in .kilo/setup-script, for example copying apps/web/.env.local, creating a per-worktree database, or installing dependencies. The setup script receives WORKTREE_PATH and REPO_PATH in the environment.
Layer review in before asking a teammate:
Cmd+D) — live diff against the parent branch. Drag filenames into the chat input for @file mentions. Inline-comment the lines you want revisited, then Send to chat to iterate./local-review-uncommitted — slash command, AI review of staged and unstaged changes in the worktree. Good as a last pass before committing./local-review — slash command, AI review of the whole branch vs. its base.kilo review in CI — automated PR review. See Code Reviews for the setup.gh pr create. The PR badge appears on the worktree and stays in sync with CI and reviews.A typical sequence: self-review in the diff panel → /local-review-uncommitted → push → CI review → teammate review.
Over a worktree's life you will merge in two directions: from the worktree back to its parent branch (integrating the work), and from the parent branch into the worktree (staying current). The parent branch is whatever branch the worktree was created from — often main, but not always. The examples below use main; substitute your actual parent branch where relevant.
graph LR
parent["parent branch"]
wt["worktree"]
parent -->|"Pull parent in (stay current)"| wt
wt -->|"Apply / Merge / PR"| parent
Three ways, pick based on how much collaboration the change needs:
git checkout main && git merge <branch>. The natural flow on teams without a PR culture.git push -u origin <branch> && gh pr create --fill from the session terminal. The PR badge appears on the worktree and stays in sync with CI and reviews.When the parent branch moves ahead, ask the agent from the worktree's session:
Merge the latest
origin/maininto this branch and resolve any conflicts. Do not usegit stash.
Save this as a reusable slash command if you do it often.
{% callout type="danger" %}
Never use git stash inside a worktree. Stashes live in the shared .git directory that every worktree points at, so a stash made in one worktree can be popped in another — crossing uncommitted changes between agents. Use a WIP commit or a temporary branch instead.
{% /callout %}
The Agent Manager is good at conflict resolution when you give it context. A low-context ask ("fix the conflicts") often produces a result that compiles but silently drops one side's intent. Tell the agent what each branch was trying to do:
I am merging
<branch>into<target>.<branch>did X.<target>has since added Y. Both need to survive.
Merge the most foundational one first. Then, in each remaining worktree, ask the agent to pull the updated parent branch in (same prompt as above) before merging. The agent handles the merge direction and only escalates conflicts it cannot resolve.
git stash inside a worktree. Stashes cross between worktrees.| Situation | Where |
|---|---|
| Small, interactive task | Sidebar |
| Long task, want to do something else meanwhile | New worktree (Cmd+N) |
| Two or three approaches, pick the winner | Multi-version (Cmd+Shift+N) |
| Sidebar task outgrew the sidebar | Continue in Worktree |
| Separate conversation on the same branch | New tab (Cmd+T) |
| Long conversation, want a fresh context on same branch | New tab, summarize |
| Run the app to verify | Run script (Cmd+E) |
| One-off git or shell commands | Terminal (Cmd+/) |
| Team review | Push + gh pr create |
| Ship without ceremony | Apply to local |