# Mutagent CLI

<p align="center">
  <a href="https://www.npmjs.com/package/@mutagent/cli"><img src="https://img.shields.io/npm/v/@mutagent/cli?style=for-the-badge&color=cb3837&logo=npm&logoColor=white" alt="npm"></a>
  <a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node-22.18+-339933?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js 22.18+"></a>
  <a href="https://bun.sh"><img src="https://img.shields.io/badge/Bun-1.1+-f472b6?style=for-the-badge&logo=bun&logoColor=white" alt="Bun 1.1+"></a>
  <a href="https://www.apache.org/licenses/LICENSE-2.0"><img src="https://img.shields.io/badge/License-Apache_2.0-blue?style=for-the-badge" alt="License: Apache 2.0"></a>
</p>

<p align="center">
  <strong>Run Helix and your own agents in cloud sandboxes, from your terminal or your coding agent.</strong>
</p>

`mutagent` is the command-line client for the [Mutagent](https://mutagent.io) platform. With it you can:

- sign in and choose a workspace;
- add your own LLM provider keys (BYOK);
- store the variables and secrets your agents' tools need;
- run Helix on a task in a cloud sandbox, and follow or steer the session;
- deploy and run managed agents (`agent.md` folders);
- connect GitHub and Slack, and set up triggers and routines that start runs;
- install the Helix binary on your own machine.

Every command supports `--json`, so a coding agent can drive the CLI as easily as a person can.

**Documentation:** [docs.mutagent.io/cli](https://docs.mutagent.io/cli)

---

## Contents

- [Install](#install)
- [Quick start](#quick-start)
- [Concepts](#concepts)
- [Commands](#commands)
- [Scripts, CI and coding agents](#scripts-ci-and-coding-agents)
- [Configuration](#configuration)
- [Links](#links)

---

## Install

```bash
npm install -g @mutagent/cli
# or
bun install -g @mutagent/cli

mutagent --version
```

Requires Node.js 22.18 or later, or Bun 1.1 or later.

## Quick start

```bash
# 1. Sign in: opens the browser (or set MUTAGENT_API_KEY, see below)
mutagent login

# 2. Add an LLM provider key, read from stdin so it stays out of your shell history
mutagent providers add --provider openai --name "My OpenAI" --api-key-stdin < key.txt
#    or copy the keys from your local Helix login
mutagent providers mirror

# 3. Create an Environment: the variables and secrets a sandbox gets
mutagent env set staging GREETING=hello --secrets-from-file .env.secrets

# 4. Run an agent.md folder on a task with the local Helix binary
mutagent install helix
mutagent agent run reviewer/agent.md "check the deploy"
```

`mutagent architech` runs the Architech harness on a task in a cloud sandbox.

## Concepts

- **Workspace**: the scope most commands act in. Your sign-in key works in every workspace you
  belong to in its organization. `mutagent workspaces use <name>` selects one, and `--workspace`
  overrides it for a single command.
- **LLM provider (BYOK)**: a model provider key (OpenAI, Anthropic, Google, ...) stored in the
  workspace, encrypted. A cloud run uses it to call models. Manage them with
  `mutagent providers`.
- **Environment**: a named set of variables and secrets an agent's tools need, such as a GitHub
  token or a database URL. Load one into a run with `--env <name>`. Values are write-only:
  `mutagent env show` prints names and fingerprints, never a value. LLM provider keys do not
  belong here.
- **Cloud session**: a cloud run of the Architech harness, addressed by a reference (`hs1_...`)
  that is printed when the run starts. `mutagent architech session` lists sessions, attaches to them, sends input,
  answers their questions, stops, checkpoints and restores them. A sandbox idle for 15 minutes is
  stopped, and an interactive session in it is checkpointed first.
- **Managed agent**: a folder whose entry file is `agent.md` (YAML frontmatter, then the standing
  prompt). `mutagent agent deploy` stores each change as a new revision. A slot is the agent in one
  Environment (`--env`).
- **Sandbox provider and preset**: where a cloud run executes, and the named sandbox definition it
  uses. Both are managed by the platform. You choose a sandbox provider per run with
  `--sandbox-provider`.
- **Gateway**: connects GitHub and Slack, and runs Helix when an event or a schedule fires.

## Commands

Run `mutagent --help`, or `mutagent <command> --help`, for the full and current flags of any
command. The [command reference](https://docs.mutagent.io/cli/commands) covers each group in
detail.

### Sign in and workspaces

```bash
mutagent login                          # In a terminal, choose browser or API key
mutagent login --browser                # Browser sign-in (sign in or sign up)
mutagent login --org <slug>             # Sign in for another organization
MUTAGENT_API_KEY=mg_live_... mutagent login --json   # Sign in with a key (CI)

mutagent auth status                    # Sign-in state, endpoint and active workspace
mutagent auth logout                    # Clear the stored credentials

mutagent workspaces list                # Your workspaces in the key's organization
mutagent workspaces use <name|id>       # Every later command works in this workspace
mutagent workspaces current             # The key's scope, organization and workspace
mutagent workspaces get <id>            # One workspace

mutagent config list                    # Every setting
mutagent config get endpoint            # One setting
mutagent config set workspace <name|id> # Same as: mutagent workspaces use
mutagent config set org <id|slug>       # Confirm the key's organization
mutagent config server                  # The API deployment answering: environment, version, commit

mutagent usage                          # Count the workspace's LLM providers and your workspaces
```

`mutagent auth login` is the same command as `mutagent login`. Create or change workspaces in the
dashboard at [app.mutagent.io](https://app.mutagent.io).

### LLM providers (`providers`)

```bash
mutagent providers mirror               # Copy the keys from your local Helix login (shows the plan, asks first)
mutagent providers list                 # The workspace's LLM providers
mutagent providers list --models        # Catalogue models per LLM provider type
mutagent providers get <id>
mutagent providers test <id>            # Test the saved key
mutagent providers add --provider anthropic --name "Anthropic" --api-key-stdin < key.txt
mutagent providers update <id> --name "New name"
mutagent providers delete <id> --force
```

LLM provider types: `openai`, `anthropic`, `google`, `moonshot`, `glm`, `zai-coding-plan`,
`deepseek`, `xai`, `openrouter`, `azure`, `vertex`, `bedrock`, `custom`. Keys are stored encrypted
and never returned. `mutagent providers add --help` lists the extra flags for Azure, Vertex,
Bedrock and custom endpoints.

### Environments (`env`)

```bash
mutagent env list
mutagent env set demo GREETING=hello --secret GITHUB_TOKEN=ghp_...
mutagent env set staging --from-file .env.staging --secrets-from-file .env.staging.secrets
mutagent env show demo                  # Entry names and fingerprints, never a value
mutagent env unset demo GREETING
mutagent env delete demo --force
```

`set` creates the Environment or merges into it. `--replace --force` overwrites it and removes
every entry you do not name. A variable named like an LLM provider key (`ANTHROPIC_API_KEY`, ...)
is refused unless you pass `--allow-provider-key`. Environment names use letters, digits, `.`, `_`
and `-` (up to 64 characters). Variable names use `A-Z`, `0-9` and `_`, and cannot start with a
digit. An Environment holds up to 64 KiB.

### Run Architech in the cloud (`architech`)

`mutagent architech` is the cloud form of the local `architech`. It always runs the Architech
harness in a new sandbox, so it has no `--preset` and no `--sandbox`.

```bash
mutagent architech -p "plan the refactor"           # Run to completion and print the final answer
mutagent architech --mode json "run the tests"      # Stream events as JSON lines
mutagent architech --mode rpc                       # A steerable session: JSON commands on stdin
mutagent architech --prime -p "plan the refactor"
mutagent architech agent --name reviewer -p "review the diff"
mutagent architech session list
mutagent architech session send <reference> "and now the tests"
mutagent architech session end <reference> --force
mutagent architech models                           # Models a cloud run can use, and the default
mutagent architech models default <provider/model>  # Set the workspace default model

# Sandbox providers and presets
mutagent sandbox providers
mutagent sandbox presets
```

| Run option | What it does |
|---|---|
| `-p "<task>"` | Run the task to completion and print the final answer |
| `--mode json "<task>"` | Stream events as JSON lines |
| `--mode rpc`, `--rpc` | Read JSON commands on stdin, write events on stdout |
| `--prime` | Run the lean Prime agent instead of the full orchestrator |
| `--model <provider/model>` | Model to use (default: the workspace default model) |
| `--env <name>` | Workspace Environment to load |
| `--sandbox-provider <name>` | Run on this sandbox provider |
| `--cwd <path>` | Working directory in the sandbox |
| `--repository <owner/name>` | Run in a checkout of this GitHub repository (needs the workspace's GitHub connection) |
| `--branch <name>` | Branch of `--repository` to check out |

There is no terminal chat UI: choose `-p`, `--mode json` or `--mode rpc`. Each run prints its
session reference (`hs1_...`) on stderr. Ctrl-C stops the session.

`mutagent helix` and `mutagent factory` are removed. They answer `UNKNOWN_COMMAND` with what does
the job now: `mutagent agent run` for an agent.md, `mutagent install helix` for the Helix binary,
the Factory page in the web app for Agent Factory entries. See the CHANGELOG.

Only an interactive session (`--mode rpc`) accepts `session send`. A send to a session whose
sandbox was stopped for idling wakes it from its last checkpoint.

### Managed agents (`agent`)

```bash
mutagent agent check invoice/agent.md                  # Compile and validate; nothing leaves the machine
mutagent agent pack invoice/agent.md --output invoice.tgz
mutagent agent run invoice/agent.md "Price three widget units."   # Local, with the local Helix binary
mutagent agent deploy invoice/agent.md --env prod
mutagent agent list
mutagent agent inspect invoice-pricing --env prod
mutagent agent activate invoice-pricing --revision v2 --env prod   # An older revision is a rollback
mutagent agent retire invoice-pricing --env prod --force
```

The `agent.md` frontmatter fields `name`, `description`, `model`, `thinking`, `tools`,
`disallowed_tools` and `skills` are a local brief. Deployment settings live in one optional
`harness:` block (tools, skills, files, bindings, runtime). `name` is the slug, and `model` is
`provider/model` as `mutagent architech models` lists it.

Each deploy of new content is the next revision (`v1`, `v2`, ...). `--no-activate` stores it
without moving the slot. `@slug:vN` pins a revision and `@slug:latest` runs the newest one.

Compiling needs Bun 1.4.2 on `PATH` (or `MUTAGENT_BUN_BIN`). `agent run` needs a local Helix binary
(`mutagent install helix`).

### GitHub, Slack, triggers and routines (`gateway`)

```bash
mutagent gateway                         # What's connected, what's missing, the next command
mutagent gateway doctor                  # End-to-end check, with fixes
mutagent gateway connect github          # Prints a URL to open (--wait polls until done)
mutagent gateway connect slack
mutagent gateway repos --linked
mutagent gateway repos link acme/api

mutagent gateway triggers create --on <kind> --repo acme/api --instruction "triage the new issue"
mutagent gateway routines create --every "weekdays 09:00" --tz Europe/Berlin --repo acme/api \
  --instruction "summarise yesterday's failures"

mutagent gateway test-run --repo acme/api --wait   # Start a real run to prove the path works
mutagent gateway runs --since 24h
mutagent gateway runs logs <runId> --follow
```

Routines need `--tz`. Destructive verbs (`disconnect`, `repos unlink`, `triggers delete`,
`routines delete`, `runs cancel`) need `--force`. See `mutagent gateway --help` for every verb.

### Reports, findings, triage and inbox

```bash
mutagent reports push <run-dir> --kind evaluator   # Upload a run report Helix published
mutagent reports list
mutagent reports show <id> --html report.html
mutagent reports review <id>

mutagent findings list --status open
mutagent findings set-status <id> resolved

mutagent triage file --subject <id> --title "<one line>" --body @notes.md   # Previews; --yes sends
mutagent triage list
mutagent triage set-status <id> resolved

mutagent inbox list
mutagent inbox read-all
```

### Trace sources (`integrations`)

```bash
mutagent integrations sources list
pass show langfuse/sk | mutagent integrations sources add langfuse --name prod --public-key pk-lf-... --secret-stdin
mutagent integrations sources test <id>
mutagent integrations sources pull <id> --since 2026-10-01T00:00:00Z
```

Connects Langfuse or OpenObserve trace sources and pulls their traces. Credentials are write-only.

### Setup: Helix binary, project, skill and hooks

```bash
mutagent install helix                       # The Helix binary, into ~/.mutagent/bin (no sign-in needed)
mutagent install helix --channel candidate

mutagent init                                # Write .mutagentrc.json and install the CLI skill
mutagent skills install                      # .claude/skills/mutagent-cli/SKILL.md for Claude Code
mutagent hooks install                       # Claude Code session telemetry (.claude/settings.local.json)
mutagent hooks import session.jsonl --dry-run   # Upload Helix session transcripts as traces
```

`mutagent install helix` downloads the Helix binary for macOS or Linux (x64 or arm64) from
`install.mutagent.io`, checks it against the published checksums, and writes
`~/.mutagent/bin/helix`. It never edits your shell rc files: when the directory is not on `PATH`,
it prints the line to add. It also records the install (anonymously when you are not signed in);
that step never fails the install.

### Feedback

```bash
mutagent feedback send "describe what went wrong" --category cli
mutagent feedback send "eval gate was confusing" --category stage:evaluate
```

Categories: `cli` (default), `helix`, `stage:<spec|build|evaluate|diagnose|optimize>`.
`--attach-transcript` uploads your coding-agent session transcript, which contains source code,
paths and the context of your prompts. Use it only when you mean to share all of that.

### Global options

| Option | What it does |
|---|---|
| `--json` | Print structured JSON instead of tables |
| `--api-key <key>` | Use this Mutagent API key instead of the stored one |
| `--endpoint <url>` | Use this Mutagent server instead of the configured one |
| `--workspace <name\|id>` | Run this one command in another workspace |
| `--org <id\|slug>` | Check that the key belongs to this organization; a mismatch exits 1 and sends nothing |
| `--non-interactive` | Never prompt (also when `CI=true` or stdin is not a terminal) |
| `-h, --help` | Help for any command |
| `-v, --version` | CLI version (only before a subcommand) |

With `mutagent architech`, put `--api-key` and `--endpoint` before `architech`
(`mutagent --api-key <key> architech -p "<task>"`). After `architech` they are refused, so a model key
cannot be sent as your Mutagent key.

## Scripts, CI and coding agents

```bash
export MUTAGENT_API_KEY="mg_live_..."   # Sign in without a browser
mutagent login --json
mutagent workspaces list --json
mutagent providers list --json
```

- **Coding agents:** run `mutagent skills install` first. It installs a skill that teaches the agent
  the CLI's workflows. To help a person sign in, run `mutagent login --browser --json`, show them the
  printed URL, and wait (the CLI polls for up to 5 minutes).
- **JSON:** pass `--json` to every command except a `mutagent architech` launch, whose output is the
  harness's own. A response may carry `_directive` (a status card and the next step for an agent), `_links`
  (dashboard and API URLs) and `_compat` (CLI and skill versions).
- **Destructive commands** (delete, retire, signal, cancel, ...) need `-f/--force` in every mode.
  Without it they refuse with `CONFIRMATION_REQUIRED` and send nothing. They never prompt.

### Exit codes

| Code | Meaning |
|---|---|
| `0` | Success |
| `1` | Failure, usage errors included |
| `2` | The API key expired or is invalid |
| `3` | Not signed in, or no workspace selected |

Under `--json`, `success: true` if and only if the exit code is 0. A failure is one object on stdout.
For example, `mutagent env list --nope --json` prints:

```json
{
  "success": false,
  "error": "unknown option '--nope'",
  "code": "UNKNOWN_OPTION",
  "suggestedAction": "Run: mutagent env list --help",
  "_agentGuidance": {
    "helpCommand": "mutagent env list --help",
    "suggestion": "Run: mutagent env list --help",
    "fix": ["mutagent env list --help"],
    "notes": []
  }
}
```

`_agentGuidance.escalate` is present only when a person has to act. In a terminal the same failure
is `Error: ...` on stderr, with the fix. A Helix run exits with the session's own exit code.

## Configuration

### Environment variables

| Variable | Default | What it does |
|---|---|---|
| `MUTAGENT_API_KEY` | none | Mutagent API key; sign in without a browser |
| `MUTAGENT_ENDPOINT` | `https://api.mutagent.io` | Mutagent server |
| `MUTAGENT_WORKSPACE_ID` | the selected workspace | Workspace for every command (`--workspace` wins) |
| `MUTAGENT_NON_INTERACTIVE` | unset | `true` disables every prompt |
| `CI` | unset | `true` also disables every prompt |
| `NO_COLOR` | unset | Any value disables color |
| `MUTAGENT_NO_BANNER` | unset | `1` hides the banner |
| `MUTAGENT_DEBUG` | unset | `1`, `true` or `yes` writes redacted request logs to stderr |
| `MUTAGENT_HELIX_CHANNEL` | `latest` | Channel for `mutagent install helix` (`latest` or `candidate`; `--channel` wins) |
| `MUTAGENT_INSTALL_DIR` | `~/.mutagent/bin` | Where `mutagent install helix` writes the binary |
| `MUTAGENT_INSTALL_HOST` | `https://install.mutagent.io` | Where `mutagent install helix` downloads from |
| `MUTAGENT_HELIX_BIN` | `~/.mutagent/bin/helix`, then `helix` on `PATH` | Helix binary `mutagent agent run` uses |
| `MUTAGENT_BUN_BIN` | `bun` on `PATH` | Bun binary that compiles managed agents |
| `HELIX_CODING_AGENT_DIR` | `~/.mutagent/agent` | Local Helix login store that `mutagent providers mirror` reads |

Workspace precedence: `--workspace`, then `MUTAGENT_WORKSPACE_ID`, then the workspace chosen with
`mutagent workspaces use`.

### Files

- `~/.config/mutagent/credentials.json`: the credentials `mutagent login` stores.
- `.mutagentrc.json`: project config written by `mutagent init` (the endpoint and the selected
  workspace). An existing file is left untouched.

## Links

- [Documentation](https://docs.mutagent.io/cli): installation, every command, JSON output, errors
- [Dashboard](https://app.mutagent.io)
- [mutagent.io](https://mutagent.io)
- Found a problem? `mutagent feedback send "<what happened>" --category cli`

## License

Released under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) (`"license": "Apache-2.0"` in `package.json`; the `LICENSE` file ships in the package).
