CLI cf для API Cloudflare

Находит и выполняет команды CLI cf от Cloudflare (бета) через cf cli search, cf schema и пробные прогоны, выбирает между cf и Wrangler. Для случаев, когда нужно работать с DNS, зонами, D1, KV или R2 из терминала или начать проект на Workers.

DevOpsПак: Скиллы Cloudflare94 строкиcf-cli
Автор
Источник
cloudflare/skills/skills/cf-cli @ 5108325
Лицензия
Apache-2.0

Об этом скилле

Что делает

Скилл учит агента работать с cf — CLI Cloudflare, который пока в бете: больше 2900 команд, сгенерированных в основном из публичного API, плюс cf dev, cf build и cf deploy для проектов на Workers. Вместо списка команд в нём цикл поиска: описать задачу в cf cli search, проверить форму запроса через cf schema или параметры через --help, прогнать с --dry-run и только потом выполнить.

Ставится через npm install --global cf — пакет добавляет и такую же команду cloudflare на случай, если в PATH уже есть другой cf. cf auth login печатает ссылку и одноразовый код (по SSH и в контейнере — с --no-browser); агентам, которые работают без присмотра, и CI нужен CLOUDFLARE_API_TOKEN.

Разрушительная команда без --force в неинтерактивной сессии печатает Aborted. и всё равно выходит с кодом 0. --force бывает и параметром API: cf workers delete --force удалит даже Worker, на который ссылаются другие. --local работает только для KV, части команд D1 и R2.

Ещё скилл выбирает CLI для проекта: есть cloudflare.config.ts — cf; есть конфигурация Wrangler — Wrangler для dev, build и deploy, а cf только для команд по ресурсам; нет ничего — cf. Команды Wrangler из документации агент переводит, а не запускает; живые логи и одиночные секреты, которых в cf пока нет, идут через npx wrangler. references/skill-feedback.md — порядок отправки GitHub issue об ошибке в скилле с вашего одобрения.

Когда включать и когда не надо

Для DNS, зон, D1, KV, R2 и других операций с API из терминала, для новых проектов на Workers и проектов с cloudflare.config.ts.

В проекте с конфигурацией Wrangler разработку и деплой оставьте Wrangler.

Как поставить и вызвать

Команда установки ниже скачивает папку скилла, а сам CLI ставится отдельно, как описано выше; ему нужен Node.js 22.18 или новее (Bun не подходит). Вызвать вручную:

  • Claude Code: /cf-cli или попросить скилл по имени.
  • Codex: $cf-cli.
  • Cursor: наберите / в чате Agent и выберите cf-cli.

Пример: /cf-cli Создай CNAME-запись для docs.example.com в моей зоне, сначала покажи пробный прогон.

Скилл предлагает строку для пользовательского AGENTS.md или CLAUDE.md, чтобы агенты выбирали cf, когда в проекте нет конфигурации Wrangler.

Чем отличается от похожих

Wrangler CLI для Cloudflare ведёт жизненный цикл Workers в проектах на Wrangler; этот скилл охватывает весь API и новые проекты. CLI hf для Hugging Face Hub держит в SKILL.md сгенерированный список команд hf; при 2900 командах здесь агент их ищет. Ошибки и события в Sentry устроен похоже — пара sentry schema и sentry api, — но только читает.

Установка

Выполните одну команду — она сохранит SKILL.md и файлы, которые он использует, в папку скиллов агента. Claude Code и Codex подхватывают новый скилл без перезапуска; если скилл не появился, перезапустите агента.

Скилл написан на английском — агент поймёт его и ответит вам по-русски.

