PluginBench
Skill
Pass
Audit score 90

cline-sdk

cline/sdk-skill

Comprehensive SDK for building AI agents with custom tools, plugins, LLM providers, and multi-agent orchestration.

What is cline-sdk?

The Cline SDK provides two main API surfaces—Agent (lightweight, in-memory) and ClineCore (persistent, full-featured)—for building AI agents. Use it when you need to create agents with custom tools, integrate LLM providers, add plugins/hooks, handle events, schedule recurring tasks, or coordinate multi-agent teams.

  • Build agents with the lightweight Agent class or full-featured ClineCore runtime
  • Create custom tools with schema validation and tool approval policies
  • Configure multiple LLM providers (Anthropic, OpenAI, Google, AWS Bedrock, Mistral, custom)
  • Add plugins and hooks for lifecycle events, tool observation, and system prompt rules
  • Stream events in real time: text deltas, reasoning, tool calls, token usage, and completion status
  • Schedule recurring agents and automate tasks with ClineCore

How to install cline-sdk

npx skills add https://github.com/cline/sdk-skill --skill cline-sdk
Prerequisites
  • Node.js 22 or later
  • npm or yarn for package installation
  • Basic understanding of async/await and TypeScript (recommended)
Claude Code
Cursor
Windsurf
Cline

How to use cline-sdk

  1. 1.Install with `npm install @cline/sdk`
  2. 2.Choose your API surface: read `references/agent/REFERENCE.md` for lightweight agents or `references/clinecore/REFERENCE.md` for full runtime
  3. 3.Define custom tools using `createTool()` from `@cline/sdk` with snake_case names
  4. 4.Configure your LLM provider via `providers/REFERENCE.md`
  5. 5.Subscribe to events with `agent.subscribe()` or `cline.subscribe()` to stream text, reasoning, and tool activity
  6. 6.Add plugins/hooks for lifecycle observation and system prompt rules via `plugins/REFERENCE.md`
  7. 7.For multi-agent workflows, read `multi-agent/REFERENCE.md` and use sub-agent delegation or configured agent profiles
  8. 8.Call `dispose()` on ClineCore when done to clean up resources

Use cases

Good for
  • Build a lightweight chatbot with custom tools using the Agent class
  • Create a persistent automation agent with file/shell/search/web tools via ClineCore
  • Integrate multiple LLM providers and switch between them based on task requirements
  • Develop a plugin that bundles tools, hooks, and system prompt rules for distribution
  • Set up scheduled agents to run recurring tasks on a cron-like schedule
Who it's for
  • Backend engineers building AI agent infrastructure
  • Full-stack developers integrating agents into applications
  • DevOps/platform teams deploying agents at scale
  • Plugin/extension developers packaging reusable agent capabilities
  • Teams building multi-agent systems or automation platforms

cline-sdk FAQ

What's the difference between Agent and ClineCore?

Agent is a lightweight, in-memory API for simple agents with custom tools. ClineCore is a full-featured runtime with session persistence, built-in tools (file/shell/search/web), config discovery, scheduling, and multi-agent support. Choose Agent for simplicity; choose ClineCore for production features.

How do I create a custom tool?

Use `createTool()` from `@cline/sdk` with a snake_case name, JSON schema for parameters, and an `execute()` function. Return structured error data for recoverable failures. Set `lifecycle: { completesRun: true }` if the tool should end the agent loop.

How do I stream agent output to a UI?

For Agent, use `agent.subscribe()` to listen for `AgentRuntimeEvent` types; text streaming is `"assistant-text-delta"`. For ClineCore, use `cline.subscribe()` to listen for `CoreSessionEvent` types; render text from `"agent_event"` payloads with `content_start`, `content_update`, `content_end`, and `done` fields.

Can I use multiple LLM providers?

Yes. Configure providers via `providers/REFERENCE.md` for Anthropic, OpenAI, Google, AWS Bedrock, Mistral, or custom/self-hosted endpoints. Pass your chosen provider config to the Agent or ClineCore constructor.

How do I build a multi-agent system?

Use `multi-agent/REFERENCE.md`. For one-off delegation, spawn sub-agents dynamically. For predefined teams, define agent profiles as YAML files in `.cline/agents/` and enable `enableSpawnAgent`. Use hooks to coordinate parent-child workflows.

Full instructions (SKILL.md)

Source of truth, from cline/sdk-skill.


name: cline-sdk description: 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. metadata: references: agent, clinecore

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:

  1. 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.
  2. Requires Node.js 22 or later.
  3. Use createTool() from @cline/sdk (or @cline/shared) to define tools. Tool names must be snake_case.
  4. 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.
  5. Use lifecycle: { completesRun: true } on tools that should end the agent loop (e.g. a "submit answer" tool).
  6. When using ClineCore, always call dispose() when done to clean up resources.
  7. 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.
  8. 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.
  9. 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:

FilePurposeWhen to Read
REFERENCE.mdOverview, when to use, quick startAlways read first
api.mdFull API: classes, methods, config, typesWriting code
patterns.mdCommon patterns, best practicesImplementation guidance
gotchas.mdPitfalls, limitations, debuggingTroubleshooting

Cross-cutting concepts in ./references/<concept>/ have REFERENCE.md as the entry point.

Reading Order

  1. Start with REFERENCE.md for your chosen API surface
  2. 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

APIEntry FileDescription
Agent./references/agent/REFERENCE.mdLightweight in-memory agent loop
ClineCore./references/clinecore/REFERENCE.mdFull runtime with sessions, persistence, built-in tools

Cross-Cutting Concepts

ConceptEntry FileDescription
Tools./references/tools/REFERENCE.mdBuilt-in and custom tool creation
Plugins./references/plugins/REFERENCE.mdExtension system with hooks, MCP servers, and bundled skills
Events./references/events/REFERENCE.mdReal-time streaming events
Providers./references/providers/REFERENCE.mdLLM provider configuration
Production./references/production/REFERENCE.mdDeployment, security, observability
Scheduling./references/scheduling/REFERENCE.mdCron jobs and automation
Multi-Agent./references/multi-agent/REFERENCE.mdTeams, sub-agents, and configured agent profiles

Package Map

PackagePurpose
@cline/sdkUser-facing alias for @cline/core; install this first
@cline/coreSessions, persistence, built-in tools, config, hub, and selected re-exports
@cline/agentsBrowser-compatible AgentRuntime class and lower-level factories
@cline/llmsLLM provider gateway
@cline/sharedTypes, 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