Cf: The Agentic CLI for the Cloudflare API
https://blog.cloudflare.com/cloudflare-cf-cli-launch/📌 Cloudflare 為 Agent 打造全新 CLI:cf 正式登場
TL;DR:Cloudflare 推出 agent 優先設計的 cf CLI,把 Wrangler 的 280 個操作擴展到涵蓋 3,000 多個 API。
一個數字很能說明問題:今年三月,Agent 使用 Wrangler 的比例是四分之一,上週已經衝到 48%,而且 Agent 每天使用的指令種類幾乎是人類的兩倍,用到六個以上指令的機率更是人類的四倍。Cloudflare 觀察到這個趨勢後,沒有選擇在既有的 Wrangler 上疊加功能,而是直接推出一套從頭為 Agent 設計的新 CLI,cf。
🤔 Wrangler 的天花板:280 個操作 vs. 3,000+ 個 API
Wrangler 是由各產品團隊各自手工打造指令組合起來的,各團隊在命令設計上缺乏統一標準,於是出現像 d1 info、hyperdrive get、workflows describe 這種用詞不一致的狀況;有些團隊甚至為單一功能寫了數千行客製化程式碼,結果使用率極低。更根本的問題是,Wrangler 累積多年也只涵蓋約 280 個指令路徑,而 Cloudflare 的 API 總共有超過 3,000 個操作,兩者之間有巨大的落差。
🧩 靠 Forge 直接從 API schema 產生 CLI
Cloudflare 內部的統一 API 產生管線 Forge 是這次擴張的關鍵:既有的每個 API 都已有 OpenAPI schema 用於產生官方文件與 SDK,只要在 schema 上補上一點額外標註,Forge 就能把它直接轉成 CLI 指令。這讓 cf 能一口氣把涵蓋範圍從 Wrangler 的約 280 個功能,擴展到整個 Cloudflare API 的 3,000 多個操作,理論上能讓 Agent 用同一套工具設定 Worker、部署、監控、用 Cloudflare Access 保護、購買網域、再用 WAF 保護前端,一路串起來。
cf 內建了幾個目前僅少數 CLI 具備的 Agent 導向設計。首先是 cf cli search:面對 3,000 條可能的指令路徑,Agent 可以用自然語言描述需求,讓內建的小型搜尋索引根據 API 說明與參數找出對應指令,Agent 第一次執行 --help 時系統就會自動告知這個功能的存在。第二是把 JSON 定為預設輸出介面,人類看到的是美化排版,Agent 拿到的是精簡格式以節省 context;相較之下,Wrangler 只有部分指令支援 --json,很多指令回傳的是為人類設計的 Unicode 表格,Agent 得額外花時間與 token 去解析。第三是新的設定格式 cloudflare.config.ts,以 TypeScript 為基礎,讓 Claude Code、Codex 這類支援 LSP 外掛的 Agent 能直接讀懂設定檔的結構並給出更準確的建議;Cloudflare 內部有些 Wrangler 設定檔透過改用可程式化定義環境(而非逐一複製貼上 env 區塊),從超過 5,000 行壓縮了 40%。這套設定格式也搭配 Vite 成為預設的本地開發伺服器,並附上一套外掛組合。
💡 推翻重來,反而比漸進升級更乾淨
Cloudflare 在文中提出一個值得注意的判斷:多年的文件、部落格與第三方教學已經被吸收進 LLM 的訓練資料裡,這對 Wrangler 是資產,但也是包袱,因為任何重大改動都會與模型「學到」的既有行為衝突。相較之下,直接推出一套 Agent 從未見過的新 CLI,搭配設計好的 context 注入與 AGENTS.md 檔案,反而比讓 Agent 去釐清同一工具新舊版本間的差異更簡單。
⚠️ 仍在 Open Beta 階段
cf 目前以 open beta 形式推出,可透過 npm i -g cf 全域安裝並在任何地方執行;新的 TypeScript 設定格式目前從 Workers 開始支援,尚未涵蓋 Cloudflare 全部產品線。
🎯 實務啟示
如果團隊已經讓 Agent 自動化操作 Cloudflare 資源,cf 的 cli search 與 JSON-first 設計能明顯減少 Agent 摸索指令與解析輸出所花的 token;而 TypeScript 設定格式對於想讓 Agent 安全地編輯基礎設施設定的團隊,也提供了比 TOML、JSONC 更可靠的型別檢查基礎。
🔗 來源
- 標題:Cf: The Agentic CLI for the Cloudflare API
- 作者/機構:macleos(Hacker News 提交)
- 連結:https://blog.cloudflare.com/cloudflare-cf-cli-launch/
#Cloudflare #CLI #AgenticAI #DeveloperTools #API #Wrangler #TypeScript #DevOps #AIAgents #CloudInfrastructure
原始資料 Hacker News · 收集於 2026-09-28
摘要原文
Over the last year, agent use of Wrangler has skyrocketed. In March 2026, agents were responsible for a quarter of Wrangler use, up from single-digit percentages the year prior. Last week, agent usage reached 48%. Agents are more prolific users, using almost twice as many distinct commands per day, and are almost four times as likely to use six or more commands. Agents love CLIs. But Wrangler only provides commands for around 280 operations, and Cloudflare offers thousands. Earlier in the year we teased how we were planning to solve this and today, we’re enabling agents to use every Cloudflare product by introducing a new CLI: cf. cf is a CLI that is built for the next generation of software development: Agents can find the command they need to do anything they want to do with bespoke search and steering. JSON is the default interface, pretty printed for humans and condensed for agents for maximum context savings. cloudflare.config.ts is the new configuration format for the whole of Cloudflare, starting with Workers, and bringing the safety and accuracy of TypeScript to you and your agent’s language server protocol (LSP) Vite becomes default, bringing with it the best local development server, and a plugin suite for developers and framework authors. Install the open beta today globally and run it from anywhere: npm i -g cf Copy prompt Copy prompt Prompt copied! cf gives your agent access to the entire Cloudflare API What if your agent could do everything Cloudflare can do? That’s the question that sparked our interest earlier this year: agents were getting ever more powerful, but what they were able to do with Cloudflare’s CLI was still limited. Wrangler was hand-built with each product team contributing and taking their own approach to their command developer experience. Enforcing patterns across teams was virtually impossible, even across our ~280 command paths. We had inconsistent terminology across d1 info , hyperdrive get , workflows describe as each team came up with their own practices at different times. Some teams built entirely custom experiences across thousands of lines of code that turned out to be used extremely rarely, and teams came up with different approaches to solve the same problems. We wanted to both standardize what we had and make a massive expansion, all at once. Forge — Cloudflare’s new unified API generation pipeline — enabled us to do this, building on the idea of generating our CLI commands directly from the API schema that powers our API documentation and SDK generation. Everything we provide has an OpenAPI schema, and if we annotate this with just a little more information, we can use it as the source for Forge to make a CLI. This enables us to expand cf from the ~280 functions that Wrangler had built up over time, to cover the entirety of the Cloudflare API surface of over 3,000 operations. Now it’s simple to give your agent cf and ask it to go set up a worker, deploy it, monitor and observe it, protect it with Cloudflare Access, buy a domain, and front it with Cloudflare WAF, all from a single tool. Building for an agent that has never used cf cf is built for the trajectory of software engineering, where agentic development is drastically changing how software is built and deployed. This year we’ve been focused on providing tools to support this shift, culminating in cf. cf has been built from the ground up with agents in mind, and includes novel tools for agentic command discovery that we think will become standard in more CLIs in the near future. Wrangler came with the advantage that years of documentation, blogs, and third-party guides have been absorbed into the training process of LLMs. It also came with the same disadvantage: changing how Wrangler works now goes against learned behavior, and significant change would be inevitable given the scale of improvement we want to make. Introducing a new CLI that agents have never seen sounds like a big disruptive change — but actually it’s the cleanest thing we can do. Because of the design decisions we have made, the context injections we can make, and the AGENTS.md files we can append, making a switch in this way is actually less confusing than having an agent contextualize the major differences between two versions of a tool it is familiar with. We’re launching with a couple of these agent-focused features built in, with more to come. Agents need to filter JSON, not look at tables When agents use Wrangler, they append --json to every command they run, and then often filter the output with jq to extract a subset of fields. But only some commands in Wrangler supported --json ; many commands returned unicode tables, designed for humans looking at output in their terminal. Agents can figure these out, but it costs them more time and tokens than a jq filter. In cf we’re taking the opposite stance: agents just need JSON, and if agents are the future primary user of this tool, it should be the default. For the vast majority of commands that will rarely be accessed by humans, this is obviously the right call. You as the human customer of this CLI are, in reality, one step removed from using it. Agents being able to easily filter their results and then return that filtered list in whatever format you request is preferable to supplying tables you will never likely read directly. But what if you’re looking to do something that might require real personal input, like searching for a domain to buy? For commands that your agent can access through chaining named parameters in a long and unwieldy sequence, you can simply fill in a form. Cf deconstructs the requirements of the API into a series of validated inputs, so buying a domain, even one with complex requirements, is simple to follow. Or, if you insist, just ask your agent to do it. Your agent can find the right command itself With 3,000 possible routes through a CLI, how can your agent find the right operation it needs quickly without bloating your context? For this reason we have also added cf cli search . This command allows your agent to ask in natural language what it needs to do, and a small search index will provide a list of appropriate commands, based on their API description and parameters. We automatically tell your agent about this command when it runs --help for the first time. Configuration that type-checks your agent Our new configuration format is based on TypeScript, which is easy for humans and agents to parse, and allows you to write your configuration programmatically. Typed configuration is enormously helpful for agents. We’ve found that even with no prior context of the programmatic configuration format, agents are able to easily identify and edit the configuration on demand, even across elements like env which have dramatically changed from the same named feature in Wrangler. All agents that use LSP plugins, such as Claude Code and Codex, benefit from being able to interpret more about the configuration file format in context, and make much more accurate suggestions as a result. Compare this to TOML, which had no accessible schema, or JSONC, which had a linked schema that agents rarely used. Some Wrangler configuration files inside Cloudflare have been condensed by 40% from over 5,000 lines, with many custom environments per developer, to factory files that build each developer’s configuration more efficiently. This is achieved through programmatically defining each environment from the same universal base, instead of copying env blocks as was typical in Wrangler. A simple Worker with multiple environments simply switches on the Vite-native mode argument to swap between one set of configuration and another. A simple configuration that does this now looks like: import { bindings, defineConfig } from "cf/config" ; import * as entrypoint from "./index. (87 points, 38 comments on Hacker News)
由 claude-code/sonnet 自動生成