Claude Code — macOS, Linux
curl -fsSL --create-dirs -o ~/.claude/skills/cf-cli/SKILL.md https://anymodel.org/en/skills/cloudflare/cf-cli/SKILL.md -o ~/.claude/skills/cf-cli/LICENSE https://anymodel.org/en/skills/cloudflare/cf-cli/LICENSE -o ~/.claude/skills/cf-cli/references/skill-feedback.md https://anymodel.org/en/skills/cloudflare/cf-cli/references/skill-feedback.md
Codex, Cursor — macOS, Linux
curl -fsSL --create-dirs -o ~/.agents/skills/cf-cli/SKILL.md https://anymodel.org/en/skills/cloudflare/cf-cli/SKILL.md -o ~/.agents/skills/cf-cli/LICENSE https://anymodel.org/en/skills/cloudflare/cf-cli/LICENSE -o ~/.agents/skills/cf-cli/references/skill-feedback.md https://anymodel.org/en/skills/cloudflare/cf-cli/references/skill-feedback.md
Claude Code — Windows PowerShell
foreach ($f in 'SKILL.md','LICENSE','references/skill-feedback.md') { $p = Join-Path "$HOME\.claude\skills\cf-cli" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/cloudflare/cf-cli/$f" -UseBasicParsing -OutFile $p }
Codex, Cursor — Windows PowerShell
foreach ($f in 'SKILL.md','LICENSE','references/skill-feedback.md') { $p = Join-Path "$HOME\.agents\skills\cf-cli" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/cloudflare/cf-cli/$f" -UseBasicParsing -OutFile $p }

Другой агент: сохраните файл в его папку скиллов или дайте ему ссылку на файл: https://anymodel.org/en/skills/cloudflare/cf-cli/SKILL.md

SKILL.md

Исходник

Cloudflare CLI (cf)

cf is Cloudflare's command-line interface for the public Cloudflare API (2,900+ commands, most generated from API schemas) and for Workers projects. It is in beta: commands, configuration, and Build Output can change before the stable release.

Prefer retrieval over pre-trained knowledge. Describe the task to cf cli search, inspect the match with cf schema or --help, and preview with --dry-run before running a command you have not verified.

Docs index: https://developers.cloudflare.com/cf/llms.txt

Documentation

Topic Page
Install, sign in, credential and account selection https://developers.cloudflare.com/cf/get-started/index.md
First Worker with cf init, cf dev, cf deploy https://developers.cloudflare.com/cf/get-started/first-worker/index.md
Find, create, and delete resources from the terminal https://developers.cloudflare.com/cf/get-started/resources/index.md
cf for Wrangler users https://developers.cloudflare.com/cf/wrangler/index.md
Migrate a Wrangler project with cf migrate https://developers.cloudflare.com/cf/wrangler/migrate/index.md
Wrangler-to-cf command and config reference https://developers.cloudflare.com/cf/wrangler/reference/index.md
Develop, build, and deploy; modes and previews https://developers.cloudflare.com/cf/projects/index.md
Typed cloudflare.config.ts https://developers.cloudflare.com/cf/projects/cloudflare-config/index.md
Using cf with coding agents (safety rules) https://developers.cloudflare.com/cf/agents/index.md
CI, API tokens, unattended authentication https://developers.cloudflare.com/cf/ci/index.md
Environment variables https://developers.cloudflare.com/cf/environment-variables/index.md
Find slow or expensive D1 databases and queries with cf sql query https://developers.cloudflare.com/d1/observability/find-expensive-queries/index.md

FIRST: check installation and sign in

npm install --global cf   # installs two equivalent commands: `cf` and `cloudflare`
cf --version
cf auth whoami
  • Requires Node.js 22.18 or later. Bun is not supported.
  • If another tool named cf is on your PATH, use cloudflare instead — the package installs both commands.
  • cf auth login prints a link and a one-time code, then opens the browser. On a remote machine, over SSH, or in a container, add --no-browser so cf only prints the link; approve it from another device. Add --force to sign in again.
  • cf keeps its own credentials and does not reuse a Wrangler login.
  • Unattended agents and CI cannot complete cf auth login — set CLOUDFLARE_API_TOKEN instead (see https://developers.cloudflare.com/cf/ci/index.md).

To make agents prefer cf, add this to the user-level AGENTS.md, CLAUDE.md, or equivalent:

When interacting with Cloudflare, use the `cf` CLI unless the project has a
Wrangler configuration file.

Find commands

cf cli search "create a DNS record"   # local, no credentials; quote the whole task; up to 5 JSON matches
cf schema d1 create                   # API request shape: method, path, params, body fields
cf <command> --help                   # arguments and options (e.g. cf deploy --help)

cf cli search takes the task as one argument — unquoted words after the first are parsed as unknown commands. cf schema covers generated API commands; for command arguments and options use --help.

Read output

  • Results are JSON on standard output; status messages and errors go to standard error, so piping to jq or redirecting needs no extra flags.
  • Lists print one JSON array page; paging options differ per command — check --help.
  • A failed command exits non-zero and prints the error to standard error.

Run commands safely

  • Preview first. --dry-run prints the request as JSON without sending it, and needs no credentials.
  • Aborted deletes still exit 0. In a non-interactive session, a destructive command without --force prints Aborted. to standard error and exits 0 — a zero exit does not mean the resource was deleted.
  • Review --force before allowing it. On some commands --force is also an API parameter (for example, cf workers delete --force also deletes a Worker that other Workers reference).
  • --local is limited. It works for KV keys, D1 databases (cf d1 raw, cf d1 migrations list|apply), and R2 objects; other commands (including cf d1 query) return an error instead of calling the API.

Choose the CLI for this project

  • cloudflare.config.ts exists: use cf.
  • wrangler.jsonc, wrangler.json, or wrangler.toml exists, and no cloudflare.config.ts: keep Wrangler for dev, build, and deploy. Do not run cf dev, cf build, or cf deploy there — they can generate a new configuration that ignores the Wrangler file, or fail. cf resource commands (DNS, zones, storage) are fine alongside it. Run cf migrate only when the user asks, and follow Migrate a Wrangler project: preview with cf migrate --dry-run, run cf migrate, then resolve the TODO(@cloudflare) comments in the generated cloudflare.config.ts.
  • Neither exists: use cf, as Use cf with coding agents recommends. Do not install Wrangler or create a Wrangler configuration file.

Product documentation often shows only Wrangler commands and wrangler.jsonc configuration. In a cf project, treat those as tasks to translate, not commands to run, and do not add a Wrangler configuration file. Use one CLI per project; the only exceptions are the commands under Commands cf does not support yet. For Wrangler equivalents, use the Wrangler to cf reference or cf cli search. Do not translate Wrangler commands from memory. For the full comparison, refer to cf for Wrangler users.

Commands cf does not support yet

cf does not support every Wrangler command yet. Run these with npx wrangler instead of adding Wrangler to the project. Wrangler does not read cloudflare.config.ts, so pass the Worker name:

  • Live logs: npx wrangler tail <WORKER_NAME>.
  • A single secret: npx wrangler secret put <SECRET_NAME> --name <WORKER_NAME>. Or upload secrets with a new Worker version by passing --secrets-file <PATH> to cf deploy or cf workers versions create.

For the current list, refer to "Commands not yet supported" in the Wrangler to cf reference.

Skill feedback

If the user reports that this skill gave incorrect or outdated guidance, or is missing information, read references/skill-feedback.md.

Подключить через AnyModel API

Скилл работает на той модели, которую использует агент. Подключите Claude Code, Codex или Cursor к AnyModel и запускайте его на Claude, GPT, Gemini и других моделях по одному ключу — оплата за токены, без подписки.

Ещё из пака Скиллы Cloudflare

Лучшие практики Cloudflare Workers

Проверяет код и конфигурацию Cloudflare Workers по правилам для прода: даты совместимости, логи и трейсы, стриминг, waitUntil, биндинги вместо REST, Web Crypto, типы Env. Для случаев, когда Worker пишут, ревьюят или готовят к выкладке.

Wrangler CLI для Cloudflare

Ведёт команды и конфигурацию Wrangler в проектах с wrangler.jsonc или wrangler.toml: сверяется со справкой и документацией, бережёт секреты, окружения и Previews. Для случаев, когда Worker деплоят, настраивают или чинят через Wrangler.

Durable Objects в Cloudflare

Помогает писать и ревьюить Durable Objects в Cloudflare: объект на сущность, хранилище SQLite и миграции, RPC-методы, alarms, WebSocket и тесты на Vitest. Для случаев, когда приложению на Workers нужны общее состояние и координация.

Agents SDK от Cloudflare

Помогает строить приложения на Agents SDK от Cloudflare: агенты с состоянием на Durable Objects, RPC, расписания, очереди, Workflows, чат на AIChatAgent, MCP и почта. Для случаев, когда нужен ИИ-агент или чат на Workers.

Веб-фреймворки на Cloudflare Workers

Настраивает приложения на Astro, SvelteKit, React Router, TanStack Start, Nuxt, Hono и SPA под Cloudflare Workers, выбирая C3, Wrangler или cf по состоянию проекта. Для случаев, когда приложение создают, переносят или деплоят на Workers.

Локальная разработка Workers

Запускает и отлаживает Workers локально через cf dev, wrangler dev или плагин Vite, а в Local Explorer читает и наполняет данные биндингов и смотрит трейсы. Для случаев, когда локальный запрос падает или непонятно, что вернул биндинг.

Аудит скорости сайта

Проводит аудит скорости страницы через Chrome DevTools MCP: трейс, Core Web Vitals по порогам, сеть, снимок доступности и настройки сборки, с исправлениями по приоритету. Для случаев, когда страница тормозит или оценка Lighthouse низкая.