Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计提醒

datocms-clidatocms CLI 搜索

Agent Skill

datocms-cli 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,877

周安装

79

GitHub Stars

公开资料未说明

下载量

657
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:datocms-cli(datocms CLI 搜索)
来源仓库:https://github.com/datocms/agent-skills
仓库路径:skills/datocms-cli
安装命令:
npx skills add https://github.com/datocms/agent-skills --skill datocms-cli
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/datocms/agent-skills --skill datocms-cli

简介

用于操作 DatoCMS CLI 工具链,管理项目链接与本地开发环境。

  • 自动检测已有配置并引导完成登录与项目关联流程。
  • 支持迁移脚本执行、类型生成和环境变量设置。
  • 确保所有操作基于已认证的 CLI 会话进行,保障安全性。
  • 首次使用需依次完成 datocms login 和 datocms link 两步设置。

SKILL.md

DatoCMS CLI Skill

You are an expert at using the DatoCMS CLI (datocms). Follow these steps in order. Do not skip steps.


Step 1: Detect Context

If the project context is already established in this conversation (CLI package, config file, token, migrations directory, TypeScript setup), skip broad detection below. Re-inspect only when a question cannot be answered from prior context.

CLI + link is a required bootstrap for any repo that interfaces with a DatoCMS project. The datocms npm package installed + datocms login + datocms link is how the agent gets visibility into the live project (models, fields, ids, record state). Missing → fix first, same as git init or npm install.

Detection (do not rely on which datocms — the CLI runs via npx)

  1. datocms in package.json devDependencies → CLI available. If missing, install it (npm install --save-dev datocms) — never fall back to pasted tokens or manual Dashboard steps.
  2. datocms.config.json with a siteId on the active profile → linked. If missing, drive the bootstrap below.
  3. npx datocms whoami succeeds → OAuth session active.
  4. migrations/ directory → migrations already scaffolded.
  5. tsconfig.json or migrations.tsconfig → TypeScript migrations convention.

Bootstrap flow (CLI available but not linked)

Only datocms login needs a terminal; the rest runs in non-TTY.

npx datocms login                                   # user, one-time, interactive
npx datocms projects:list [hint] --json             # agent discovers siteId
npx datocms link --site-id=<ID> [--organization-id=<ID>]   # agent links

Always confirm the target project with the user before running datocms link, even when projects:list returns a single candidate. Show the candidate(s) (name, id, organization) and wait for an explicit yes. Do not treat "only one result" as consent — the user may have access to a project they did not mean to wire to this repo, and fixing a mis-linked project later is painful.

datocms link without --site-id requires a terminal. In non-TTY it now exits cleanly with a suggestion to pass --site-id; do not retry without it. Same applies when credentials are missing — ask the user to run datocms login first.

Once the project is linked, use npx datocms schema:inspect (optionally with a model API key, id, or display name) to learn what the project actually contains — models, blocks, fields, validators, fieldsets, nested blocks, relationships. This is the right tool any time the agent or the user needs generic info about the project structure; reach for it before writing mutations, migrations, or CMA code so decisions rest on the real schema rather than guesses. See references/schema-inspect.md.

Authentication policy

  • Interactive task (publish, delete, fix, backfill, introspect, etc.): OAuth via login + link is the mechanism. Never ask the user to paste a token or add DATOCMS_CMA_TOKEN=... to .env for this case.
  • Unattended execution (CI, cron, server-side app, shared scripts without an OAuth session): CMA-enabled token via env var. Read-only CDA tokens (DATOCMS_READONLY_API_TOKEN, NEXT_PUBLIC_DATOCMS_API_TOKEN) will not work — flag that a separate CMA-enabled token is needed. The agent itself still needs CLI + link at development time for visibility.

Token resolution order the CLI uses:

  • --api-token flag
  • Linked project (OAuth-backed, the default after login + link)
  • Env var: DATOCMS_API_TOKEN (default profile), DATOCMS_<PROFILE>_PROFILE_API_TOKEN (named), or custom apiTokenEnvName
  • Profile override via DATOCMS_PROFILE

Step 2: Understand the Task

Classify the user's task into one or more categories:

