sdk

Guides building programmatic integrations with the Cursor SDK in TypeScript or Python.

3|Updated Jul 2, 2026
One-click install
npx skills add https://github.com/ArangoGutierrez/claude-toolkit --skill sdk-arangogutierrez
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sdk
Source: https://github.com/ArangoGutierrez/claude-toolkit/tree/main/.cursor/skills-cursor/sdk
Command: npx skills add https://github.com/ArangoGutierrez/claude-toolkit --skill sdk-arangogutierrez

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers integrating Cursor agents into scripts, CI pipelines, or backend services often hit silent runtime misconfiguration, leaked resources, and conflated error types. This Skill provides the decision framework, invocation patterns, and failure-mode prevention needed to build a working Cursor SDK integration correctly the first time. ## Core Features & Use Cases - Three Invocation Patterns: Covers one-shot Agent.prompt, durable Agent.create with streaming follow-ups, and Agent.resume for continuing agents across process boundaries, in both TypeScript (@cursor/sdk) and Python (cursor-sdk). - Trap Prevention: Documents the five most common integration failures, including silent local-runtime fallback, conflating startup errors with run failures, resource leaks from missing disposal, and unsupported run operations. - Production Guidance: Covers auth via CURSOR_API_KEY, model selection with Cursor.models.list(), MCP server configuration, local vs cloud runtime tradeoffs, and exit-code conventions for CI. - Use Case: A team wants a GitHub Action that asks a Cursor agent to review each pull request. This Skill walks them through choosing the cloud runtime, wiring Agent.prompt with an explicit API key, and setting exit codes based on run status. ## Quick Start Ask the assistant to write a TypeScript script that uses the Cursor SDK to send a one-shot prompt to a cloud agent and print the result.

Frequently Asked Questions about sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a Cursor agent programmatically from a script?▼

Use the Cursor SDK's Agent.prompt for one-shot tasks or Agent.create followed by agent.send for streaming and multi-turn conversations. Both TypeScript (@cursor/sdk) and Python (cursor-sdk) variants follow the same Agent-to-Run model and authenticate with a CURSOR_API_KEY.

Should I use the TypeScript or Python Cursor SDK?▼

Choose based on your codebase: package.json and .ts files indicate TypeScript, while pyproject.toml and .py files indicate Python. Both SDKs share identical concepts, differing only in syntax conventions like camelCase versus snake_case and async defaults.

What is the difference between local and cloud runtimes in the Cursor SDK?▼

Local runs on the caller's machine against a working directory, reusing its environment and credentials. Cloud runs on a Cursor-hosted VM against a freshly cloned repo, suiting long jobs and automatic PR creation. Always set the runtime explicitly to avoid silent local fallback.

Why does my Cursor SDK agent leak resources or hang?▼

Leaks happen when disposal is skipped: use await using in TypeScript or a with block in Python so executors and HTTP clients close properly. Also always call run.wait() after streaming, since skipping it leaves internal watchers alive and hides the terminal status.

How do I handle errors from the Cursor SDK?▼

A thrown CursorAgentError means the run never started (auth, config, or network), while result.status == "error" means it executed and failed. Use distinct exit codes for each, and respect the isRetryable flag and Python's retry_after before retrying.

Do MCP server configurations persist when resuming a Cursor agent?▼

No, inline MCP servers are not persisted across Agent.resume because they often carry secrets and live only in memory. You must pass the server configurations again on the resume call in either language.