cline-sdk
Installation
SKILL.md
Cline SDK Skill
Consolidated skill for building AI agents with the Cline SDK. Use the decision trees below to find the right entry point and API surface, then load detailed references.
Critical Rules
Follow these rules in all Cline SDK code:
- Install with
npm install @cline/sdk. The@cline/sdkpackage re-exports@cline/core, not every sub-package directly. Core re-exports the public SDK surface such asClineCore,Agent,createAgentRuntime,createTool, built-in tool helpers, provider helpers, and theLlmsnamespace. Import from@cline/agents,@cline/llms, or@cline/sharedonly when you need APIs that core does not re-export, such asAgentRuntime,createAgent, or some low-level types. - Requires Node.js 22 or later.
- Use
createTool()from@cline/sdk(or@cline/shared) to define tools. Tool names must besnake_case. - Prefer returning structured error data from tool
executefunctions when the agent can recover. DirectAgentconverts thrown tool errors into error tool results; ClineCore can also count repeated failed tool turns toward its mistake-limit handling. - Use
lifecycle: { completesRun: true }on tools that should end the agent loop (e.g. a "submit answer" tool). - When using
ClineCore, always calldispose()when done to clean up resources. - The direct
AgentandClineCorehave different event systems. ForAgent: useagent.subscribe()to getAgentRuntimeEventtypes, text streaming is"assistant-text-delta", and result text isresult.outputText. ForClineCore: usecline.subscribe()to getCoreSessionEventtypes. Render user-facing text, reasoning, and tool activity from"agent_event"payloads (content_start,content_update,content_end,done). Treat"chunk"events as raw transport chunks with{ stream, chunk, ts }, not as typed text deltas.ClineCoreresult text isresult.text. There is no top-levelonEventfield onAgentRuntimeConfig; useagent.subscribe()orhooks.onEventinstead. Do not use"content_update"or"content_start"withagent.subscribe(); those are host-facingAgentEventtypes carried inside ClineCoreagent_eventevents. - For direct
Agent,pluginsare simple runtime plugins withsetup(context)returning{ tools, hooks }. ForClineCore,extensionsareAgentPluginobjects withmanifest,setup(api, ctx), and optionalhooks. Do not use ClineCore plugin examples inside directAgent.plugins. - Plugin skills are file-based, not registered. There is no
registerSkill()and noapi.registerSkill. A plugin ships skills asSKILL.mdfiles under<package>/skills/<name>/SKILL.md(package shape required); the host discovers them and surfaces them as/slash-commandsautomatically -- do not callregisterCommandfor skills. Plugin MCP servers useapi.registerMcpServer()with the"mcp"capability. Configured agents (agent profiles) are YAML files in.cline/agents/loaded assubagent_<name>tools whenenableSpawnAgentis true.