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/sdk package re-exports @cline/core, not every sub-package directly. Core re-exports the public SDK surface such as ClineCore, Agent, createAgentRuntime, createTool, built-in tool helpers, provider helpers, and the Llms namespace. Import from @cline/agents, @cline/llms, or @cline/shared only when you need APIs that core does not re-export, such as AgentRuntime, 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 be snake_case.
- Prefer returning structured error data from tool
execute functions when the agent can recover. Direct Agent converts 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 call dispose() when done to clean up resources.
- The direct
Agent and ClineCore have different event systems. For Agent: use agent.subscribe() to get AgentRuntimeEvent types, text streaming is "assistant-text-delta", and result text is result.outputText. For ClineCore: use cline.subscribe() to get CoreSessionEvent types. 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. ClineCore result text is result.text. There is no top-level onEvent field on AgentRuntimeConfig; use agent.subscribe() or hooks.onEvent instead. Do not use "content_update" or "content_start" with agent.subscribe(); those are host-facing AgentEvent types carried inside ClineCore agent_event events.
- For direct
Agent, plugins are simple runtime plugins with setup(context) returning { tools, hooks }. For ClineCore, extensions are AgentPlugin objects with manifest, setup(api, ctx), and optional hooks. Do not use ClineCore plugin examples inside direct Agent.plugins.
- Plugin skills are file-based, not registered. There is no
registerSkill() and no api.registerSkill. A plugin ships skills as SKILL.md files under <package>/skills/<name>/SKILL.md (package shape required); the host discovers them and surfaces them as /slash-commands automatically -- do not call registerCommand for skills. Plugin MCP servers use api.registerMcpServer() with the "mcp" capability. Configured agents (agent profiles) are YAML files in .cline/agents/ loaded as subagent_<name> tools when enableSpawnAgent is true.
How to Use This Skill
Reference File Structure
The two main API surfaces (Agent and ClineCore) follow a 4-file pattern. Cross-cutting concepts are single-file guides.
Each main API surface in ./references/<api>/ contains:
| File |
Purpose |
When to Read |
REFERENCE.md |
Overview, when to use, quick start |
Always read first |
api.md |
Full API: classes, methods, config, types |
Writing code |
patterns.md |
Common patterns, best practices |
Implementation guidance |
gotchas.md |
Pitfalls, limitations, debugging |
Troubleshooting |
Cross-cutting concepts in ./references/<concept>/ have REFERENCE.md as the entry point.
Reading Order
- Start with
REFERENCE.md for your chosen API surface
- Then read additional files relevant to your task:
- Writing agent code ->
api.md
- Common patterns ->
patterns.md
- Creating tools ->
tools/REFERENCE.md
- Adding plugins/hooks ->
plugins/REFERENCE.md
- Configuring LLM providers ->
providers/REFERENCE.md
- Streaming events ->
events/REFERENCE.md
- Deploying to production ->
production/REFERENCE.md
- Scheduling agents ->
scheduling/REFERENCE.md
- Multi-agent orchestration ->
multi-agent/REFERENCE.md
- Debugging ->
gotchas.md
Example Paths
./references/agent/REFERENCE.md # Start here for lightweight agents
./references/clinecore/REFERENCE.md # Start here for full runtime
./references/agent/api.md # Agent class, config, methods
./references/tools/REFERENCE.md # Creating and using tools
./references/plugins/REFERENCE.md # Plugin system
./references/providers/REFERENCE.md # LLM provider configuration
Quick Decision Trees
"Which API surface should I use?"
Which API?
+-- I want a simple, in-memory agent with custom tools
| +-- agent/ (Agent class from @cline/agents, re-exported by @cline/sdk)
+-- I need session persistence, built-in tools, config discovery
| +-- clinecore/ (ClineCore from @cline/core)
+-- I want built-in file/shell/search/web tools
| +-- clinecore/ (has built-in tools; Agent does not)
+-- I want scheduled or recurring agents
| +-- clinecore/ (automation API)
+-- I need multi-process or multi-client session sharing
| +-- clinecore/ (hub-backed runtime)
+-- I'm building a browser-compatible agent
| +-- agent/ (no Node.js dependencies)
"I need to create tools"
Tools?
+-- Define a custom tool with schema -> tools/REFERENCE.md
+-- Use built-in tools (read_files, search_codebase, run_commands, etc.) -> tools/REFERENCE.md (built-in section)
+-- Control tool approval/policies -> tools/REFERENCE.md (policies section)
+-- Tool that ends the agent loop -> tools/REFERENCE.md (completion tools)
+-- Package tools as a reusable plugin -> plugins/REFERENCE.md
"I need to handle events"
Events?
+-- Stream text/reasoning in real time -> events/REFERENCE.md
+-- Track token usage and costs -> events/REFERENCE.md
+-- Watch tool calls -> events/REFERENCE.md
+-- Detect completion/errors -> events/REFERENCE.md
+-- Hook into lifecycle stages -> plugins/REFERENCE.md
"I need to configure a model provider"
Providers?
+-- Anthropic (Claude) -> providers/REFERENCE.md
+-- OpenAI (GPT) -> providers/REFERENCE.md
+-- Google (Gemini/Vertex) -> providers/REFERENCE.md
+-- AWS Bedrock -> providers/REFERENCE.md
+-- Mistral -> providers/REFERENCE.md
+-- OpenAI-compatible (vLLM, Together, etc.) -> providers/REFERENCE.md
+-- Custom/self-hosted provider -> providers/REFERENCE.md
"I need plugins or hooks"
Plugins?
+-- Package tools + hooks together -> plugins/REFERENCE.md
+-- Observe tool calls (logging, metrics) -> plugins/REFERENCE.md
+-- Intercept lifecycle events -> plugins/REFERENCE.md
+-- Add system prompt rules -> plugins/REFERENCE.md
+-- Expose an MCP server's tools -> plugins/REFERENCE.md (MCP servers)
+-- Bundle reusable skills (SKILL.md, auto slash commands) -> plugins/REFERENCE.md (bundled skills)
+-- Distribute via npm/git -> plugins/REFERENCE.md
"I need multi-agent coordination"
Multi-agent?
+-- Run one-off delegated sub-agents -> multi-agent/REFERENCE.md (sub-agents)
+-- Predefined named sub-agents from files -> multi-agent/REFERENCE.md (configured agents)
+-- Persistent cross-session teams -> multi-agent/REFERENCE.md (teams)
+-- Parent-child delegation -> multi-agent/REFERENCE.md (sub-agents)
+-- Peer-to-peer task board -> multi-agent/REFERENCE.md (teams)
"I need scheduling or automation"
Scheduling?
+-- Recurring cron jobs -> scheduling/REFERENCE.md
+-- One-off scheduled tasks -> scheduling/REFERENCE.md
+-- Event-driven triggers -> scheduling/REFERENCE.md
+-- CLI schedule management -> scheduling/REFERENCE.md
"I need to go to production"
Production?
+-- Error handling and status checks -> production/REFERENCE.md
+-- Cost control and token limits -> production/REFERENCE.md
+-- Observability (OpenTelemetry) -> production/REFERENCE.md
+-- Security and sandboxing -> production/REFERENCE.md
+-- Deployment patterns -> production/REFERENCE.md
Troubleshooting Index
- Agent loop not stopping ->
tools/REFERENCE.md (completion tools)
- Tool errors crashing the agent ->
agent/gotchas.md or clinecore/gotchas.md
- Provider auth failures ->
providers/REFERENCE.md
- Session not persisting ->
clinecore/gotchas.md
- Token usage too high ->
production/REFERENCE.md (cost control)
- Hub connection issues ->
clinecore/gotchas.md
- Plugin not loading ->
plugins/REFERENCE.md
- Events not firing ->
events/REFERENCE.md
Product Index
API Surfaces
| API |
Entry File |
Description |
| Agent |
./references/agent/REFERENCE.md |
Lightweight in-memory agent loop |
| ClineCore |
./references/clinecore/REFERENCE.md |
Full runtime with sessions, persistence, built-in tools |
Cross-Cutting Concepts
| Concept |
Entry File |
Description |
| Tools |
./references/tools/REFERENCE.md |
Built-in and custom tool creation |
| Plugins |
./references/plugins/REFERENCE.md |
Extension system with hooks, MCP servers, and bundled skills |
| Events |
./references/events/REFERENCE.md |
Real-time streaming events |
| Providers |
./references/providers/REFERENCE.md |
LLM provider configuration |
| Production |
./references/production/REFERENCE.md |
Deployment, security, observability |
| Scheduling |
./references/scheduling/REFERENCE.md |
Cron jobs and automation |
| Multi-Agent |
./references/multi-agent/REFERENCE.md |
Teams, sub-agents, and configured agent profiles |
Package Map
| Package |
Purpose |
@cline/sdk |
User-facing alias for @cline/core; install this first |
@cline/core |
Sessions, persistence, built-in tools, config, hub, and selected re-exports |
@cline/agents |
Browser-compatible AgentRuntime class and lower-level factories |
@cline/llms |
LLM provider gateway |
@cline/shared |
Types, tool helpers, hook engine |
Resources
Repository: https://github.com/cline/cline
SDK Source: https://github.com/cline/cline/tree/main/sdk
Documentation: https://docs.cline.bot/sdk/overview
Discord: https://discord.gg/cline
1---2name: cline-sdk3description: Comprehensive Cline SDK skill for building AI agents. Covers the direct Agent runtime, ClineCore sessions, custom tools, plugins, events, LLM providers, scheduling, multi-agent teams, and production deployment. Use for any task involving @cline/sdk or its sub-packages.4---5
6# Cline SDK Skill
7
8Consolidated 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.
9
10## Critical Rules
11
12Follow these rules in all Cline SDK code:
13
141. Install with `npm install @cline/sdk`. The `@cline/sdk` package re-exports `@cline/core`, not every sub-package directly. Core re-exports the public SDK surface such as `ClineCore`, `Agent`, `createAgentRuntime`, `createTool`, built-in tool helpers, provider helpers, and the `Llms` namespace. Import from `@cline/agents`, `@cline/llms`, or `@cline/shared` only when you need APIs that core does not re-export, such as `AgentRuntime`, `createAgent`, or some low-level types.
152. Requires Node.js 22 or later.
163. Use `createTool()` from `@cline/sdk` (or `@cline/shared`) to define tools. Tool names must be `snake_case`.
174. Prefer returning structured error data from tool `execute` functions when the agent can recover. Direct `Agent` converts thrown tool errors into error tool results; ClineCore can also count repeated failed tool turns toward its mistake-limit handling.
185. Use `lifecycle: { completesRun: true }` on tools that should end the agent loop (e.g. a "submit answer" tool).
196. When using `ClineCore`, always call `dispose()` when done to clean up resources.
207. The direct `Agent` and `ClineCore` have different event systems. For `Agent`: use `agent.subscribe()` to get `AgentRuntimeEvent` types, text streaming is `"assistant-text-delta"`, and result text is `result.outputText`. For `ClineCore`: use `cline.subscribe()` to get `CoreSessionEvent` types. 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. `ClineCore` result text is `result.text`. There is no top-level `onEvent` field on `AgentRuntimeConfig`; use `agent.subscribe()` or `hooks.onEvent` instead. Do not use `"content_update"` or `"content_start"` with `agent.subscribe()`; those are host-facing `AgentEvent` types carried inside ClineCore `agent_event` events.
218. For direct `Agent`, `plugins` are simple runtime plugins with `setup(context)` returning `{ tools, hooks }`. For `ClineCore`, `extensions` are `AgentPlugin` objects with `manifest`, `setup(api, ctx)`, and optional `hooks`. Do not use ClineCore plugin examples inside direct `Agent.plugins`.
229. Plugin skills are **file-based**, not registered. There is no `registerSkill()` and no `api.registerSkill`. A plugin ships skills as `SKILL.md` files under `<package>/skills/<name>/SKILL.md` (package shape required); the host discovers them and surfaces them as `/slash-commands` automatically -- do not call `registerCommand` for skills. Plugin MCP servers use `api.registerMcpServer()` with the `"mcp"` capability. Configured agents (agent profiles) are YAML files in `.cline/agents/` loaded as `subagent_<name>` tools when `enableSpawnAgent` is true.
23
24## How to Use This Skill
25
26### Reference File Structure
27
28The two main API surfaces (`Agent` and `ClineCore`) follow a 4-file pattern. Cross-cutting concepts are single-file guides.
29
30Each main API surface in `./references/<api>/` contains:
31
32| File | Purpose | When to Read |
33|------|---------|--------------|
34| `REFERENCE.md` | Overview, when to use, quick start | Always read first |
35| `api.md` | Full API: classes, methods, config, types | Writing code |
36| `patterns.md` | Common patterns, best practices | Implementation guidance |
37| `gotchas.md` | Pitfalls, limitations, debugging | Troubleshooting |
38
39Cross-cutting concepts in `./references/<concept>/` have `REFERENCE.md` as the entry point.
40
41### Reading Order
42
431. Start with `REFERENCE.md` for your chosen API surface
442. Then read additional files relevant to your task:
45 - Writing agent code -> `api.md`
46 - Common patterns -> `patterns.md`
47 - Creating tools -> `tools/REFERENCE.md`
48 - Adding plugins/hooks -> `plugins/REFERENCE.md`
49 - Configuring LLM providers -> `providers/REFERENCE.md`
50 - Streaming events -> `events/REFERENCE.md`
51 - Deploying to production -> `production/REFERENCE.md`
52 - Scheduling agents -> `scheduling/REFERENCE.md`
53 - Multi-agent orchestration -> `multi-agent/REFERENCE.md`
54 - Debugging -> `gotchas.md`
55
56### Example Paths
57
58```
59./references/agent/REFERENCE.md # Start here for lightweight agents
60./references/clinecore/REFERENCE.md # Start here for full runtime
61./references/agent/api.md # Agent class, config, methods
62./references/tools/REFERENCE.md # Creating and using tools
63./references/plugins/REFERENCE.md # Plugin system
64./references/providers/REFERENCE.md # LLM provider configuration
65```
66
67## Quick Decision Trees
68
69### "Which API surface should I use?"
70
71```
72Which API?
73+-- I want a simple, in-memory agent with custom tools
74| +-- agent/ (Agent class from @cline/agents, re-exported by @cline/sdk)
75+-- I need session persistence, built-in tools, config discovery
76| +-- clinecore/ (ClineCore from @cline/core)
77+-- I want built-in file/shell/search/web tools
78| +-- clinecore/ (has built-in tools; Agent does not)
79+-- I want scheduled or recurring agents
80| +-- clinecore/ (automation API)
81+-- I need multi-process or multi-client session sharing
82| +-- clinecore/ (hub-backed runtime)
83+-- I'm building a browser-compatible agent
84| +-- agent/ (no Node.js dependencies)
85```
86
87### "I need to create tools"
88
89```
90Tools?
91+-- Define a custom tool with schema -> tools/REFERENCE.md
92+-- Use built-in tools (read_files, search_codebase, run_commands, etc.) -> tools/REFERENCE.md (built-in section)
93+-- Control tool approval/policies -> tools/REFERENCE.md (policies section)
94+-- Tool that ends the agent loop -> tools/REFERENCE.md (completion tools)
95+-- Package tools as a reusable plugin -> plugins/REFERENCE.md
96```
97
98### "I need to handle events"
99
100```
101Events?
102+-- Stream text/reasoning in real time -> events/REFERENCE.md
103+-- Track token usage and costs -> events/REFERENCE.md
104+-- Watch tool calls -> events/REFERENCE.md
105+-- Detect completion/errors -> events/REFERENCE.md
106+-- Hook into lifecycle stages -> plugins/REFERENCE.md
107```
108
109### "I need to configure a model provider"
110
111```
112Providers?
113+-- Anthropic (Claude) -> providers/REFERENCE.md
114+-- OpenAI (GPT) -> providers/REFERENCE.md
115+-- Google (Gemini/Vertex) -> providers/REFERENCE.md
116+-- AWS Bedrock -> providers/REFERENCE.md
117+-- Mistral -> providers/REFERENCE.md
118+-- OpenAI-compatible (vLLM, Together, etc.) -> providers/REFERENCE.md
119+-- Custom/self-hosted provider -> providers/REFERENCE.md
120```
121
122### "I need plugins or hooks"
123
124```
125Plugins?
126+-- Package tools + hooks together -> plugins/REFERENCE.md
127+-- Observe tool calls (logging, metrics) -> plugins/REFERENCE.md
128+-- Intercept lifecycle events -> plugins/REFERENCE.md
129+-- Add system prompt rules -> plugins/REFERENCE.md
130+-- Expose an MCP server's tools -> plugins/REFERENCE.md (MCP servers)
131+-- Bundle reusable skills (SKILL.md, auto slash commands) -> plugins/REFERENCE.md (bundled skills)
132+-- Distribute via npm/git -> plugins/REFERENCE.md
133```
134
135### "I need multi-agent coordination"
136
137```
138Multi-agent?
139+-- Run one-off delegated sub-agents -> multi-agent/REFERENCE.md (sub-agents)
140+-- Predefined named sub-agents from files -> multi-agent/REFERENCE.md (configured agents)
141+-- Persistent cross-session teams -> multi-agent/REFERENCE.md (teams)
142+-- Parent-child delegation -> multi-agent/REFERENCE.md (sub-agents)
143+-- Peer-to-peer task board -> multi-agent/REFERENCE.md (teams)
144```
145
146### "I need scheduling or automation"
147
148```
149Scheduling?
150+-- Recurring cron jobs -> scheduling/REFERENCE.md
151+-- One-off scheduled tasks -> scheduling/REFERENCE.md
152+-- Event-driven triggers -> scheduling/REFERENCE.md
153+-- CLI schedule management -> scheduling/REFERENCE.md
154```
155
156### "I need to go to production"
157
158```
159Production?
160+-- Error handling and status checks -> production/REFERENCE.md
161+-- Cost control and token limits -> production/REFERENCE.md
162+-- Observability (OpenTelemetry) -> production/REFERENCE.md
163+-- Security and sandboxing -> production/REFERENCE.md
164+-- Deployment patterns -> production/REFERENCE.md
165```
166
167### Troubleshooting Index
168
169- Agent loop not stopping -> `tools/REFERENCE.md` (completion tools)
170- Tool errors crashing the agent -> `agent/gotchas.md` or `clinecore/gotchas.md`
171- Provider auth failures -> `providers/REFERENCE.md`
172- Session not persisting -> `clinecore/gotchas.md`
173- Token usage too high -> `production/REFERENCE.md` (cost control)
174- Hub connection issues -> `clinecore/gotchas.md`
175- Plugin not loading -> `plugins/REFERENCE.md`
176- Events not firing -> `events/REFERENCE.md`
177
178## Product Index
179
180### API Surfaces
181| API | Entry File | Description |
182|-----|------------|-------------|
183| Agent | `./references/agent/REFERENCE.md` | Lightweight in-memory agent loop |
184| ClineCore | `./references/clinecore/REFERENCE.md` | Full runtime with sessions, persistence, built-in tools |
185
186### Cross-Cutting Concepts
187| Concept | Entry File | Description |
188|---------|------------|-------------|
189| Tools | `./references/tools/REFERENCE.md` | Built-in and custom tool creation |
190| Plugins | `./references/plugins/REFERENCE.md` | Extension system with hooks, MCP servers, and bundled skills |
191| Events | `./references/events/REFERENCE.md` | Real-time streaming events |
192| Providers | `./references/providers/REFERENCE.md` | LLM provider configuration |
193| Production | `./references/production/REFERENCE.md` | Deployment, security, observability |
194| Scheduling | `./references/scheduling/REFERENCE.md` | Cron jobs and automation |
195| Multi-Agent | `./references/multi-agent/REFERENCE.md` | Teams, sub-agents, and configured agent profiles |
196
197### Package Map
198| Package | Purpose |
199|---------|---------|
200| `@cline/sdk` | User-facing alias for `@cline/core`; install this first |
201| `@cline/core` | Sessions, persistence, built-in tools, config, hub, and selected re-exports |
202| `@cline/agents` | Browser-compatible AgentRuntime class and lower-level factories |
203| `@cline/llms` | LLM provider gateway |
204| `@cline/shared` | Types, tool helpers, hook engine |
205
206## Resources
207
208Repository: https://github.com/cline/cline
209SDK Source: https://github.com/cline/cline/tree/main/sdk
210Documentation: https://docs.cline.bot/sdk/overview
211Discord: https://discord.gg/cline