跳到正文
DEV Community· Jeff·· 3 小時前AI 評分49

從手動 Cursor API 提示詞遷移至規格驅動工具

Migrating from Manual Cursor API Prompts to Spec-Driven Tools

AI 導讀

將手動貼入對話的 API 備註遷移至規格驅動工具,可避免 Agent 每次重新整理 API 資訊。做法是把 OpenAPI 檔案存放在程式碼庫,據此生成 MCP 伺服器和模擬工具,並先讓 Agent 與備註並行使用。當呼叫記錄顯示工具選擇、型別化參數及回應均符合合約,便可停用手動備註。

正文

Jeff

Short answer: Stop paying an agent to re-derive the API from pasted notes. Put the OpenAPI file in the repo, generate the tools and mock from it, and let the agent read the current contract every session. The migration is incremental: establish the contract, wire the tools, then retire the prompt notes as the agent proves it works.

What the manual pattern costs

Pasting curl commands and endpoint notes into the chat is a per-session tax. The agent re-reads, re-derives, and re-types the same facts, and any stale note becomes a confident error. The knowledge lives in the conversation, not in a maintained artifact.

The migration in stages

  1. Establish the contract: convert the existing requests and notes into an OpenAPI file kept in the repo.
  2. Generate the surface: compile the spec into an MCP server and a mock.
  3. Run in parallel: let the agent use the tools while keeping the notes as a fallback.
  4. Retire the notes: once the call log shows correct calls, stop pasting them.

How to judge success

The clearest signal is the call log: the agent selects the right tools, supplies typed arguments, and the responses verify against the contract. When that is consistent, the manual notes are redundant.

The discipline that keeps it working

The contract is the source of truth. When the API changes, change the spec first; the tools and mock regenerate, and the agent is never reading a stale description.

This is part of the Powerduck vs Cursor comparison. Finish with why they are better together.

來源:DEV Community · dev.to