CLI for AI coding agents
A handful of CLI commands exist primarily to make life easier for AI coding agents (Claude Code, Codex, Cursor, and similar tools) when they operate on a DatoCMS project from your editor. They are perfectly usable from a human terminal, but a human developer typically has better alternatives (the dashboard, the typed CMA client in their editor, the online API docs). When an agent is at the keyboard instead, these commands turn the CLI into a powerful surface for autonomous interaction with DatoCMS.
The most leveraged way to use these commands is to install the DatoCMS Agent Skills. The Skills package the CLI together with the domain knowledge an agent needs to use it well — when to inspect the schema before generating types, how to scaffold a migration, when to fork an environment instead of working in primary, how to compose CMA calls without drifting from your project's conventions. The CLI is the engine; the Skills are the operator's manual.
The agent-first commands
schema:inspect
Dump the structure of a DatoCMS project (models, blocks, fields, validators, appearance, fieldsets, nested blocks, relationships) as JSON or in a token-efficient format optimised for LLM consumption. This is typically the first command an agent runs against an unfamiliar project.
npx datocms schema:inspectA human typically inspects the schema visually in the dashboard. For a typed snapshot to use in your code, schema:generate is the right command: it emits a TypeScript file rather than a dump.
cma:docs
Browse the Content Management API reference from the terminal. Output is formatted for LLM consumption.
npx datocms cma:docsnpx datocms cma:docs item createIf you are a human, the online CMA reference is more ergonomic.
projects:list
List every DatoCMS project the authenticated account has access to. Supports fuzzy search by name or subdomain, and accepts --workspace, --limit, and --json flags. Agents invoke it during bootstrap to discover the siteId they need to pass to link.
npx datocms projects:listA human typically picks a project from the dashboard.
cma:call
Make a single Content Management API call from the terminal, without setting up a Node project.
npx datocms cma:call items create --data='{ "item_type": { "type": "item_type", "id": "..." }, "title": "Hello" }'If you are a human, importing @datocms/cma-client-node in a TypeScript file in your editor gives you auto-completion and is usually nicer.
cma:script
Run a one-off TypeScript script against the Content Management API, with a pre-configured client and the project schema as ambient types. Accepts either a file (export default async function(client: Client)) or stdin with top-level await.
npx datocms cma:script ./script.tsecho "console.log(await client.items.list({ filter: { type: 'article' } }))" | npx datocms cma:scriptIf you are a human and your script is more than a handful of lines, write it as a regular TypeScript file in your project and run it with your usual tooling.
environments:primary
Print the name of the project's primary environment.
npx datocms environments:primaryMostly useful inside shell scripts and CI pipelines that need to know which environment to target programmatically. A human developer normally knows this already.
Why these commands exist
A coding agent operating in your editor needs to discover, inspect, and operate on a DatoCMS project without going through a browser. Each of the commands above corresponds to one of those steps:
schema:inspect,cma:docs, andprojects:listfor discovery: figure out what the project contains, what the API can do, and which projects the account has access to.cma:callandcma:scriptfor operation: make changes through the CMA without scaffolding a Node project around them.environments:primaryfor orientation: answer "which environment should I work on?" programmatically.
Combined with the rest of the CLI (auth, link, environments, migrations, schema generation), an agent has everything it needs to interact agentically with your DatoCMS project. The Agent Skills package the conventions and best practices that turn this surface into a productive workflow.
For the full list of flags accepted by each command above, see the datocms package README on GitHub or run datocms <command> --help.