> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anonalabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# The CLI for AI agents

> How an agent learns the anona CLI: anona guide, the anona-cli skill, and when to use MCP or the CLI.

An agent with a shell can use Anona through the CLI without being taught every
flag in advance. Three things make that work: a reference the CLI prints about
itself, a skill that teaches the habits, and output built for a program to read.

## MCP first, the CLI as the fallback

| The agent has | Use |
| - | - |
| Anona's MCP tools (`record`, `retrieve`, `reason`, `list_spaces`) in its own tool list | The MCP tools. Nothing to set up, no shell needed. See [MCP](https://docs.anonalabs.com/mcp-integration.md). |
| A shell, and no MCP tools | The CLI, always with `--json`. |
| A shell, and work MCP has no tool for: uploading files, ingesting a JSON Lines export, changing a space's settings, cancelling a job | The CLI, even alongside MCP. |
| No shell (Claude Desktop chat, claude.ai) | A [custom connector](https://docs.anonalabs.com/integrations/skills.md#claude-desktop-and-claudeai) to `https://memory.anonalabs.com/mcp`. |

## Where to start: `anona`

pip 0.25.0; npm 0.19.0

An agent that has just found the command can run `anona` with no arguments. It
prints a short orientation and exits `0`: how to get a credential, the three
memory commands, and that `anona guide` is the reference to read before
anything unfamiliar. It touches no credential and sends nothing, so it is safe
to run first. (`anona --quiet` with no command still exits `2`.)

## anona guide

pip 0.25.0; npm 0.19.0

```bash theme={null}
anona guide          # the whole CLI, compact, for a model to read
anona guide --json   # the same, as a command tree
anona help --llm     # the same as `anona guide`
```

`anona guide` prints a compact reference generated from the CLI's own parser:
what the CLI is for, the credential order, the global options, every command
with every flag and its help, an example and the shape of its `--json` output,
the exit codes, and the common errors with their fixes. Because it is generated
from the parser, it describes **the copy that is installed**, and cannot list a
flag that copy lacks.

`anona guide --json` is the same as one document:

```json theme={null}
{"purpose": "...", "credentials": ["..."], "credential_notes": ["..."], "global_options": [], "commands": [], "exit_codes": [], "common_errors": []}
```

Each entry in `commands` has `name`, `path`, `help`, `positionals`, `options`
(each with `flags`, `help`, `takes_value`, `metavar`, `choices`, `required`)
and `subcommands`; a runnable command also has `example` and `json_output`. A
group such as `spaces` lists its verbs under `subcommands`, named in full
(`"spaces list"`, path `["spaces", "list"]`). `exit_codes` entries are
`{"code", "name", "meaning"}` and `common_errors` entries are
`{"error", "fix"}`.

**Tell an agent to read it before composing an unfamiliar command**, rather
than guessing a flag. A guessed flag exits `2` with nothing sent, which is
cheap, but a guessed *meaning* (a filter that silently matches nothing) is not.
`anona <command> --help` answers for one command.

```bash theme={null}
anona guide --json | jq '.. | objects | select(.name? == "documents upload") | .options[].flags'
```

## The anona-cli skill

The [Agent Skills](https://docs.anonalabs.com/integrations/skills.md) installer ships an `anona-cli` skill
that teaches an agent the CLI's habits: check `anona guide --json` before an
unfamiliar command, which credential applies and how to set one up, how to read
each exit code (`3` is not a failure to retry, `7` after a write means check
before re-sending, `8` means poll), that a destructive command needs `--yes`
and the user's say-so, and how to scope a write to one end user. The
`anona-memory` skill uses the CLI as its fallback when MCP tools are absent.

```bash theme={null}
curl -fsSL https://raw.githubusercontent.com/anonalabs/Anona-Memory-SDK/main/skills/install.sh | bash -s -- --skill anona-cli
```

## Rules an agent should follow

* **Always `--json`**, and branch on the exit code, never on the text.
* **Name the space**: `--space` or `ANONA_SPACE_ID`, except on a temporary
  profile, whose only space is `default`.
* **`3` from `record` is not a failure**: the server accepted the write and
  extracted nothing. Re-record once, with a sentence of context.
* **Never re-run a write after `7` without checking**: it may have been stored.
* **`8` means still running**: poll with `anona jobs get JOB_ID`.
* **Never add `--yes` on your own**: `spaces delete`, `memories delete`,
  `documents delete`, `jobs cancel` and the settings `reset` commands refuse
  without it, and the user should confirm first.
* **Signing in is the person's step**: `anona login` needs someone at a browser.
  An agent may run `anona start` for a temporary profile and say so.

## Give an MCP client memory with the CLI

`anona mcp` is a stdio MCP server that uses the MCP login from `anona login`, so
a client needs no URL, no header and no API key:

```bash theme={null}
anona login --mcp
claude mcp add anona -- anona mcp
```

The tools are available the next time the client starts. For a client that
runs its own OAuth, skip the CLI and point it at the remote server directly:

```bash theme={null}
claude mcp add --transport http anona-oauth https://memory.anonalabs.com/mcp
```

**`anona mcp` handles one message at a time.** It reads a request, waits for
the answer, then reads the next. A slow `reason` can take up to 120 seconds,
and for that long every other request from the same client waits behind it. If
your agent issues parallel memory calls, expect them to queue.

## Related

* [Self-onboarding](https://docs.anonalabs.com/agents/self-onboarding.md): the four ways an agent can connect.
* [Onboarding prompt](https://docs.anonalabs.com/agents/onboarding-prompt.md): a prompt that walks an agent through setup.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.