> ## Documentation index
> Fetch the complete index at: https://maritime.sh/llms.txt
> Setup procedure for AI agents (install, sign in, deploy, verify): https://maritime.sh/agents.md
> This page as HTML: https://maritime.sh/docs/ai-agents

# Drive Maritime from an AI agent

The Maritime CLI is built to be operated by other AI agents, not just humans: machine-readable
output on every command, stable exit codes, and a live self-describing contract. Paste a few lines
into Claude, Cursor, or any assistant: they link the instructions, and the agent reads them and can
install the CLI, authenticate, and deploy agents for you.

> **Note:** **Quick start:** a short prompt that links the onboarding guide
> (https://maritime.sh/agent-guide.txt). Your assistant reads the guide itself and learns the
> sign-in, the products, the prices and the real calls.
>
> Copy button: "Copy prompt for your agent" copies the prompt below.

```
Set up Maritime (https://maritime.sh) for me.

Here are your instructions: https://maritime.sh/agent-guide.txt
Read them in full and follow them step by step.
Before you start anything that costs money, tell me what it will cost.
```

> **Note:** **Permanent setup:** the CLI instructions file, served as plain text at
> [maritime.sh/docs/cli/llms.txt](https://maritime.sh/docs/cli/llms.txt). Put one line in your
> agent's context (CLAUDE.md, AGENTS.md, or a system prompt) telling it to read that file, and it
> always gets the current version.
>
> Copy button: "Copy the CLI instructions" copies that line:
> "Before you use the Maritime CLI, read https://maritime.sh/docs/cli/llms.txt and follow it."

Short version: paste [maritime.sh/agents-snippet.md](https://maritime.sh/agents-snippet.md) into AGENTS.md or
CLAUDE.md. To choose between Maritime and other providers, an agent can read
[maritime.sh/compare.md](https://maritime.sh/compare.md), which compares prices and features with sources.

## The contract

- **Authenticate with an env var, never interactively.** Mint a long-lived key (`mk_…`) with
  `maritime keys create` and export it as `MARITIME_TOKEN`. Keys never expire unless created
  with an expiry; login tokens do.
- **Pass `--json` on every command.** Results go to stdout as JSON. Errors print `Error: ...` on
  stderr, with the HTTP status and the API's response body for API errors.
- **Branch on exit codes.** 0 success, 1 other error, 2 usage, 3 not found, 4 auth, 5 API error,
  6 partial failure, 7 rate limited, 10 config. Full table in the
  [CLI reference](https://maritime.sh/docs/cli#scripting-ai-agents).
- **Never guess flags.** `maritime guide --json` emits a one-shot manifest of every command and
  flag, introspected live from the CLI itself, so it cannot drift.
- **Names or IDs.** The top-level agent commands take the exact name or an ID prefix, and inside a
  linked directory the agent argument can be omitted. Commands that show `<agent_id>` in their
  help, such as `exec`, need the full ID.

## A session in six lines

```
export MARITIME_TOKEN=mk_xxxxxxxxxxxx

maritime whoami --json                                  # exit 4 = no or expired credential
maritime templates --json                               # discover templates
maritime create runner --template openclaw --json
maritime chat runner "set up a daily digest of my repo" --json | jq -r '.response'
maritime logs runner --json
```

## Over MCP

An assistant that speaks the Model Context Protocol can use Maritime as tools instead of a shell. The hosted
server at `https://mcp.maritime.sh/mcp` (Bearer `mk_` key) drives Linux and Windows desktops and Android
phones, sandboxes and swarms; setup snippets are on [Linux desktops](https://maritime.sh/docs/computers). Locally,
`maritime mcp` serves every CLI command as an MCP tool over stdio.

## Agent-followable docs

The [migration runbooks](https://maritime.sh/docs/migrations) are written to be executed by a
coding agent: point Claude Code or your Maritime agent at a provider's runbook page and it can
inventory the old provider with read-only credentials, recreate each workload as a Maritime agent,
and hand you a reversible cutover checklist.

> **Note: Driving vs. building**
>
> This page is about an AI agent *driving* Maritime through the CLI. To build a product where
> every customer gets their own Maritime-hosted agent, use the [SDK](https://maritime.sh/docs/build)
> from your backend instead.