CategoryExamples
CLI setupInstall CLI, authenticate (login/logout/whoami), discover accessible projects (projects:list), link/unlink projects (link/unlink), configure profiles, datocms.config.json
Schema changesAdd, modify, or remove models, fields, fieldsets, or block models — via a migration script (default) or a direct CMA operation against a chosen environment
Creating migrationsScaffold new migration scripts, autogenerate from environment diffs, custom templates (sub-task of schema changes once the migration approach is chosen)
Running migrationsExecute pending migrations, dry-run, fork-and-run, in-place execution
Schema generationRun schema:generate, scope output to item types, target a specific environment
Schema inspectionRun schema:inspect to dump models, blocks, fields, validators, appearance, default values, fieldsets, nested blocks, referenced models, or embedding models — use any time the agent or user needs to understand how the project is structured before writing code or mutations
Direct CMA callsUse cma:docs to browse API reference, cma:call for a single call with a shape from the docs, cma:script for one-off TypeScript logic that needs loops, branching, or typed Schema.* types — stdin-mode for heredocs/pipes, file-mode for longer scripts in a gitignored scratch dir
Environment managementFork, promote, rename, destroy, list environments via CLI commands
Deployment workflowMaintenance mode, safe deployment sequences, CI/CD integration
Multi-project syncShared migrations across blueprint/client projects via CLI profiles
Importing contentWordPress import, Contentful import
CLI plugin managementInstall, remove, update, list, inspect, link, or reset CLI plugins (plugins:* commands)

Step 2.5: Collect Critical Inputs Before You Commit To Commands

Do not skip questions merely because the category is obvious. Skip follow-up questions only if the request already includes the critical inputs for the relevant category, or the repo inspection answers them safely.

Ask the minimum targeted question set needed to avoid flattening a real workflow decision.

Category-specific inputs live in the reference files

Each category reference loaded in Step 3 opens with an "Inputs to confirm before running commands" section — that is the per-category equivalent of this step. Do not skip loading the reference for the task's category: it carries the workflow decisions this step is designed to protect. If you skip it, you skip the checklist.

Schema changes — decide the approach with the user

DatoCMS schema operations fall into four buckets. The choice of approach is not automatic — ask the user when the bucket is not obvious from the request, because reversibility and workflow preference matter more than which tool performs the mutation.

SituationWhat it coversApproach
Destructive schema changeDROP a field, DROP a model, bulk_destroy records, lossy field_type changes (e.g. string → json, json → string, anything that discards stored values)Migration via datocms-cli (migrations:new), against a forked sandbox first. Never run these against a primary environment without explicit, repeated user confirmation.
Reversible schema changeAdd a field, add a model or block, rename a field, toggle required, add or tighten a validation, reorder fieldsetsAsk the user. Both approaches are safe; pick by preference and context. Lean to a migration (datocms-cli) when the repo already uses a migrations workflow or the user is on a secondary branch — reviewable, reproducible. Direct mutation (cma:call, cma:script stdin-mode, or cma:script file-mode) is fine for quick iteration on a sandbox. Default to migration only when the user has no preference AND the repo shows migration conventions (migrations/ directory, prior migration commits).
User-requested one-offPhrases like "quickly, without a migrations workflow", "just patch this", "one-off", "don't scaffold migrations for this"Honor the opt-out. Use direct mutation via cma:call (single call with shape from cma:docs) or cma:script (stdin-mode for loops/multi-step, file-mode when the script is long enough that a heredoc hurts). Do not re-suggest migrations unless the change turns out to be a destructive schema change.
Content operationPublish, unpublish, delete individual records, fix slugs, bulk update a field value, re-tag uploadsNo migration needed. Prefer cma:call for a single call; cma:script stdin-mode for loops, pagination, or multi-step logic; cma:script file-mode only when a heredoc becomes painful. Code that needs to be committed and replayed across environments is a migration (datocms-cli), not datocms-cma.

Regardless of which skill is loaded, the question to ask the user is the same for a reversible schema change: *"Do you want this as a reviewable migration, or a direct mutation against a sandbox?"* The answer determines which skill owns the follow-up — not which skill was loaded first.

Cross-skill routing.

  • Destructive schema changes and the migration branch of a reversible schema change are this skill's core: migrations:new, migrations:run, fork-and-run, safe deployment. Stay here and load creating-migrations.md + running-migrations.md.
  • User-requested one-offs, content operations, and the direct-mutation branch of a reversible schema change are better covered by datocms-cma. Switch when the user has opted out of migrations, when the task is a content mutation (publish, delete, fix), or when the user wants a cma:script or a checked-in buildClient() script. The handoff is loading the sibling skill's references — do not bounce the user.
  • Unattended runtime code (CI, app server, webhook, long-lived automation) is a separate scenario — that is where a checked-in buildClient() script belongs, and datocms-cma owns that pattern.

Destructive and production-sensitive confirmations

Destructive schema changes always require these confirmations; the list below also covers non-schema destructive commands.

