# cs tasks (/docs/cli/tasks)

`cs tasks` drives [Tasks](/docs/tasks) from a shell. A Task is one piece of
work an agent does, on a Box (the machine CoreSpeed gives an agent) or on a
member's machine through [Tie](/docs/cli/tie). [`cs routines`](/docs/cli/routines)
starts Tasks on a schedule or an event, and [`cs models`](/docs/cli/models)
lists the models and seats that run them.

The Agents area is a preview: it may change at any time.

`cs tasks` uses the credential `cs` already holds, so there is no second
sign-in: `CS_TASK_TOKEN` inside a Task's Box, else `CS_API_KEY` when it is
set, else your [`cs login`](/docs/cli/login) session.

## Usage

```bash
cs tasks create [--repo <org/name>] [--branch main] [--engine claude|codex|opencode|cursor|antigravity]
                [--model <id>] [--effort <level>] [--box-type <type> | --machine <id>]
                [--ttl <duration>] [--env <environment-id>|none] [--space <name>] <prompt…|->
cs tasks send <id> <text…|->
cs tasks add-repo <id> [<org/name>]
cs tasks peek <id> [--tail <chars>]
cs tasks wait <id> [--timeout 15m]
cs tasks list [--limit 40] [--cursor <c>] [--search <text>] [--space <name>]
              [--repo <org/name>] [--status active|archived|all]
cs tasks archive <id> [--after <duration>]
cs tasks group <id> <name…> | --none
cs tasks delete <id>
```

Every command takes `--json`: it prints the answer as JSON instead of the
view. `cs tasks --help` prints this usage. Durations are `90s`, `15m`, `2h`,
`1d` or bare seconds. A Task ID is its global ID (`task_…`) or the bare UUID.

```bash
cs tasks create --repo acme/web "Fix the flaky login test, then open a PR."
cs tasks wait task_4f6c…
cs tasks peek task_4f6c…
```

## Spaces

