[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M781PSH8ZEQPGGNG4SC56G83":3,"skill-same:01M781PSH8ZEQPGGNG4SC56G83":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M781PSH8ZEQPGGNG4SC56G83","cursor-sdk",null,"Guide users building apps, scripts, CI pipelines, or automations on top of the Cursor TypeScript SDK (`@cursor\u002Fsdk`). Use this skill whenever the user mentions integrating, installing, or writing code against the Cursor SDK; whenever they say `Agent.create`, `Agent.prompt`, `Agent.resume`, `agent.send`, `run.stream`, `CursorAgentError`, or `@cursor\u002Fsdk`; whenever they ask to run Cursor agents programmatically from a script, CI\u002FCD pipeline, GitHub Action, backend service, or any other code that isn't the Cursor IDE itself; and whenever they want to pick between local and cloud runtime, configure MCP servers for an SDK agent, or handle streaming, cancellation, or errors from an SDK agent. Also trigger when a user is wiring Cursor into an automation, writing a bot that runs Cursor, or porting REST `\u002Fv1\u002Fagents` calls to the SDK, even if they don't explicitly name the package. Use this eagerly rather than answering from memory; the SDK surface evolves and this skill plus its references are the source of truth for the external package.","TheAngryPit\u002FTheAngrySkills","TheAngryPit","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F7040636?v=4","01M7803EENA9ATXJ46S9268QJX","Vitor Cepeda Lopes","01M7803EF9FMF4G4420XE4DV7Y",0,"MIT","https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fsnapshot\u002Fcursor-sdk\u002Fskills\u002Fcursor-sdk\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: cursor-sdk\ndescription: Guide users building apps, scripts, CI pipelines, or automations on top of the Cursor TypeScript SDK (`@cursor\u002Fsdk`). Use this skill whenever the user mentions integrating, installing, or writing code against the Cursor SDK; whenever they say `Agent.create`, `Agent.prompt`, `Agent.resume`, `agent.send`, `run.stream`, `CursorAgentError`, or `@cursor\u002Fsdk`; whenever they ask to run Cursor agents programmatically from a script, CI\u002FCD pipeline, GitHub Action, backend service, or any other code that isn't the Cursor IDE itself; and whenever they want to pick between local and cloud runtime, configure MCP servers for an SDK agent, or handle streaming, cancellation, or errors from an SDK agent. Also trigger when a user is wiring Cursor into an automation, writing a bot that runs Cursor, or porting REST `\u002Fv1\u002Fagents` calls to the SDK, even if they don't explicitly name the package. Use this eagerly rather than answering from memory; the SDK surface evolves and this skill plus its references are the source of truth for the external package.\n---\n\n# Cursor SDK\n\nThe Cursor TypeScript SDK (`@cursor\u002Fsdk`) runs Cursor agents programmatically. The same interfaces drives the local runtime (agent runs on your machine against your files) and the cloud runtime (agent runs on Cursor-hosted or self-hosted infrastructure against a cloned repo and opens PRs).\n\nUse this skill to help someone **bootstrap a working integration quickly** and **avoid the handful of traps that bite new users**. Canonical docs live at [https:\u002F\u002Fcursor.com\u002Fdocs\u002Fapi\u002Fsdk\u002Ftypescript](https:\u002F\u002Fcursor.com\u002Fdocs\u002Fapi\u002Fsdk\u002Ftypescript); this skill only adds decision-making, failure-mode prevention, and ready-to-extend patterns.\n\n## Voice and Posture\n\nThis skill helps the user **build** with the SDK. It is not the place to validate, congratulate, or sell the SDK as a choice. The user's intent is the input; your job is execution.\n\n- **When the user names the SDK explicitly** (says \"Cursor SDK\", `@cursor\u002Fsdk`, `Agent.create`, `Agent.prompt`, etc.): assume they know what the SDK is and have decided to use it. Skip framing, skip pep talk, go straight to producing the integration. No \"good news\", no \"the SDK is perfect for this\", no \"this is almost exactly the pattern X is designed for\".\n- **When the user describes a problem the SDK fits but doesn't name it** (\"I want a bot that reviews my PRs\", \"I want a script that asks Cursor questions about my repo\"): the SDK isn't yet a confirmed choice. Surface it as a question, briefly, then wait: *\"The Cursor SDK is what I'd reach for here — want me to design it that way, or do you have a different runtime in mind?\"* If they confirm, proceed. If they push back or want options, give options.\n- **In either case, don't restate the user's intent back to them.** They know what they want. Get to the design.\n\nAvoid these specific openers (and their close cousins):\n\n- \"Good news: this is exactly the pattern…\"\n- \"The SDK is built for this shape.\"\n- \"Great, you've come to the right place.\"\n- \"This is almost exactly the X the SDK is designed for.\"\n- Any lede that compliments the user's choice or restates their goal in flattering terms.\n\nPrefer:\n\n- Open with the design decision or the first thing they need to know.\n- If you genuinely have a design choice to flag (local vs cloud, prompt vs send, sync vs stream), name it in one sentence and explain why; don't preface it with validation.\n\n## When to open a reference file\n\nKeep this page short. Read a reference file only when the user's task clearly falls inside it:\n\n\n| If the user is...                                                                    | Read                                                           |\n| ------------------------------------------------------------------------------------ | -------------------------------------------------------------- |\n| Picking between local and cloud runtime, or not sure which they should use           | [`references\u002Fruntime-choice.md`](references\u002Fruntime-choice.md) |\n| Debugging auth (401s, \"Missing CURSOR_API_KEY\", team-vs-user keys, local vs prod)    | [`references\u002Fauth.md`](references\u002Fauth.md)                     |\n| Handling errors, retries, rate limits, `CursorAgentError`, `result.status === error` | [`references\u002Ferror-handling.md`](references\u002Ferror-handling.md) |\n| Consuming streams, picking event types, cancelling, or deciding stream vs wait       | [`references\u002Fstreaming.md`](references\u002Fstreaming.md)           |\n| Configuring MCP servers (HTTP, stdio, cloud vs local transport, auth injection)      | [`references\u002Fmcp.md`](references\u002Fmcp.md)                       |\n| Using sub-agents, resume, artifacts, listing\u002Finspecting agents, `Agent.messages`     | [`references\u002Fadvanced.md`](references\u002Fadvanced.md)             |\n| Building a specific integration (CI review bot, scheduled triage, chat, webhook)     | [`references\u002Fpatterns.md`](references\u002Fpatterns.md)             |\n\n\nEverything below is the minimum needed for 80% of tasks.\n\n## The Three Invocation Patterns\n\nAlmost every SDK integration collapses to one of three shapes. Pick the one that fits the job, don't mix them.\n\n### 1. `Agent.prompt(...)` — one-shot\n\n```typescript\nimport { Agent } from \"@cursor\u002Fsdk\";\n\nconst result = await Agent.prompt(\"Refactor src\u002Futils.ts for readability\", {\n  apiKey: process.env.CURSOR_API_KEY!,\n  model: { id: \"composer-2\" },\n  local: { cwd: process.cwd() },\n});\nconsole.log(result.status, result.result);\n```\n\nUse for fire-and-forget scripts, GitHub Actions steps, or any \"send this prompt, get a result, exit\" flow. No streaming, no follow-ups, no cleanup to remember. If you're reaching for this and then immediately resuming, you wanted pattern 2 instead.\n\n### 2. `Agent.create(...)` + `agent.send(...)` — durable with follow-ups\n\n```typescript\nimport { Agent } from \"@cursor\u002Fsdk\";\n\nconst agent = Agent.create({\n  apiKey: process.env.CURSOR_API_KEY!,\n  model: { id: \"composer-2\" },\n  local: { cwd: process.cwd() },\n});\n\ntry {\n  const run = await agent.send(\"Find the bug in src\u002Fauth.ts\");\n  for await (const event of run.stream()) {\n    if (event.type === \"assistant\") {\n      for (const block of event.message.content) {\n        if (block.type === \"text\") process.stdout.write(block.text);\n      }\n    }\n  }\n  const result = await run.wait();\n\n  \u002F\u002F Follow-up keeps full conversation context.\n  const run2 = await agent.send(\"Now write a regression test for it\");\n  await run2.wait();\n} finally {\n  await agent[Symbol.asyncDispose]();\n}\n```\n\nUse when you need streaming, multi-turn conversation, or lifecycle operations (cancel, status listener). This is the shape of most non-trivial integrations.\n\n### 3. `Agent.resume(...)` — pick up an existing agent later\n\n```typescript\nconst agent = Agent.resume(previousAgentId, {\n  apiKey: process.env.CURSOR_API_KEY!,\n  model: { id: \"composer-2\" },\n  local: { cwd: process.cwd() },\n});\nconst run = await agent.send(\"Also update the changelog\");\nawait run.wait();\n```\n\nUse across process boundaries: a cron that continues last night's cleanup, a webhook that extends a user's agent, an interactive CLI that reloads conversation state. **Inline `mcpServers` are not persisted across resume** — pass them again on the resume call.\n\n## Top Five Traps (read these before writing code)\n\nThese trip up almost every new integration. They're all easy to prevent once you know about them.\n\n### 1. Missing `cloud: { repos }` silently defaults to local\n\n`AgentOptions` doesn't require `local` or `cloud`; if you omit both, the SDK selects the local runtime. The trap: if you intended a cloud agent and forgot the `cloud:` field, you get a local agent silently — no error, just a local agent ID and a local executor. Always pass `cloud: { repos }` explicitly when you want cloud, and pass `local: { cwd }` explicitly for local even though it's the default. Picking the right runtime: see [`references\u002Fruntime-choice.md`](references\u002Fruntime-choice.md).\n\n### 2. Two different kinds of failure, one instinct to conflate them\n\n```typescript\ntry {\n  const run = await agent.send(prompt);\n  const result = await run.wait();\n  if (result.status === \"error\") {\n    \u002F\u002F Agent started but failed mid-run. Inspect transcript, git state, tool outputs.\n    console.error(`run failed: ${result.id}`);\n    process.exit(2);\n  }\n} catch (err) {\n  if (err instanceof CursorAgentError) {\n    \u002F\u002F Didn't start. Auth, config, network. Fix environment, retry.\n    console.error(`startup failed: ${err.message}, retryable=${err.isRetryable}`);\n    process.exit(1);\n  }\n  throw err;\n}\n```\n\n`CursorAgentError` thrown → the run never executed (auth, config, network). `result.status === \"error\"` → the agent did work, and that work failed. Different fixes, different exit codes, different observability. Full taxonomy in [`references\u002Ferror-handling.md`](references\u002Ferror-handling.md).\n\n### 3. Forgetting `await agent[Symbol.asyncDispose]()` leaks resources\n\nThe SDK holds handles to local executors, persisted run stores, and cloud API clients. Not disposing means leaked child processes, open databases, and in long-running services, memory growth. Always dispose in a `finally`, or use `Agent.prompt()` (disposes for you), or use the `await using` syntax if your tsconfig targets it:\n\n```typescript\nawait using agent = Agent.create({ \u002F* ... *\u002F });\n```\n\n### 4. Streaming is optional but `wait()` is (almost) required\n\n`run.stream()` is how you observe; `run.wait()` is how you get the terminal result. You can skip streaming, but skipping `wait()` means you can't tell whether the run finished, errored, or was cancelled, and you'll leak the run's internal watchers. Always call `wait()`. If you don't want live output, just call `wait()` alone. See [`references\u002Fstreaming.md`](references\u002Fstreaming.md) for event type reference.\n\n### 5. Not every `run` operation is supported on every runtime\n\n`Run` exposes four operations — `stream`, `wait`, `cancel`, `conversation` — and the runtime may or may not support each. Always guard with `run.supports(\"...\")` before calling, rather than assuming:\n\n```typescript\nif (run.supports(\"cancel\")) await run.cancel();\nif (run.supports(\"conversation\")) console.log(await run.conversation());\n```\n\nCurrent gap worth knowing about: detached\u002Fre-hydrated runs (you got the handle from `Agent.getRun(...)` after the live event store has closed) may not support `stream()` and may have empty `conversation()`. `run.unsupportedReason(op)` tells you why. Cloud `run.conversation()` IS supported — it accumulates best-effort from the stream.\n\n## Local vs Cloud, in one sentence each\n\n- **Local** — runs on the caller's machine against `cwd`, reuses their environment and credentials, good for dev loops and CI that already has a repo checkout.\n- **Cloud** — runs on a Cursor-hosted VM against a freshly cloned `repos[].url`, good for long jobs, fire-and-forget automation, and opening real PRs (`autoCreatePR: true`).\n\nDecision tree, capability differences, and capability gaps (artifacts, cancel, MCP transport): [`references\u002Fruntime-choice.md`](references\u002Fruntime-choice.md).\n\n## Auth, minimum viable\n\n```bash\nexport CURSOR_API_KEY=\"cursor_...\"  # user API key or team service-account key\n```\n\nThe SDK reads `CURSOR_API_KEY` if `apiKey` isn't passed. Both user keys (from [https:\u002F\u002Fcursor.com\u002Fdashboard\u002Fcloud-agents](https:\u002F\u002Fcursor.com\u002Fdashboard\u002Fcloud-agents)) and team service-account keys (Team Settings → Service accounts) work for local and cloud runs.\n\nIf you're seeing 401s, the usual suspects are: key pasted with surrounding whitespace, key minted against a different environment, or the key belongs to a user without repo access for a cloud run. Full troubleshooting: [`references\u002Fauth.md`](references\u002Fauth.md).\n\n## Model Selection\n\n```typescript\nimport { Cursor } from \"@cursor\u002Fsdk\";\n\nconst models = await Cursor.models.list({ apiKey: process.env.CURSOR_API_KEY! });\n```\n\n`composer-2` is the current default for most integrations. `{ id: \"auto\" }` lets the server pick. Model IDs change; don't hardcode exotic ones without calling `Cursor.models.list()` first to confirm the caller has access.\n\nModel is **required for local**, **optional for cloud** (the server resolves a default from the caller's account).\n\n## Production Best Practices\n\nApply these to any integration that runs unattended:\n\n1. **Wrap every `Agent.create` \u002F `Agent.prompt` \u002F `Agent.resume` in a try\u002Ffinally with `[Symbol.asyncDispose]()`**. Non-negotiable.\n2. **Distinguish startup failures from run failures** — exit code 1 for `CursorAgentError`, exit code 2 for `result.status === \"error\"`, exit code 0 only for `finished`. Makes CI failures actually readable.\n3. **Log `run.id` and `agent.agentId` immediately after `send()`** before streaming. If the stream hangs, the IDs are what you need to investigate in the dashboard or via `Agent.getRun(...)`.\n4. **Respect `error.isRetryable`** — it's the backend telling you the specific failure is safe to retry. Blind retries can cause duplicate cloud runs; respecting the flag doesn't.\n5. **Use `local: { settingSources: [] }` (default) unless you need ambient config.** Opting into `\"all\"` loads project\u002Fuser\u002Fteam\u002FMDM settings from the caller's environment, which is rarely what you want from a service. Note: `settingSources` lives under `local`, not at the top level; it has no effect on cloud agents (cloud always honors team\u002Fproject\u002Fplugins).\n6. **For cloud agents in CI, set `skipReviewerRequest: true`** unless a human should be paged — it suppresses the reviewer-request step and keeps PR notifications quiet.\n7. **Always pass `apiKey` explicitly** in shared-infrastructure code instead of relying on the env var. Makes the credential dependency obvious and prevents cross-tenant mistakes.\n8. **Prefer `Agent.prompt(...)` for true one-shots** — it disposes for you and is harder to leak.\n\nLonger version with examples: [`references\u002Fpatterns.md`](references\u002Fpatterns.md).\n\n## Observing a Run You Didn't Launch\n\nYou can inspect any agent\u002Frun by ID later:\n\n```typescript\n\u002F\u002F Cloud: IDs that start with \"bc-\" auto-route to the cloud API\nconst info = await Agent.get(\"bc-abc123\", { apiKey });\nconst run = await Agent.getRun(runId, { runtime: \"cloud\", agentId: \"bc-abc123\", apiKey });\n\n\u002F\u002F Local: you need the cwd where the agent was created\nconst localInfo = await Agent.list({ runtime: \"local\", cwd: process.cwd() });\n```\n\nA cloud `bc-`-prefixed agent ID is **not** a run ID. If you only have a run ID (from a log or a webhook), pass it to `Agent.getRun` with the runtime hint; don't confuse the two.\n\n## Offering a Canvas\n\nIf the user's integration monitors, lists, or visualizes agents — dashboards of active runs, conversation replays, tool-call timelines — offer a Cursor Canvas to render it. If they accept, defer entirely to the `canvas` skill.\n\n## What This Skill Doesn't Cover\n\n- The Cloud Agents REST API (`\u002Fv1\u002Fagents\u002F*`). If the user needs a non-TS client, the REST API is documented separately at \u003Chttps:\u002F\u002Fcursor.com\u002Fdocs\u002Fcloud-agent\u002Fapi>; check there for current capabilities before assuming parity with the SDK.\n- `.cursor\u002Fhooks.json` hooks. Cloud agents execute them but the SDK doesn't manage them; see Cursor's Hooks docs.\n- Private workers \u002F self-hosted cloud. Send users to the Private Workers docs.\n- Python \u002F non-TS SDKs. There is no first-party SDK in other languages at time of writing; REST is the portable option.\n\n","# Cursor SDK\n\nThe Cursor TypeScript SDK (`@cursor\u002Fsdk`) runs Cursor agents programmatically. The same interfaces drives the local runtime (agent runs on your machine against your files) and the cloud runtime (agent runs on Cursor-hosted or self-hosted infrastructure against a cloned repo and opens PRs).\n\nUse this skill to help someone **bootstrap a working integration quickly** and **avoid the handful of traps that bite new users**. Canonical docs live at [https:\u002F\u002Fcursor.com\u002Fdocs\u002Fapi\u002Fsdk\u002Ftypescript](https:\u002F\u002Fcursor.com\u002Fdocs\u002Fapi\u002Fsdk\u002Ftypescript); this skill only adds decision-making, failure-mode prevention, and ready-to-extend patterns.\n\n## Voice and Posture\n\nThis skill helps the user **build** with the SDK. It is not the place to validate, congratulate, or sell the SDK as a choice. The user's intent is the input; your job is execution.\n\n- **When the user names the SDK explicitly** (says \"Cursor SDK\", `@cursor\u002Fsdk`, `Agent.create`, `Agent.prompt`, etc.): assume they know what the SDK is and have decided to use it. Skip framing, skip pep talk, go straight to producing the integration. No \"good news\", no \"the SDK is perfect for this\", no \"this is almost exactly the pattern X is designed for\".\n- **When the user describes a problem the SDK fits but doesn't name it** (\"I want a bot that reviews my PRs\", \"I want a script that asks Cursor questions about my repo\"): the SDK isn't yet a confirmed choice. Surface it as a question, briefly, then wait: *\"The Cursor SDK is what I'd reach for here — want me to design it that way, or do you have a different runtime in mind?\"* If they confirm, proceed. If they push back or want options, give options.\n- **In either case, don't restate the user's intent back to them.** They know what they want. Get to the design.\n\nAvoid these specific openers (and their close cousins):\n\n- \"Good news: this is exactly the pattern…\"\n- \"The SDK is built for this shape.\"\n- \"Great, you've come to the right place.\"\n- \"This is almost exactly the X the SDK is designed for.\"\n- Any lede that compliments the user's choice or restates their goal in flattering terms.\n\nPrefer:\n\n- Open with the design decision or the first thing they need to know.\n- If you genuinely have a design choice to flag (local vs cloud, prompt vs send, sync vs stream), name it in one sentence and explain why; don't preface it with validation.\n\n## When to open a reference file\n\nKeep this page short. Read a reference file only when the user's task clearly falls inside it:\n\n\n| If the user is...                                                                    | Read                                                           |\n| ------------------------------------------------------------------------------------ | -------------------------------------------------------------- |\n| Picking between local and cloud runtime, or not sure which they should use           | [`references\u002Fruntime-choice.md`](references\u002Fruntime-choice.md) |\n| Debugging auth (401s, \"Missing CURSOR_API_KEY\", team-vs-user keys, local vs prod)    | [`references\u002Fauth.md`](references\u002Fauth.md)                     |\n| Handling errors, retries, rate limits, `CursorAgentError`, `result.status === error` | [`references\u002Ferror-handling.md`](references\u002Ferror-handling.md) |\n| Consuming streams, picking event types, cancelling, or deciding stream vs wait       | [`references\u002Fstreaming.md`](references\u002Fstreaming.md)           |\n| Configuring MCP servers (HTTP, stdio, cloud vs local transport, auth injection)      | [`references\u002Fmcp.md`](references\u002Fmcp.md)                       |\n| Using sub-agents, resume, artifacts, listing\u002Finspecting agents, `Agent.messages`     | [`references\u002Fadvanced.md`](references\u002Fadvanced.md)             |\n| Building a specific integration (CI review bot, scheduled triage, chat, webhook)     | [`references\u002Fpatterns.md`](references\u002Fpatterns.md)             |\n\n\nEverything below is the minimum needed for 80% of tasks.\n\n## The Three Invocation Patterns\n\nAlmost every SDK integration collapses to one of three shapes. Pick the one that fits the job, don't mix them.\n\n### 1. `Agent.prompt(...)` — one-shot\n\n```typescript\nimport { Agent } from \"@cursor\u002Fsdk\";\n\nconst result = await Agent.prompt(\"Refactor src\u002Futils.ts for readability\", {\n  apiKey: process.env.CURSOR_API_KEY!,\n  model: { id: \"composer-2\" },\n  local: { cwd: process.cwd() },\n});\nconsole.log(result.status, result.result);\n```\n\nUse for fire-and-forget scripts, GitHub Actions steps, or any \"send this prompt, get a result, exit\" flow. No streaming, no follow-ups, no cleanup to remember. If you're reaching for this and then immediately resuming, you wanted pattern 2 instead.\n\n### 2. `Agent.create(...)` + `agent.send(...)` — durable with follow-ups\n\n```typescript\nimport { Agent } from \"@cursor\u002Fsdk\";\n\nconst agent = Agent.create({\n  apiKey: process.env.CURSOR_API_KEY!,\n  model: { id: \"composer-2\" },\n  local: { cwd: process.cwd() },\n});\n\ntry {\n  const run = await agent.send(\"Find the bug in src\u002Fauth.ts\");\n  for await (const event of run.stream()) {\n    if (event.type === \"assistant\") {\n      for (const block of event.message.content) {\n        if (block.type === \"text\") process.stdout.write(block.text);\n      }\n    }\n  }\n  const result = await run.wait();\n\n  \u002F\u002F Follow-up keeps full conversation context.\n  const run2 = await agent.send(\"Now write a regression test for it\");\n  await run2.wait();\n} finally {\n  await agent[Symbol.asyncDispose]();\n}\n```\n\nUse when you need streaming, multi-turn conversation, or lifecycle operations (cancel, status listener). This is the shape of most non-trivial integrations.\n\n### 3. `Agent.resume(...)` — pick up an existing agent later\n\n```typescript\nconst agent = Agent.resume(previousAgentId, {\n  apiKey: process.env.CURSOR_API_KEY!,\n  model: { id: \"composer-2\" },\n  local: { cwd: process.cwd() },\n});\nconst run = await agent.send(\"Also update the changelog\");\nawait run.wait();\n```\n\nUse across process boundaries: a cron that continues last night's cleanup, a webhook that extends a user's agent, an interactive CLI that reloads conversation state. **Inline `mcpServers` are not persisted across resume** — pass them again on the resume call.\n\n## Top Five Traps (read these before writing code)\n\nThese trip up almost every new integration. They're all easy to prevent once you know about them.\n\n### 1. Missing `cloud: { repos }` silently defaults to local\n\n`AgentOptions` doesn't require `local` or `cloud`; if you omit both, the SDK selects the local runtime. The trap: if you intended a cloud agent and forgot the `cloud:` field, you get a local agent silently — no error, just a local agent ID and a local executor. Always pass `cloud: { repos }` explicitly when you want cloud, and pass `local: { cwd }` explicitly for local even though it's the default. Picking the right runtime: see [`references\u002Fruntime-choice.md`](references\u002Fruntime-choice.md).\n\n### 2. Two different kinds of failure, one instinct to conflate them\n\n```typescript\ntry {\n  const run = await agent.send(prompt);\n  const result = await run.wait();\n  if (result.status === \"error\") {\n    \u002F\u002F Agent started but failed mid-run. Inspect transcript, git state, tool outputs.\n    console.error(`run failed: ${result.id}`);\n    process.exit(2);\n  }\n} catch (err) {\n  if (err instanceof CursorAgentError) {\n    \u002F\u002F Didn't start. Auth, config, network. Fix environment, retry.\n    console.error(`startup failed: ${err.message}, retryable=${err.isRetryable}`);\n    process.exit(1);\n  }\n  throw err;\n}\n```\n\n`CursorAgentError` thrown → the run never executed (auth, config, network). `result.status === \"error\"` → the agent did work, and that work failed. Different fixes, different exit codes, different observability. Full taxonomy in [`references\u002Ferror-handling.md`](references\u002Ferror-handling.md).\n\n### 3. Forgetting `await agent[Symbol.asyncDispose]()` leaks resources\n\nThe SDK holds handles to local executors, persisted run stores, and cloud API clients. Not disposing means leaked child processes, open databases, and in long-running services, memory growth. Always dispose in a `finally`, or use `Agent.prompt()` (disposes for you), or use the `await using` syntax if your tsconfig targets it:\n\n```typescript\nawait using agent = Agent.create({ \u002F* ... *\u002F });\n```\n\n### 4. Streaming is optional but `wait()` is (almost) required\n\n`run.stream()` is how you observe; `run.wait()` is how you get the terminal result. You can skip streaming, but skipping `wait()` means you can't tell whether the run finished, errored, or was cancelled, and you'll leak the run's internal watchers. Always call `wait()`. If you don't want live output, just call `wait()` alone. See [`references\u002Fstreaming.md`](references\u002Fstreaming.md) for event type reference.\n\n### 5. Not every `run` operation is supported on every runtime\n\n`Run` exposes four operations — `stream`, `wait`, `cancel`, `conversation` — and the runtime may or may not support each. Always guard with `run.supports(\"...\")` before calling, rather than assuming:\n\n```typescript\nif (run.supports(\"cancel\")) await run.cancel();\nif (run.supports(\"conversation\")) console.log(await run.conversation());\n```\n\nCurrent gap worth knowing about: detached\u002Fre-hydrated runs (you got the handle from `Agent.getRun(...)` after the live event store has closed) may not support `stream()` and may have empty `conversation()`. `run.unsupportedReason(op)` tells you why. Cloud `run.conversation()` IS supported — it accumulates best-effort from the stream.\n\n## Local vs Cloud, in one sentence each\n\n- **Local** — runs on the caller's machine against `cwd`, reuses their environment and credentials, good for dev loops and CI that already has a repo checkout.\n- **Cloud** — runs on a Cursor-hosted VM against a freshly cloned `repos[].url`, good for long jobs, fire-and-forget automation, and opening real PRs (`autoCreatePR: true`).\n\nDecision tree, capability differences, and capability gaps (artifacts, cancel, MCP transport): [`references\u002Fruntime-choice.md`](references\u002Fruntime-choice.md).\n\n## Auth, minimum viable\n\n```bash\nexport CURSOR_API_KEY=\"cursor_...\"  # user API key or team service-account key\n```\n\nThe SDK reads `CURSOR_API_KEY` if `apiKey` isn't passed. Both user keys (from [https:\u002F\u002Fcursor.com\u002Fdashboard\u002Fcloud-agents](https:\u002F\u002Fcursor.com\u002Fdashboard\u002Fcloud-agents)) and team service-account keys (Team Settings → Service accounts) work for local and cloud runs.\n\nIf you're seeing 401s, the usual suspects are: key pasted with surrounding whitespace, key minted against a different environment, or the key belongs to a user without repo access for a cloud run. Full troubleshooting: [`references\u002Fauth.md`](references\u002Fauth.md).\n\n## Model Selection\n\n```typescript\nimport { Cursor } from \"@cursor\u002Fsdk\";\n\nconst models = await Cursor.models.list({ apiKey: process.env.CURSOR_API_KEY! });\n```\n\n`composer-2` is the current default for most integrations. `{ id: \"auto\" }` lets the server pick. Model IDs change; don't hardcode exotic ones without calling `Cursor.models.list()` first to confirm the caller has access.\n\nModel is **required for local**, **optional for cloud** (the server resolves a default from the caller's account).\n\n## Production Best Practices\n\nApply these to any integration that runs unattended:\n\n1. **Wrap every `Agent.create` \u002F `Agent.prompt` \u002F `Agent.resume` in a try\u002Ffinally with `[Symbol.asyncDispose]()`**. Non-negotiable.\n2. **Distinguish startup failures from run failures** — exit code 1 for `CursorAgentError`, exit code 2 for `result.status === \"error\"`, exit code 0 only for `finished`. Makes CI failures actually readable.\n3. **Log `run.id` and `agent.agentId` immediately after `send()`** before streaming. If the stream hangs, the IDs are what you need to investigate in the dashboard or via `Agent.getRun(...)`.\n4. **Respect `error.isRetryable`** — it's the backend telling you the specific failure is safe to retry. Blind retries can cause duplicate cloud runs; respecting the flag doesn't.\n5. **Use `local: { settingSources: [] }` (default) unless you need ambient config.** Opting into `\"all\"` loads project\u002Fuser\u002Fteam\u002FMDM settings from the caller's environment, which is rarely what you want from a service. Note: `settingSources` lives under `local`, not at the top level; it has no effect on cloud agents (cloud always honors team\u002Fproject\u002Fplugins).\n6. **For cloud agents in CI, set `skipReviewerRequest: true`** unless a human should be paged — it suppresses the reviewer-request step and keeps PR notifications quiet.\n7. **Always pass `apiKey` explicitly** in shared-infrastructure code instead of relying on the env var. Makes the credential dependency obvious and prevents cross-tenant mistakes.\n8. **Prefer `Agent.prompt(...)` for true one-shots** — it disposes for you and is harder to leak.\n\nLonger version with examples: [`references\u002Fpatterns.md`](references\u002Fpatterns.md).\n\n## Observing a Run You Didn't Launch\n\nYou can inspect any agent\u002Frun by ID later:\n\n```typescript\n\u002F\u002F Cloud: IDs that start with \"bc-\" auto-route to the cloud API\nconst info = await Agent.get(\"bc-abc123\", { apiKey });\nconst run = await Agent.getRun(runId, { runtime: \"cloud\", agentId: \"bc-abc123\", apiKey });\n\n\u002F\u002F Local: you need the cwd where the agent was created\nconst localInfo = await Agent.list({ runtime: \"local\", cwd: process.cwd() });\n```\n\nA cloud `bc-`-prefixed agent ID is **not** a run ID. If you only have a run ID (from a log or a webhook), pass it to `Agent.getRun` with the runtime hint; don't confuse the two.\n\n## Offering a Canvas\n\nIf the user's integration monitors, lists, or visualizes agents — dashboards of active runs, conversation replays, tool-call timelines — offer a Cursor Canvas to render it. If they accept, defer entirely to the `canvas` skill.\n\n## What This Skill Doesn't Cover\n\n- The Cloud Agents REST API (`\u002Fv1\u002Fagents\u002F*`). If the user needs a non-TS client, the REST API is documented separately at \u003Chttps:\u002F\u002Fcursor.com\u002Fdocs\u002Fcloud-agent\u002Fapi>; check there for current capabilities before assuming parity with the SDK.\n- `.cursor\u002Fhooks.json` hooks. Cloud agents execute them but the SDK doesn't manage them; see Cursor's Hooks docs.\n- Private workers \u002F self-hosted cloud. Send users to the Private Workers docs.\n- Python \u002F non-TS SDKs. There is no first-party SDK in other languages at time of writing; REST is the portable option.\n\n",{"name":5,"description":7},"main","f31e1d2df163b90a48e30d0a3df67285f6641418","sources\u002Fcursor-plugins\u002Fsnapshot\u002Fcursor-sdk\u002Fskills\u002Fcursor-sdk",1,"https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills","https:\u002F\u002Fgithub.com\u002FTheAngryPit","www.vitorcepedalopes.com","Creative Director | Executive Producer | Storyteller | Narrative Worlds & Creative Production Systems\r\nFounder @TheHive-Mind ","2026-11-14 21:48:38",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add TheAngryPit\u002FTheAngrySkills --skill cursor-sdk",{"tool":39,"command":40},"bunx","bunx skills add TheAngryPit\u002FTheAngrySkills --skill cursor-sdk",{"tool":42,"command":43},"pnpm","pnpm dlx skills add TheAngryPit\u002FTheAngrySkills --skill cursor-sdk","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fsnapshot\u002Fcursor-sdk\u002Fskills\u002Fcursor-sdk\u002FSKILL.md",true,[47,53,57,61,65,69,73],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"references\u002Fadvanced.md","REFERENCE","参考文档",8999,"https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fsnapshot\u002Fcursor-sdk\u002Fskills\u002Fcursor-sdk\u002Freferences\u002Fadvanced.md",{"path":54,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":55,"sourceHtmlUrl":56},"references\u002Fauth.md",6154,"https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fsnapshot\u002Fcursor-sdk\u002Fskills\u002Fcursor-sdk\u002Freferences\u002Fauth.md",{"path":58,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":59,"sourceHtmlUrl":60},"references\u002Ferror-handling.md",8239,"https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fsnapshot\u002Fcursor-sdk\u002Fskills\u002Fcursor-sdk\u002Freferences\u002Ferror-handling.md",{"path":62,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":63,"sourceHtmlUrl":64},"references\u002Fmcp.md",8133,"https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fsnapshot\u002Fcursor-sdk\u002Fskills\u002Fcursor-sdk\u002Freferences\u002Fmcp.md",{"path":66,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":67,"sourceHtmlUrl":68},"references\u002Fpatterns.md",10700,"https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fsnapshot\u002Fcursor-sdk\u002Fskills\u002Fcursor-sdk\u002Freferences\u002Fpatterns.md",{"path":70,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Fruntime-choice.md",7239,"https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fsnapshot\u002Fcursor-sdk\u002Fskills\u002Fcursor-sdk\u002Freferences\u002Fruntime-choice.md",{"path":74,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":75,"sourceHtmlUrl":76},"references\u002Fstreaming.md",8362,"https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fsnapshot\u002Fcursor-sdk\u002Fskills\u002Fcursor-sdk\u002Freferences\u002Fstreaming.md",[78,85,92,99,106,113],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M782GJ4CTPNKZN0WXTASXXZ4","X MCP guide","ALWAYS read this before using any X tool (the X plugin, any X MCP, or Grok Bot's built-in public X reads) and again on any X error. X tools are included in Grok Bot at no cost: never estimate costs, check credits, or tell the user to buy credits. tools=0 \u002F user-X-* not found is a setup failure, not a paywall. Covers Spaces, communities, and Lists (reads and list writes), X Chat (XChat, inbox, DMs, unread, message requests, Chat PIN, juicebox, xchat_lite: clone xchat-grokbot-helper yourself and decrypt locally), scheduled X calls (schedule_call, list_scheduled_calls and the other call tools), and livestreams (stream sources, broadcasts, scheduled broadcasts, broadcast chat, moderators, mutes). Chat, call, livestream, Spaces, or Lists tools missing while other X tools work: reconnect the X plugin.","https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fupstream-tree\u002Fthird_party\u002Fx\u002Fskills\u002Fx-api-mcp-guide\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M782GBW77901ESC9PD3XAM6V","X Money guide","Read this before the first X Money action in a session and again on any X Money error, refusal, or missing capability. Covers the approval rule for every action that moves money (always ask, every time, no exceptions), how the connection works (connection code plus passkey in the X app), how to guide the user through connect, reconnect, and revoke at x.com\u002Fi\u002Fmoney\u002Fsettings\u002Fconnections, and what each failure message means.","https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fupstream-tree\u002Fthird_party\u002Fx-money\u002Fskills\u002Fx-money-guide\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M782G7CMYD2JSVT3RX81QRB8","google-slides","Build and edit Google Slides through the google-slides MCP tools - slides, grids of cards and columns, text boxes, shapes, images, tables, styling, layout inspection, and per-slide PNG rendering. Use when creating a deck, laying out slide elements, matching a template, or verifying how a slide looks.","https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fupstream-tree\u002Fthird_party\u002Fgoogle-slides\u002Fskills\u002Fgoogle-slides\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":19},"01M782G4DDAJ4SMGJEF13HTX69","google-sheets","Build and edit Google Sheets with the google-sheets tools - values, formatting, charts, conditional formatting, structure, validation, named and protected ranges. Use when creating a spreadsheet or dashboard, formatting cells, adding or fixing charts, or reorganizing tabs and rows.","https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fupstream-tree\u002Fthird_party\u002Fgoogle-sheets\u002Fskills\u002Fgoogle-sheets\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":19},"01M782G1F8QNMNKRSY6M3Y0QG6","google-drive","Work with Google Drive through its MCP tools - search, read, create, organize, share, comment, and export files. Use when creating files in specific folders, moving or renaming, converting Markdown\u002FCSV into Docs\u002FSheets, managing comments, or exporting a rendered PDF.","https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fupstream-tree\u002Fthird_party\u002Fgoogle-drive\u002Fskills\u002Fgoogle-drive\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":19},"01M782FYVJ5XTP2R0B446RRYTX","google-docs","Author and edit Google Docs with the google-docs tools - structured writing, character and paragraph styling, lists, tables, images, headers\u002Ffooters. Use when creating a formatted document, editing document content, or applying styles.","https:\u002F\u002Fgithub.com\u002FTheAngryPit\u002FTheAngrySkills\u002Fblob\u002Fmain\u002Fsources\u002Fcursor-plugins\u002Fupstream-tree\u002Fthird_party\u002Fgoogle-docs\u002Fskills\u002Fgoogle-docs\u002FSKILL.md",[],[]]