If context is missing, ask for explicit confirmation before proposing final commands for:

  • environments:destroy
  • environments:promote
  • imports into a non-obviously disposable target
  • migrations:run --in-place on a primary-like environment
  • maintenance:on --force
  • environments:fork --fast --force
  • cma:call with destroy, bulk_destroy, or promote methods
  • direct schema mutations (via cma:call or cma:script) targeting a primary-like environment instead of a migration on a forked sandbox
  • plugins:reset (removes all user-installed and linked CLI plugins)

Step 3: Load References

Based on the task classification, read the appropriate reference files from the references/ directory next to this skill file. Only load what is relevant.

Always load:

  • references/cli-setup.md — Installation, configuration, profiles, global flags, token resolution

Load per category:

Task categoryReference file
Creating migrationsreferences/creating-migrations.md
Running migrationsreferences/running-migrations.md
Schema generationreferences/schema-generate.md
Schema inspectionreferences/schema-inspect.md
Direct CMA callsreferences/direct-cma-calls.md (for cma:call) and/or references/cma-script.md (for cma:script)
Environment managementreferences/environment-commands.md
Deployment workflowreferences/deployment-workflow.md
Multi-project syncreferences/blueprint-sync.md
Importing contentreferences/importing-content.md
CLI plugin managementreferences/cli-plugin-management.md

Load cross-cutting references when needed:

  • If creating + running migrations together -> load both creating-migrations.md and running-migrations.md
  • If schema generation is followed by typed CMA code changes -> also load datocms-cma guidance for consuming the generated types
  • If a direct CMA call grows beyond a one-off command -> switch to datocms-cma for reusable code
  • If deployment involves environment commands -> also load environment-commands.md
  • If multi-project sync involves rollout execution -> also load running-migrations.md
  • If a CLI plugin install is specifically for WordPress/Contentful import -> also load importing-content.md

Step 4: Generate Code

Write commands and scripts following these mandatory rules:

Command Prefix

  • Respect the repo's existing package-manager execution style when one is already established (npm run..., pnpm exec..., bunx...)
  • Otherwise default to npx datocms so the local CLI version is used
  • Example: npx datocms migrations:new "add blog model" --ts

Migration File Templates

  • When generating migration file content, use the exact function signatures from the reference files
  • TypeScript: export default async function(client: Client): Promise<void>
  • JavaScript: module.exports = async (client) => {}
  • Import for TypeScript migrations: import {Client} from 'datocms/lib/cma-client-node'

File Naming

  • Migration files are automatically named: {unix_timestamp}_{camelCaseName}.ts|.js
  • Do not manually create migration files — always use npx datocms migrations:new

Migration Script Bodies

  • For the CMA API calls inside migration scripts (creating models, fields, records, uploads), defer to the datocms-cma reference patterns
  • The client parameter in migrations is the same CMA client from @datocms/cma-client-node

Schema Generation

  • Use npx datocms schema:generate <filename> to generate TypeScript schema definitions
  • Use --item-types to narrow the output when the user only needs specific models
  • Use --environment when the generated types must reflect a sandbox or staging environment
  • Route the follow-up code changes that consume those types to datocms-cma

Schema Inspection

  • Use npx datocms schema:inspect any time the agent or user needs project structure information — models, blocks, field definitions, validators, appearance, default values, fieldset grouping, nested blocks, referenced or embedding models
  • No argument dumps every model and block; pass an API key, id, or display name to narrow down (fuzzy fallback when there is no exact match)
  • Defaults to TOON output for agent consumption; add --json when piping through jq
  • Opt into extra detail selectively with --include-validators, --include-appearance, --include-default-values, --include-fieldsets, --include-nested-blocks, --include-referenced-models, --include-embedding-models; use --fields-details=complete to include everything at once
  • Restrict to regular models or modular blocks with --type=models_only / --type=blocks_only; target sandbox schemas with --environment
  • Prefer schema:inspect over composing cma:call item_types list + fields list by hand — it already resolves fieldsets, nested blocks, and embedding models in one call

Direct CMA Calls

  • Use npx datocms cma:docs <resource> <action> to look up endpoint details (request body, parameters, examples) before constructing a command
  • Use npx datocms cma:call <resource> <method> [...pathArgs] for single-method ad-hoc CMA operations
  • Pass request bodies with --data '{...}' and query parameters with --params '{...}'
  • Add --environment when the call must target a sandbox environment
  • cma:call is positional (<RESOURCE> <METHOD> + URL placeholders as extra positional args). It is not a REST wrapper: there is no --endpoint, --method, --query-params, or --body flag — do not invent these

