SKILL.md--- name: cline-sdk description: 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. 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 everything from `@cline/core`, `@cline/agents`, `@cline/llms`, and `@cline/shared`. 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. Return errors as structured data from tool `execute` functions. Throwing counts as a "mistake" against the agent's mistake limit. 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 standalone `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. ## 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 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 -> `