cline-sdk
Original:🇺🇸 English
Translated
Comprehensive Cline SDK skill for building AI agents. Covers the 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.
4installs
Sourcecline/sdk-skill
Added on
NPX Install
npx skill4agent add cline/sdk-skill cline-sdkTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →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 . The
npm install @cline/sdkpackage re-exports everything from@cline/sdk,@cline/core,@cline/agents, and@cline/llms.@cline/shared - Requires Node.js 22 or later.
- Use from
createTool()(or@cline/sdk) to define tools. Tool names must be@cline/shared.snake_case - Return errors as structured data from tool functions. Throwing counts as a "mistake" against the agent's mistake limit.
execute - Use on tools that should end the agent loop (e.g. a "submit answer" tool).
lifecycle: { completesRun: true } - When using , always call
ClineCorewhen done to clean up resources.dispose() - The standalone and
Agenthave different event systems. ForClineCore: useAgentto getagent.subscribe()types (text streaming isAgentRuntimeEvent, result text is"assistant-text-delta"). Forresult.outputText: useClineCoreto getcline.subscribe()types (text streaming isCoreSessionEventwith"chunk", result text ispayload.type === "text"). There is no top-levelresult.textfield ononEvent-- useAgentRuntimeConfigoragent.subscribe()instead. Do not use event types likehooks.onEventor"content_update"with"content_start"-- those are internal legacy types from the ClineCore adapter layer.agent.subscribe()
How to Use This Skill
Reference File Structure
The two main API surfaces ( and ) follow a 4-file pattern. Cross-cutting concepts are single-file guides.
AgentClineCoreEach main API surface in contains:
./references/<api>/| File | Purpose | When to Read |
|---|---|---|
| Overview, when to use, quick start | Always read first |
| Full API: classes, methods, config, types | Writing code |
| Common patterns, best practices | Implementation guidance |
| Pitfalls, limitations, debugging | Troubleshooting |
Cross-cutting concepts in have as the entry point.
./references/<concept>/REFERENCE.mdReading Order
- Start with for your chosen API surface
REFERENCE.md - 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
- Writing agent code ->
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 configurationQuick Decision Trees
"Which API surface should I use?"
Which API?
+-- I want a simple, stateless agent with custom tools
| +-- agent/ (Agent class from @cline/agents)
+-- 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 (bash, editor, read_files) -> 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
+-- Distribute via npm/git -> plugins/REFERENCE.md"I need multi-agent coordination"
Multi-agent?
+-- Spawn one-off background agents -> multi-agent/REFERENCE.md (sub-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.mdTroubleshooting Index
- Agent loop not stopping -> (completion tools)
tools/REFERENCE.md - Tool errors crashing the agent -> or
agent/gotchas.mdclinecore/gotchas.md - Provider auth failures ->
providers/REFERENCE.md - Session not persisting ->
clinecore/gotchas.md - Token usage too high -> (cost control)
production/REFERENCE.md - 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 | | Lightweight stateless agent loop |
| ClineCore | | Full runtime with sessions, persistence, built-in tools |
Cross-Cutting Concepts
| Concept | Entry File | Description |
|---|---|---|
| Tools | | Built-in and custom tool creation |
| Plugins | | Extension system with hooks |
| Events | | Real-time streaming events |
| Providers | | LLM provider configuration |
| Production | | Deployment, security, observability |
| Scheduling | | Cron jobs and automation |
| Multi-Agent | | Teams and sub-agents |
Package Map
| Package | Purpose |
|---|---|
| Everything you need, install this one |
| Sessions, persistence, built-in tools, config, hub |
| Stateless agent loop, tool orchestration, streaming |
| LLM provider gateway |
| 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