.agents/skills/cline-sdk/SKILL.md
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.
Follow these rules in all Cline SDK code:
npm install @cline/sdk. The @cline/sdk package re-exports everything from @cline/core, @cline/agents, @cline/llms, and @cline/shared.createTool() from @cline/sdk (or @cline/shared) to define tools. Tool names must be snake_case.execute functions. Throwing counts as a "mistake" against the agent's mistake limit.lifecycle: { completesRun: true } on tools that should end the agent loop (e.g. a "submit answer" tool).ClineCore, always call dispose() when done to clean up resources.Agent and ClineCore have different event systems. For Agent: use agent.subscribe() to get AgentRuntimeEvent types (text streaming is "assistant-text-delta", result text is result.outputText). For ClineCore: use cline.subscribe() to get CoreSessionEvent types (text streaming is "chunk" with payload.type === "text", result text is result.text). There is no top-level onEvent field on AgentRuntimeConfig -- use agent.subscribe() or hooks.onEvent instead. Do not use event types like "content_update" or "content_start" with agent.subscribe() -- those are internal legacy types from the ClineCore adapter layer.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.
REFERENCE.md for your chosen API surfaceapi.mdpatterns.mdtools/REFERENCE.mdplugins/REFERENCE.mdproviders/REFERENCE.mdevents/REFERENCE.mdproduction/REFERENCE.mdscheduling/REFERENCE.mdmulti-agent/REFERENCE.mdgotchas.md./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
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)
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
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
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
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
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)
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
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
tools/REFERENCE.md (completion tools)agent/gotchas.md or clinecore/gotchas.mdproviders/REFERENCE.mdclinecore/gotchas.mdproduction/REFERENCE.md (cost control)clinecore/gotchas.mdplugins/REFERENCE.mdevents/REFERENCE.md| API | Entry File | Description |
|---|---|---|
| Agent | ./references/agent/REFERENCE.md | Lightweight stateless agent loop |
| ClineCore | ./references/clinecore/REFERENCE.md | Full runtime with sessions, persistence, built-in tools |
| Concept | Entry File | Description |
|---|---|---|
| Tools | ./references/tools/REFERENCE.md | Built-in and custom tool creation |
| Plugins | ./references/plugins/REFERENCE.md | Extension system with hooks |
| 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 and sub-agents |
| Package | Purpose |
|---|---|
@cline/sdk | Everything you need, install this one |
@cline/core | Sessions, persistence, built-in tools, config, hub |
@cline/agents | Stateless agent loop, tool orchestration, streaming |
@cline/llms | LLM provider gateway |
@cline/shared | Types, tool helpers, hook engine |
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