A Task works in one space, named as [`cs spaces`](/docs/cli#spaces) prints
it: `~` (your own, the default), `everyone`, or a team space's slug. Who is
in the space sees the Task and works with it at their level there. `--space`
puts a new Task in a space, and narrows `list` to one. A Task lent to a
space you are in, from a space you are not in, lists as `lent`.

## create

`cs tasks create <prompt>` starts a Task and prints its ID and its page.
The prompt is the Task's first message: the words after the flags, or, with
a lone `-`, everything on stdin, so a prompt of several paragraphs rides a
heredoc.

```bash
cs tasks create --repo acme/web --engine codex --space growth - <<'EOF'
Read issue #42.

Reproduce it with a failing test, fix it, and open a pull request.
EOF
```

```text title="Output"
Started task_4f6c0d3e…
  https://…/a/task_4f6c0d3e…
```

* `--repo` is the repository it checks out, as `org/name`; `--branch` is its
  base branch (default `main`). Leave both out for a Task with no
  repository. The organization's CoreSpeed GitHub App must reach the
  repository: when it does not, the error names the page that installs it.
* `--engine` picks the coding agent: `claude` (the default), `codex`,
  `opencode`, `cursor` or `antigravity`.
* `--model` and `--effort` are checked by the service; a flag you leave out
  gets the default. [`cs models`](/docs/cli/models) lists what they may name.
* `--box-type` picks the Box for this Task, such as `small`, `standard` or
  `large`. Without it, the environment or the plan decides.
  `--machine <id>` runs it on a member's machine through Tie instead.
* `--ttl` archives it this long after it starts.
* `--env` pins an environment; `--env none` starts it with none. Without it,
  the Task gets the team's default environment.
* `--space` is the space it works in; you need the level `use` there. A space
  API key starts Tasks only in its own space.

When the Task was made but its Box did not start, `create` still prints the
ID, says why on stderr, and exits 0: the Task's page has the details.

## send and add-repo

`cs tasks send <id> <text>` queues a message for a Task; it is delivered at
the end of the Task's current turn. `cs` waits up to 30 seconds for the
Task's receipt and prints it; with no receipt it exits `7`, and the message
may or may not be queued. A message of several paragraphs rides stdin, as
for `create`:

```bash
cs tasks send task_4f6c… "pushed fixes at abc123, re-review"
cs tasks send task_4f6c… - < review-notes.md
```

`cs tasks add-repo <id> <org/name>` gives a running Task one more
repository; it is the same `/add-repo` command as in the app, so the Task's
own check answers it. Without a repository, `add-repo` lists the ones the
Task has.

## peek and wait

`cs tasks peek <id>` prints the Task's status and its newest reply prose:
whole messages, newest last, up to 8,000 characters (`--tail <chars>` changes
that). When older prose was left out, it says so on stderr, and `--json` sets
`tailTruncated`.

`cs tasks wait <id>` blocks until the Task's turn ends, then prints its
state. A turn that ended before you ran it counts. It stops after
`--timeout` (default 15 minutes) and exits `7`, so a script can tell "still
working" from a failure:

```bash
cs tasks send "$ID" "pushed fixes, re-review" && cs tasks wait "$ID" --timeout 30m && cs tasks peek "$ID"
```

## list, group, archive and delete

`cs tasks list` is the Tasks you can see as a table, newest first: one Task
a line, with its state, the space it is in, its repository, last update and
title. `--search` matches titles, repositories, branches and IDs; when there
are more, stderr names the `--cursor` for the next page.

`cs tasks group <id> <name>` puts the Task, and every Task it started, in a
group of the task list; `--none` takes them out of it.

`cs tasks archive <id>` archives a Task now; `--after 1h` archives it once
it has been quiet that long. Archiving takes the level `use` in the Task's
space. `cs tasks delete <id>` purges an archived Task's transcript for good.
A Task that is not archived yet is refused, so a purge always takes two
steps.

## As a Task

Inside a Task's Box, `CS_TASK_TOKEN` holds the Task's own token. `cs` reads
it before `CS_API_KEY` and the login session, and then acts as that Task:
the server decides what the Task may do, at most the level `use` in the
spaces it works in. A Task has no sign-in, machine or session of its own, so
its `cs` refuses `login`, `logout`, `switch`, `token`, `mcp-config`, `tie`
and `untie` before it sends anything, with exit `4`.

## Errors

A failure prints `Error: <message>` with one of cs's
[exit codes](/docs/cli#output-and-exit-codes), and `7` when `wait` or
`send` stopped waiting. Each refusal says what to do about it:

| You see                                                                     | What to do                                                                                        |
| --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| `… refused your session` (exit `3`)                                         | Run `cs login`.                                                                                   |
| `… refused the key in CS_API_KEY` (exit `3`)                                | The key is unknown, revoked or expired: replace it, or unset `CS_API_KEY`.                        |
| `the key in CS_API_KEY is a space API key, …` (exit `4`)                    | This command takes a member's credential: use a member's personal API key, or unset `CS_API_KEY`. |
| `A Task or a space API key does not do this: it is at most USE.` (exit `4`) | A Task ran a command that is a person's own; run it as a member.                                  |
| `… is suspended` / `names no organization` (exit `4`)                       | Signing in again does not help; use a key or session of an active organization.                   |
| `… allows …` / `out of credits` (exit `4`)                                  | Archive a Task, or change the plan or add credits on the billing page it names.                   |
| `… is not reachable by any GitHub installation`                             | Install the CoreSpeed GitHub App on the repository's owner, at the link it names.                 |
| `no task <id> that you can see`                                             | The Task does not exist, or it is in a space you are not in.                                      |
| `try again` (exit `5`)                                                      | The service or billing could not answer; retry.                                                   |

## Environment variables

| Variable        | Default | Purpose                                                                     |
| --------------- | ------- | --------------------------------------------------------------------------- |
| `CS_TASK_TOKEN` | unset   | Set in a Task's Box: act as that Task, before `CS_API_KEY` and the session. |
| `CS_API_KEY`    | unset   | Act with this key instead of the `cs login` session.                        |