# The CLI for agents

> How an agent with a shell uses stuarty: JSON output, exit codes and waiting.

Source: https://stuarty.com/docs/agents/cli/

## The idea

Every command is an adapter over the same service as the MCP tools. For an agent three flags matter: `--json` prints one JSON document and nothing else on standard output; `--actor <label>` names the caller in the history; `--project` (or `STUARTY_PROJECT`) says which project.

## Exit codes

| Code | Meaning |
| --- | --- |
| `0` | success |
| `2` | a retryable error, or a `--wait` that ran out of time |
| `1` | anything else, including a failed file in `media:import` |

With `--json` an error is one JSON document with `code`, `message`, `hint` and `retryable`, and standard error stays empty.

## Waiting

`media:import` and `export` wait by default, up to `--timeout` (ten minutes). `--no-wait` returns the job at once; `job:show <id> --wait` picks it up later. A wait that ran out prints the job as it is and exits `2`.

## Quick start

```bash
stuarty project:create --name "Launch teaser" --description "A 30 second vertical video for people who follow the channel, with captions and a thumbnail." --specific "Publish one video that explains the idea" --measurable "One hundred views in the first week" --achievable "The footage and the script exist" --relevant "It brings the first audience" --time-bound "Edit on Monday, publish on Tuesday" --due 2027-03-31 --json --actor claude-code
stuarty edit --project prj_7k2m9x4q1b --ops - --json < batch.json
stuarty export --project prj_7k2m9x4q1b --json
```

Every command and flag is in the [CLI reference](/docs/reference/cli).

## Commands by domain

Every command belongs to a domain: `project`, `video`, `image`, `writing`, `asset`, `publish`, `provider`, `memory` or `workspace`. `stuarty <domain>` lists the commands of one, and `stuarty <domain> <verb>` runs one: `stuarty image edit` is `image:edit`, `stuarty project list` is `project:list` and `stuarty memory skill list` is `skill:list`. A verb that two commands of a domain share, such as `import` in `asset`, is refused with both full names. The full names (`edit`, `project:list`, `image:create`, ...) keep working and are what the reference and scripts use. `stuarty command:help --domain <domain>` lists the edit operations of a domain, and each domain has a page in [the guide by domain](/docs/agents/domain-video).

## Next steps

- [Connect an agent](/docs/agents/connect)
