awesome cli.

Content & media

DatoCMS CLI for coding agents

Schema migrations, environment diffs, dry-runs, sandbox forks, promotion, maintenance mode, and API-token auth for CI.

Command: datocms

Open the official project ↗

This article follows the official documentation. We haven’t tested this tool for a hands-on review.

When you give a coding agent shell access to a DatoCMS project, it can use the datocms command-line interface (CLI) to inspect the project and call the Content Management API (CMA), which manages DatoCMS content and structure. The agent can learn the project’s schema, find API guidance, or run a one-off operation without opening the DatoCMS dashboard.

Among the CLI commands for coding agents are schema:inspect and cma:docs; the set also includes cma:call and cma:script. For a first task, ask the agent to inspect the schema and report what it finds without changing anything. Review any proposed schema or content changes separately before applying them. The agent command documentation describes each command and its output.

Install and connect the CLI

Install the CLI in the project, then sign in and link the local repository to a DatoCMS project:

npm install --save-dev @datocms/cli
npx datocms login
npx datocms link

The installation adds the CLI as a development dependency. OAuth sign-in opens a page where you authorize the account; link connects the repository to a project and creates datocms.config.json. The CLI’s setup instructions cover installation and project linking. The generated config can be committed so collaborators and CI jobs can use the same project link.

OAuth is the recommended authentication method. It associates API activity with the person who signed in. For automation, the CLI also accepts an API token through the --api-token option or the DATOCMS_API_TOKEN environment variable. The CLI checks the explicit option first; next it checks the environment variable, then the linked project’s OAuth credentials. Store CI tokens in the CI provider’s secret store; do not paste them into an agent prompt.

Inspect a project without changing it

After linking the repository, run the schema inspection command:

npx datocms schema:inspect

The command reads the linked DatoCMS project and returns its schema, including models, blocks, fields, and validators. Models define content types, while validators describe rules such as required fields or accepted values. The command can provide JSON or a more compact format intended for language models. Check the command’s documentation for the available output options before adding a flag.

Ask the agent which model and fields represent a content type, then have it summarize the rules that apply to those fields. For example:

Inspect the linked DatoCMS schema and identify the model used for blog posts. Summarize its fields and validators. Do not change the project or local files.

The command sends a read request to the linked project. The agent does not need to create a migration, a file that applies project changes, or write content. It can use the result to plan a code change, but should treat the returned schema as project data and avoid inventing field names or rules that the response does not include.

To find projects available to the signed-in account, use projects:list, which can search by name or subdomain. It also accepts --workspace, --limit, and --json. The cma:docs command retrieves Content Management API reference material in a format suited to agents. These commands help the agent find a project or API operation before acting.

Separate inspection from changes

The CLI also supports operations that change DatoCMS. cma:call makes one API request, and cma:script runs a one-off TypeScript script against the API. A read request retrieves data. A write request changes project data. cma:script blocks certain TypeScript escape hatches, including explicit any or unknown annotations, casts to never, and TypeScript suppression directives. Its file-mode structure matches the CLI’s migration-file structure, so a script can be moved into the migrations directory for replay as a migration.

For schema work, the CLI supports migrations and comparisons between environments. It also supports dry runs and sandbox forks, and lets you promote changes to an environment. A dry run previews or checks a supported operation without applying the change. Check the command documentation for its exact syntax and limits. Review the proposed change and confirm the target environment before promoting it.

After the agent inspects the project, ask it to propose a migration or API request for review before making a change. The read-only command above does not apply changes. An API call sends a network request. A command that modifies a project changes its data or schema on DatoCMS. You change the repository when you edit a migration file. When you run the migration, it changes the remote project.

Choose the CLI for a local agent

Use DatoCMS’s agent-first commands when a coding agent works in a local repository and needs to inspect or manage a linked project from the shell. The environments:primary command reports the project’s primary environment, which is useful in scripts and CI. whoami checks the current CLI identity.

OAuth and project linking give the local CLI access through the signed-in account. The agent can run commands allowed by the host’s shell permissions and make network requests. Keep credentials out of prompts, and authorize only the account access the task needs. For a browser-based assistant without a local terminal, DatoCMS points to its MCP server instead.

Tool details come from awesome-ai-cli.