sdk

Build programmatic integrations with the Cursor SDK in TypeScript or Python.

Updated Oct 15, 2019
One-click install
npx skills add https://github.com/kkkaoru/dotfiles --skill sdk-kkkaoru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sdk
Source: https://github.com/kkkaoru/dotfiles/tree/main/.cursor/skills-cursor/sdk
Command: npx skills add https://github.com/kkkaoru/dotfiles --skill sdk-kkkaoru

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Running Cursor agents from scripts, CI pipelines, or backend services requires navigating two SDK variants, runtime selection, streaming, disposal, and error semantics that are easy to get wrong. This Skill provides the decision rules, invocation patterns, and failure-mode prevention needed to ship a working integration without trial and error. ## Core Features & Use Cases - Three Invocation Patterns: One-shot Agent.prompt for fire-and-forget jobs, Agent.create plus send for streaming multi-turn sessions, and Agent.resume for continuing agents across process boundaries. - Trap Prevention: Covers the five most common failures including silent local-runtime fallback, conflating startup errors with run failures, resource leaks from skipped disposal, missing wait() calls, and unsupported run operations. - Production Guidance: Exit-code conventions, retry handling with isRetryable and retry_after, explicit API key passing, MCP server configuration, and local versus cloud runtime selection. - Use Case: A GitHub Action that sends a prompt to a cloud Cursor agent on every pull request, streams the result, auto-creates a PR, and exits with distinct codes for startup versus run failures. ## Quick Start Ask the assistant to write a TypeScript script using the Cursor SDK that runs an agent locally against the current repo and prints the streamed 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 Agent.prompt for one-shot tasks or Agent.create followed by agent.send for streaming and multi-turn runs. Both the TypeScript @cursor/sdk and Python cursor-sdk packages follow the same Agent to Run model and authenticate with the CURSOR_API_KEY environment variable.

Should I use the TypeScript or Python Cursor SDK?

Match the SDK to your codebase: package.json and .ts files indicate TypeScript, while pyproject.toml and .py files indicate Python. Both SDKs share identical concepts and differ only in syntax, such as camelCase versus snake_case and async defaults.

What is the difference between local and cloud Cursor agents?

Local agents run on the caller's machine against a working directory and reuse local credentials. Cloud agents run on a Cursor-hosted VM against a cloned repository, suit long jobs and automation, and can auto-create pull requests.

Why did my Cursor SDK agent run locally instead of in the cloud?

The SDK silently defaults to the local runtime when neither local nor cloud options are set. Always pass cloud with repos or local with cwd explicitly so the intended runtime is never chosen by accident.

How do I handle errors from the Cursor SDK?

A thrown CursorAgentError means the run never started, while a result status of error means it executed and failed. Use distinct exit codes for each, check isRetryable before retrying, and always call run.wait() to obtain the terminal result.

Do MCP servers 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. Pass the server configuration again on the resume call in either language.