.agents/skills/cline-sdk/references/clinecore/REFERENCE.md
ClineCore is the full-featured runtime from @cline/core. It wraps the Agent loop with session persistence, built-in tools (bash, editor, file reading, search, web fetch), config discovery, plugin loading, and optional hub-backed multi-process support.
| Use ClineCore when... | Use Agent instead when... |
|---|---|
| You need built-in tools (bash, editor, etc.) | You only need custom tools |
| You want session persistence to disk | Stateless is fine |
You need config discovery from .cline/ dirs | You handle config yourself |
| You want scheduled/automated agents | You don't need scheduling |
| You need multi-client session sharing | Single-process is fine |
| You're building a full application | You want minimal dependencies |
import { ClineCore } from "@cline/sdk"
const cline = await ClineCore.create({ clientName: "my-app" })
const session = await cline.start({
prompt: "Set up CI with GitHub Actions",
config: {
providerId: "anthropic",
modelId: "claude-sonnet-4-6",
apiKey: process.env.ANTHROPIC_API_KEY,
cwd: "/path/to/project",
enableTools: true,
},
})
console.log(session.result?.text)
await cline.dispose()
Every cline.start() call creates a session with a unique ID. Sessions persist their messages and metadata to SQLite. You can list, read, resume, and delete sessions.
ClineCore provides these tools automatically when enableTools: true:
| Tool | Description |
|---|---|
bash | Execute shell commands |
editor | Edit files |
read_files | Read file contents |
apply_patch | Apply unified diffs |
search | Search file contents and structure |
fetch_web | HTTP requests and web content |
ClineCore watches .cline/ directories for:
| Mode | Description |
|---|---|
"auto" (default) | Tries to connect to a local hub; falls back to in-process if unavailable |
"local" | In-process execution, local SQLite storage, no hub |
"hub" | Requires a compatible local WebSocket hub; fails if unavailable |
"remote" | Connects to an explicit remote hub endpoint |
The default mode is "auto". For simple scripts and CLI tools, "local" avoids hub discovery overhead. Hub mode enables multi-client session sharing (e.g., a dashboard watching a running session from another process).
ClineCore.create(options) - Create and initializecline.start(input) - Start a new sessioncline.send({ sessionId, prompt }) - Send follow-up messagecline.subscribe(listener) - Listen to session eventscline.list() - List sessionscline.get(sessionId) - Get session metadatacline.readMessages(sessionId) - Read persisted messagescline.getAccumulatedUsage(sessionId) - Token/cost totalscline.abort(sessionId) - Abort a sessioncline.delete(sessionId) - Delete a sessioncline.dispose() - Clean up resourcesSee api.md for full API details.
cline.subscribe() emits CoreSessionEvent types. These are different from the AgentRuntimeEvent types emitted by the standalone Agent class -- see ../events/REFERENCE.md for the full comparison.
cline.subscribe((event) => {
switch (event.type) {
case "chunk":
if (event.payload.type === "text") {
process.stdout.write(event.payload.text)
}
break
case "ended":
console.log(`Session ended: ${event.payload.finishReason}`)
break
}
})
ClineCore results use AgentResult with .text (not .outputText like the standalone Agent's AgentRunResult).
Sessions are stored at:
~/.cline/data/sessions/
sessions.db # SQLite database
[session-id].json # Message history
api.md - Full ClineCore API referencepatterns.md - Common patterns and best practicesgotchas.md - Pitfalls and debugging../tools/REFERENCE.md - Custom tool creation../plugins/REFERENCE.md - Plugin system../scheduling/REFERENCE.md - Scheduled agents