Cursor Cookbook: Build Custom Coding Agents with the SDK
The Cursor SDK lets you run Cursor's coding agent from your own scripts and workflows. The new Cookbook repo provides practical examples from quickstart to DAG-based task orchestration.
Cursor shipped a TypeScript SDK that lets you run their coding agent from your own code. The Cursor Cookbook is a new repository of practical examples. If you've been wiring together AI tools with shell scripts and YAML files, this is a fundamentally better approach.
What the Cursor SDK Actually Does
The Cursor SDK is a TypeScript API for running Cursor's coding agent programmatically. You send a prompt, it runs the agent on a workspace (local or cloud), and streams events back as the run progresses. You get model selection, cancellation, artifact tracking, and conversation state management — all from code.
This matters because most AI coding workflows today are interactive. You open Cursor, write a prompt, watch it work, iterate. That's great for solo coding but breaks down when you want to orchestrate multiple agents, build automated review pipelines, or integrate coding agents into CI/CD.
The SDK turns the agent into infrastructure. You can spawn an agent to fix a bug, another to review the fix, and a third to deploy — all from a script. The Cookbook shows you how.
What's in the Cookbook
The repo is organized around six examples, each building on the last.
Quickstart is a minimal Node.js script: create an agent, send a prompt, stream the response. It's under 40 lines and gives you the mental model.
You create a LocalAgent with a workspace path and model, then call agent.run({ prompt }). The agent streams events — tool calls, file changes, terminal output — that you process with a simple for await loop.
Coding Agent CLI turns the quickstart into a command-line tool. You run cursor-agent "fix the linter errors" and watch the agent work in your terminal. It handles argument parsing, model selection, and exit codes. This is the building block for integrating agents into shell pipelines.
Prototyping Tool is a web app that spawns cloud agents for scaffolding new projects. You give it a project idea, it spins up a sandboxed agent, and you iterate on the generated code. It uses Cursor Cloud Agents, which means no local setup — the agent runs in a managed environment. This is how you prototype ideas without context-switching between Cursor, a terminal, and a browser.
Agent Kanban visualizes cloud agents as a kanban board. Agents are grouped by status (running, completed, failed) or repository. You can preview artifacts, restart failed runs, and create new agents from the board. It's a lightweight orchestration dashboard that gives you visibility into what your agents are doing.
DAG Task Runner is the most ambitious example. You decompose a complex task into a JSON DAG — a directed acyclic graph of subtasks with dependencies. Each node is a prompt sent to a subagent. The runner fans out nodes whose dependencies are satisfied, streaming live status into a Cursor Canvas that hot-reloads on every state change.
Think about what this enables: "Build a full-stack auth system" decomposes into "create the user model" → "build login endpoint" → "add session middleware" → "write tests." The DAG runner executes these in parallel where possible, in sequence where needed, and you watch the whole thing happen.
Why This Matters for Builders
Cursor isn't the only coding agent, but shipping an SDK with a cookbook signals something. They're treating the agent as a platform, not just a product. The SDK lets you build your own workflows on top of their agent, the same way you'd build on top of Stripe's payment API or Twilio's messaging API.
Here's what this unlocks for real projects:
- Automated PR review pipelines. Spawn a review agent on every PR, stream findings to a comment, and auto-fix low-risk issues. No human in the loop for mechanical changes.
- Multi-agent development teams. One agent writes code, another reviews it, a third writes tests. They run in parallel, coordinating through a DAG. The Kanban board gives you visibility.
- CI/CD integration. Add
cursor-agent "fix all type errors"as a CI step. If it succeeds, commit the changes and continue the pipeline. This is particularly useful for migrations and large-scale refactors. - Project scaffolding. Instead of running
create-next-appand manually configuring everything, describe what you want and let a cloud agent build the initial project structure with your preferred stack, linting rules, and folder conventions.
The Local vs Cloud Tradeoff
The SDK supports two runtimes: local agents that work on your filesystem, and cloud agents that run in sandboxed environments.
Local agents are fast and free — no API costs beyond your Cursor subscription. They work with your existing workspace, environment variables, and tools. The downside is resource consumption: each agent is a full Node.js process.
Cloud agents are isolated and scalable. You can run dozens in parallel without worrying about your machine. They're billed per run, making them cost-effective for bursty workloads like nightly builds or batch migrations. The tradeoff is latency — cloud agents take longer to start — and you need to manage API keys.
For most development workflows, local agents make sense. For CI/CD and batch processing, cloud agents are the right call. The Cookbook shows both patterns.
Getting Started
You need a Cursor API key from the Cursor integrations dashboard. Set it as CURSOR_API_KEY, clone the Cookbook, and run the quickstart:
git clone https://github.com/cursor/cookbook.git
cd cookbook/sdk/quickstart
npm install
npx tsx index.ts
The quickstart sends a simple prompt ("List all TypeScript files and summarize each one") and streams the agent's response to your terminal. From there, explore the other examples — each builds naturally on the previous one.
A useful addition to the Cookbook would be an example of chaining multiple agents with different models. Running a cheaper model for mechanical refactors and a more capable one for architectural decisions would optimize both cost and quality. The SDK supports model selection per agent, so this is possible today — it just needs a cookbook example.
Bottom Line
The Cursor Cookbook is exactly what the AI coding agent ecosystem needed. It moves from "here's a tool, figure it out" to "here's how to build real things with this tool." The examples are practical, well-documented, and cover the spectrum from quickstart to production orchestration.
If you're already using Cursor interactively, the SDK lets you automate the repetitive parts. If you're building developer tools, it gives you a coding agent you can embed. And if you're exploring multi-agent architectures, the DAG runner is a production-ready pattern you can copy.
The Cookbook is new — the repo has examples for SDK workflows but expect more categories over time: testing, code review, documentation generation, database migrations. What's there already is solid and immediately useful.