# Tasks

> One command gives a coding agent its own git worktree, branch, port and preview link on your box, so several agents work on one repository at once without touching each other's files.

URL: https://prized.dev/docs/tasks
Updated: 2026-12-01

## Start a task [#start-a-task]

```bash
prized task new fix-login -- fix the redirect after login
# ✓ task fix-login on mango
#   branch   task/fix-login (from main)
#   folder   ~/tasks/fix-login
#   agent    Claude Code, with your prompt, in session fix-login
#   preview  https://mango-3100-k7x2q9.p.prized.dev/
#   attach   prized task open fix-login
```

Run it on your machine, like `prized agents run`. It makes the task on the box and returns; the agent keeps working with your laptop closed. A sleeping or paused box wakes first.

| A task gets | What it is |
| --- | --- |
| A worktree | `~/tasks/<name>` on the box: a checkout of the project's repository on a new branch `task/<name>`, cut from the project's current commit. The project's own checkout is not touched. |
| Ignored files | The `.env` files a checkout needs, copied from the project ([Files a worktree needs](#files-a-worktree-needs)). |
| Setup | The repository's `.prized/setup.sh`, run in the worktree before the agent starts ([Setup script](#setup-script)). |
| A port | A free port in `$PORT`, and a link to it for the members of your workspace ([Port and preview link](#port-and-preview-link)). |
| A session | The agent, in a tmux session named for the task, started on your prompt when you give one. |

| Flag | What it does |
| --- | --- |
| `--agent` | `claude`, `codex`, `cursor`, `opencode` or `pi`. Defaults to the agent `prized setup` recorded for this machine, else `claude`. |
| `--from` | The branch, tag or commit the task starts from, such as `--from origin/main`. Defaults to the commit the project's checkout is at. |
| `--branch` | The task's branch, instead of `task/<name>`. A branch that already exists, on the box or on its remote, is checked out as it is, to carry on with it. |
| `--dir` | The project folder on the box, relative to your home there. Defaults to your only synced project, or with none synced, the only folder in `~/code`. With several synced projects, run the command in one of their folders on your machine, or name one. |
| `--trust` | Treat the ref the task starts from as your own code. This runs that ref's code on the box ([Trusted and untrusted starts](#trusted-and-untrusted-starts)). |
| `--copy` | Copy your ignored files into a task whose start is not trusted. |
| `--attach` | Land in the task's session as it starts. |
| `-- PROMPT` | The agent's first message. The words need no quotes. |

* **Names:** lower-case letters, digits, `-` and `_`, 32 at most; anything else is folded the same way every time, so `"Fix login!"` is `fix-login` here and in every later command. Without a name, the task is named for the first words of the prompt, with a number when that name is taken. A name you give that is in use is refused, and so are the session names other commands open (`main`, `claude`, `codex` and the other agents').
* **A project in a subfolder:** when the project is a folder inside its repository, the worktree is the whole repository and the agent starts in the same subfolder of it.
* **Sign-in:** the agent uses the sign-in already on the box. If there is none, the command says so, and the agent waits at its sign-in screen ([Agents](https://prized.dev/docs/agents#start-an-agent)).

## Leave it alone [#leave-it-alone]

An agent that stops to ask waits until you come back. Words after `--` that begin with a flag go to the agent as they are, as with `prized agents run`, so a task can start in a mode that does not ask:

```bash
prized task new auth -- --permission-mode auto "add rate limiting to the login endpoint"
```

```bash
prized task new billing --agent codex -- --sandbox workspace-write --ask-for-approval never "add an invoices page"
```

[Permission modes](https://prized.dev/docs/keep-claude-code-running#3-permission-modes-for-a-run-you-leave-alone) covers Claude Code's, and [Run Codex in the cloud](https://prized.dev/docs/run-codex-in-the-cloud#3-sandbox-and-approvals-before-you-leave-it) Codex's. Claude Code asks once whether it trusts a new folder; a task's worktree takes the answer you already gave for its project on the box, and when there is none the command says the question is waiting. A new task takes nothing from an earlier task of the same name: what Claude Code or Codex remembered about that folder on the box, such as trust and allowed tools, is cleared before anything starts in it.

## See what each is doing [#see-what-each-is-doing]

```bash
prized task ls
# TASK       BRANCH          AGENT   STATE       WORK                       PREVIEW
# auth       task/auth       claude  running     clean                      https://mango-3100-k7x2q9.p.prized.dev/
# fix-login  task/fix-login  claude  waiting 4m  2 uncommitted, 1 unpushed  https://mango-3101-p3m8wd.p.prized.dev/
```

| State | What it means |
| --- | --- |
| `setup` | The setup script is still running; the agent starts when it ends. |
| `running` | The session printed something in the last ten seconds. |
| `waiting` | The session has been quiet, for the time shown: the agent finished its turn, asks a question, or sits at a sign-in. |
| `exited` | The agent is not running: it exited, it was not started, or its whole session is gone. The worktree and its work are still there. |

**WORK** is what removing the task would lose: files changed or new in the worktree (`uncommitted`), and commits made in the task that no remote has (`unpushed`), counted from what the box last fetched. A paused box is not woken to be listed.

## Attach [#attach]

```bash
prized task open fix-login
```

This attaches your terminal to the task's session, as `prized ssh -s fix-login` does; detach with Ctrl-b, then d ([Sessions](https://prized.dev/docs/sessions)). If the session is gone, because the box restarted or the session was closed, `open` starts a new one in the worktree with a shell in it; `claude --continue` there picks the conversation up.

From a browser or a phone, while the task's session is running, the box's terminal on the [dashboard](https://prized.dev/dashboard) opens it with `?session=fix-login` added to its address ([Terminal](https://prized.dev/docs/dashboard#terminal)).

## Remove a task [#remove-a-task]

```bash
prized task rm fix-login
# ✓ task fix-login on mango: session stopped, worktree removed, branch task/fix-login deleted, preview link closed
```

It stops the task's session and what that session started, removes the worktree and closes the preview link. It removes nothing while the task holds work that would go with it:

| The task holds | What `rm` does |
| --- | --- |
| Uncommitted or new files | Refuses. Commit them, or pass `--force`. |
| Commits no remote has | Refuses. Push the branch, or pass `--keep-branch` to remove the folder and keep the branch, or `--force`. |
| Commits on a branch that was deleted or rewritten on the remote, and not merged there as a squash | Refuses, and says so. Push the branch again, or `--keep-branch`, or `--force`. |
| Commits on a remote that does not answer | Refuses, and says so. Run it again when the box reaches the remote, or `--keep-branch`, or `--force`. |
| A rebase, merge, cherry-pick or bisect that was begun and not finished | Refuses. Finish or abort it, or pass `--force`. |
| A process the task did not start, working in its folder (an editor opened there from another terminal, or a session someone opened under the task's name after its own was gone) | Refuses, and lists them. Close them, or pass `--force`, which removes the task and leaves them running. |
| Nothing unsaved | Removes the task. |

`rm` asks the remote what it has at that moment, so a branch the box last saw there does not count once it is deleted or rewritten. A pull request merged as a squash, its branch then deleted, counts as saved when every file the task changed is, on the remote's default branch, exactly as the task left it, and nothing in the worktree is uncommitted. If one of those files has changed there since, or the merge left it different, `rm` asks for `--force`.

Files git ignores are not counted and go with the worktree, a `.env` you edited there included. The branch goes with the task only when the task made it and every commit on it is on a remote; otherwise it stays, and `rm` says so. To carry on with a branch that stayed, `prized task new fix-login --branch task/fix-login --trust`.

Without `--force`, `rm` deletes the task's files and nothing git holds: its branch and HEAD, its index, an unfinished rebase and its submodules' repositories are kept in the project's repository for 14 days. `prized task ls --parked` lists what is kept, with the git commands that bring each part back; there is no one-step restore.

> [!WARNING]
> `--force` deletes the worktree with its uncommitted files, and the task's branch with commits that are nowhere else, and keeps nothing.

## Files a worktree needs [#files-a-worktree-needs]

A worktree holds tracked files only, so a new one has no `.env`. A task copies the ignored files it needs from the project's checkout:

* **With a `.worktreeinclude` file** at the top of the repository: every file or folder that git ignores and that matches a line of it. The file uses `.gitignore` syntax, and it is the same file Claude Code and Conductor read. A folder git ignores as a whole, such as `node_modules`, is copied whole when a line names it, and searched only when a line names a path inside it (`secrets/dev.json`).
* **Without one:** files named `.env`, `.env.*` or `.envrc`, at any depth, that git ignores.

```text title=".worktreeinclude"
.env
.env.local
config/master.key
```

A file that git tracks is never copied (the worktree has it already), and nothing in the worktree is overwritten. Left out, and named in the output:

* **A file the task does not ignore:** one the task's own commit does not ignore, inside a copied folder too, would show up there as a new file to commit.
* **Git's own files:** `.gitignore`, `.gitattributes`, `.gitmodules` and anything named `.git`.
* **A folder with an unreadable name in it:** a folder that holds a file or folder whose name has a line break or another control character is left out whole.
* **A link that leads out of the worktree:** one into the project's own checkout becomes a copy of the ignored file it points to, and any other is left out.

## Setup script [#setup-script]

If the repository has `.prized/setup.sh`, a task runs it once in the new worktree, in the task's session, before the agent starts. Use it for what a fresh checkout needs: installing dependencies, a build, a database.

```bash title=".prized/setup.sh"
pnpm install --frozen-lockfile
createdb "app_$PRIZED_TASK" 2>/dev/null || true
```

| Variable | What it holds |
| --- | --- |
| `PORT` | The task's port. |
| `PRIZED_TASK` | The task's name. |
| `PRIZED_TASK_PATH` | The worktree, `~/tasks/<name>`. |
| `PRIZED_ROOT_PATH` | The project's own checkout, for a file the script needs from it. |

The agent and everything it starts see the same variables. The script's output shows in the session and is kept in `~/.prized/tasks/<name>/setup.log` on the box. The agent starts when the script exits: a program the script leaves running, such as a dev server started with `&`, keeps running and keeps writing to that log.

If the script fails, the session says so and the agent starts anyway. A repository with submodules has them fetched before the script runs.

## Trusted and untrusted starts [#trusted-and-untrusted-starts]

A task runs your project's setup script, git hooks and submodules, gets your ignored files, and passes on the trust you gave Claude Code, when it starts from code you already run: a commit in the project's own history, or on its remote's default branch as the box last fetched it. A task that starts anywhere else, such as a contributor's branch, a pull request's head or a branch of your own that is not merged, runs none of that and gets none of it, and the command says so in one line. Its files are checked out as the commit stores them, through no git filter, Git LFS included.

Such a task starts its agent only when the agent will ask you before it trusts the folder: Claude Code or Codex, started without arguments of their own, on a box where they do not already trust your project. Otherwise the task's session is a shell, and the command says why: read the code and start the agent there, or run `prized task open fix-login --trust`. `--trust`, on `task new` or later on `task open`, is your word that the ref's code may run on the box; `--copy` only copies the ignored files.

## Port and preview link [#port-and-preview-link]

Each task gets a port of its own between 3100 and 3999, one no other task holds and no link is shared at yet, so two dev servers never collide. Start yours on it:

```bash title="you@box ~/tasks/fix-login"
npm run dev -- --port "$PORT"
```

The link `task new` prints opens that port for members of your workspace who can see the box, signed in to Prized ([Share a port](https://prized.dev/docs/ports#share-a-port)). The port also opens on your machine's localhost, like any port on the box ([Ports](https://prized.dev/docs/ports)). `prized task rm` closes the link.

## What git state does to a task [#what-git-state-does-to-a-task]

| The project's checkout | What happens |
| --- | --- |
| Has uncommitted changes | The task starts from the last commit, without them, and the command says so. |
| Is on no branch (detached HEAD) | The task starts from the commit it is at. |
| Is not a git repository, or has no commit yet | Refused, with what to do: a task is a git worktree. |
| Has submodules | They are fetched in the worktree before setup. `rm` also refuses while a submodule holds unsaved work: changed files, a stash, or commits its remote does not have, on a branch, a tag or any other ref of its own, in a submodule you deinitialized too. |

## Several agents at once [#several-agents-at-once]

Each task is a full agent process with its own installs and builds, sharing the box's CPU, memory and disk. [Run multiple agents in parallel](https://prized.dev/docs/parallel-agents) has what a bigger box or a box per agent costs.