Concrete shape, with JSON5 accepted in --data / --params:

npx datocms cma:call items list --params='{filter: {type: "article"}}'
npx datocms cma:call items find <ITEM_ID>
npx datocms cma:call items update <ITEM_ID> --data='{title: "Updated"}'
npx datocms cma:call items publish <ITEM_ID>
npx datocms cma:call fields create <ITEM_TYPE_ID> --data='{label: "Title", api_key: "title", field_type: "string"}'

Run npx datocms cma:call --help for the full list of built-in examples, or npx datocms cma:docs <resource> <action> for body schema and required fields.

  • Use npx datocms cma:script when the task needs loops, branching, multiple dependent calls, or typed Schema.* records, but the code does not need to live in the repo
  • stdin-mode (heredoc / pipe / redirect): top-level await only, ambient client and Schema, tsc --noEmit type-checks before execution, pre-installed packages available. Zero setup
  • file-mode (.ts file on disk):

- Signature: export default async function (client: Client) with Client imported from datocms/lib/cma-client-node — same import as migrations, so a file-mode script can be promoted with a plain mv into migrations/. - Validation: no CLI-side typecheck; rely on your editor LSP against your tsconfig.json, or an explicit tsc --noEmit. Typed Schema.* is opt-in via datocms schema:generate./datocms-schema.ts. - Placement: gitignored scratch dir (tmp/scripts/, scratch/). Prefer a migration for anything you want to commit, version, and replay across environments.

  • Redirect 2>/dev/null when piping stdin-mode stdout into jq
  • Switch to datocms-cma when the task needs reusable code checked into the repo for unattended runtime (CI, app server, webhook, long-lived automation)
  • Schema changes: default to scaffolding a migration. Only propose cma:call or cma:script for schema mutations after the user has explicitly opted out of the migration workflow, and never propose a direct schema mutation against a primary-like environment without an explicit confirmation from the user

CLI Plugin Commands

  • Use npx datocms plugins:available to discover official CLI plugins before installing
  • Use npx datocms plugins:add <PLUGIN> to install a CLI plugin by npm package name or GitHub URL
  • Use npx datocms plugins:link <PATH> only for local plugin development
  • These commands manage CLI extensions, not DatoCMS project plugins — route project plugin work to datocms-plugin-builder

Environment Safety

  • Always specify --source when running migrations to be explicit about the target
  • Use --dry-run first to preview changes before applying
  • Prefer fork-and-run (default) over --in-place for production environments
  • Treat --force as an explicit override, not a default

Step 5: Verify

Before presenting the final commands or scripts:

  1. API token — Confirm a CMA-enabled token is available (via env var or --api-token flag)
  2. Config file — If using profiles, verify datocms.config.json exists and has the right profile
  3. Migrations directory — Confirm the migrations directory exists or will be created by the command
  4. TypeScript config — If generating TS migrations, ensure tsconfig.json exists or --migrations-tsconfig is set
  5. Schema generation scope — If using schema:generate, verify the output file path plus any --item-types / --environment scope match the request
  6. Direct CMA calls — If using cma:call, verify positional args, --data, --params, and --environment align with the targeted method. If using cma:script, verify the script uses Schema.* types (not any/unknown), imports only from the pre-installed package list, and targets the intended environment
  7. Environment targeting — Verify the correct --source / --destination environment is specified
  8. Safety checks — For destructive operations (promote, destroy, destructive cma:call usage, risky imports, maintenance-mode force), confirm the user intends to target the right environment. For schema mutations, confirm the chosen approach (migration vs direct) and — if direct — the target environment (sandbox vs primary) before issuing commands
  9. CLI plugin commands — If using plugins:* commands, verify the plugin name is correct and distinguish CLI plugins from DatoCMS project plugins

Cross-Skill Routing

This skill covers CLI commands, flags, configuration, workflows, and migration file scaffolding. If the task involves any of the following, activate the companion skill:

ConditionRoute to
CMA API calls inside migration script bodies (records, schema, uploads)datocms-cma
Programmatic environment management via client.environments.* in codedatocms-cma
Consuming generated schema types inside application code or reusable scriptsdatocms-cma
Querying content with GraphQL for frontend displaydatocms-cda
Setting up framework integration, draft mode, or real-time updatesdatocms-frontend-integrations
Building a DatoCMS plugindatocms-plugin-builder

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.61%
按下载量换算241

Claude

28.86%
按下载量换算190

Cursor

17.93%
按下载量换算118

Gemini CLI

9.3%
按下载量换算61

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills