---
title: "CLI & AI Agents"
url: "https://adaptocms.com/docs/cli-ai-agents/"
source: adaptocms.com
---

# CLI & AI Agents

The `adapto` CLI manages all Adapto CMS content types from the terminal — articles, pages, categories, custom collections, micro copy, and files. It supports both interactive use and fully non-interactive scripting, making it suitable for shell automation, CI pipelines, and AI agent workflows.

`adapto llm-info` outputs the complete command reference formatted for AI consumption. An agent given that output can issue accurate CLI commands without guessing flag names or argument order.

Source and releases: [github.com/adaptocms/adapto-cms-cli](https://github.com/adaptocms/adapto-cms-cli)

* * *

## Installation

Quick install for macOS and Linux:

```
curl -sSL https://raw.githubusercontent.com/adaptocms/adapto-cms-cli/main/scripts/install.sh | bash
```

Windows binaries and all platform releases are available on the [GitHub Releases page](https://github.com/adaptocms/adapto-cms-cli/releases). The project is written in Go, so it can also be built from source.

* * *

## Authentication

### Interactive login

```
adapto auth login --email user@example.com --password secret
# Interactive project picker appears when you belong to multiple projects
# To switch later:
adapto auth switch-tenant --tenant-id TENANT_ID
```

### Non-interactive (scripts and agents)

When running without a TTY, supply credentials through environment variables. These override the stored credentials file, so no `auth login` step is required.

Variable

Description

`ADAPTO_TOKEN`

Bearer token

`ADAPTO_TENANT_ID`

Project ID

`ADAPTO_API_URL`

API base URL (default: `https://api.adaptocms.com`)

```
ADAPTO_TOKEN=your_token ADAPTO_TENANT_ID=your_project adapto articles list --json
```

* * *

## AI Agent Integration

### Giving an agent the CLI spec

`adapto llm-info` outputs the complete command reference — every command, subcommand, flag, and example — as Markdown, designed for agent tool-use and MCP scenarios. Include this output in the agent's system prompt or project-level instructions before asking it to manage content.

```
adapto llm-info
```

In Claude Code, adding the output to `CLAUDE.md` makes it available across every session in that project:

```
adapto llm-info >> CLAUDE.md
```

### Non-interactive flag requirements

In a non-TTY environment, any required flag that is omitted causes an error rather than an interactive prompt. Every required flag must be provided explicitly in agent-issued commands.

### JSON output

Every command accepts `--json`, which returns machine-readable JSON instead of a formatted table. Use this when the agent needs to parse the response — for example, to capture a newly created item's ID and pass it into a subsequent command.

```
adapto articles create \
  --title "Hello World" \
  --content "<p>Body.</p>" \
  --slug hello-world \
  --author "Editorial Team" \
  --language en-US \
  --status draft \
  --json
# { "id": "abc123", "slug": "hello-world", "status": "draft", ... }
```

### Tagging agent-created content

Articles and pages support a `--source` flag that records the origin of the content. Setting it on agent-created entries distinguishes them from human-authored ones in backoffice audit views.

```
adapto articles create \
  --title "Generated Article" \
  --content "<p>...</p>" \
  --slug generated-article \
  --author "AI Agent" \
  --language en-US \
  --source '{"type":"agent","name":"Claude"}' \
  --json
```

* * *

## Common Workflows

### Articles

```
# Create a draft, then publish
adapto articles create \
  --title "My Article" \
  --content "<p>Content here.</p>" \
  --slug my-article \
  --author "Editorial Team" \
  --language en-US \
  --status draft \
  --json

adapto articles publish ARTICLE_ID

# Update only the content
adapto articles update ARTICLE_ID --content "<p>Updated.</p>"

# Fetch by slug for read operations
adapto articles get-by-slug my-article --json
```

### Custom collection items

Collection items store field values in a `--data-json` object keyed by field name. The field schema is available from the collection record itself.

```
# Inspect the collection's field schema
adapto collections get-by-slug team-members --json

# Create an item
adapto collections items create COLLECTION_ID \
  --title "Jane Doe" \
  --slug jane-doe \
  --language en-US \
  --status published \
  --data-json '{"role":"Engineer","bio":"Loves code"}' \
  --json

# Batch create multiple items at once
adapto collections items create-batch COLLECTION_ID \
  --items-json '[
    {"title":"Item A","slug":"item-a","language":"en-US","data":{"field":"value"}},
    {"title":"Item B","slug":"item-b","language":"en-US","data":{"field":"value"}}
  ]'
```

### Micro copy

```
# Create an entry
adapto microcopy create --key "nav.home" --value "Home" --language en-US

# Create a translation of an existing entry
adapto microcopy create-translation SOURCE_ID \
  --key "nav.home" \
  --value "Accueil" \
  --language fr-FR

# Fetch all entries for a language
adapto microcopy get-by-language en-US --json
```

### File upload

```
# Upload in one step — returns the full file record including CDN URL
adapto files upload ./photo.jpg --json
# { "id": "file123", "url": "https://media.adaptocms.com/...", ... }
```

The returned `url` is already CDN-rewritten and ready to use in content fields or `--media-json` placements.

### Translations

Every content type — articles, pages, categories, collection items, and micro copy — has a `create-translation` subcommand. It links the new entry to the original via `translation_of_id`. See the [SDK Reference](/docs/sdk-reference) for the translation model.

```
adapto articles create-translation ARTICLE_ID \
  --title "Premiers pas" \
  --content "<p>Bienvenue.</p>" \
  --slug premiers-pas \
  --author "Équipe éditoriale" \
  --language fr-FR \
  --json
```

* * *

## Global Flags

Every command accepts these flags. Environment variable equivalents override stored credentials.

Flag

Env var

Description

`--json`

—

Machine-readable JSON output

`--token`

`ADAPTO_TOKEN`

Bearer token

`--tenant-id`

`ADAPTO_TENANT_ID`

Project ID

`--api-url`

`ADAPTO_API_URL`

API base URL

`--verbose`

—

Show HTTP request/response details
