Cline explained: one coding agent across several interfaces
Cline architecture: CLI routing, runtime host and session lifecycle
Follow startup configuration into ClineCore without attributing every integration behavior to one class.
What you will learn
- Resolve configuration before services
- Inspect the core factory
- Track cleanup and evidence separately
Before you start
- Basic terminal and Git knowledge
- Disposable repository without secrets
A learning project separates streamed events, tool actions and verified repository outcomes.
Key takeaways
- Startup storage selection happens early.
- Automation is an optional factory configuration.
- Session cleanup does not reverse external actions.
Resolve configuration before services
runCli scans --config before general command parsing and applies it before capturing activation telemetry. The purpose is to keep early storage under the selected configuration directory instead of the default location.
The CLI then routes subcommands and lazily loads runtime modules. Command parsing, account resolution and actual agent execution are distinct layers; a failure in one should not immediately be blamed on the model.
Inspect the core factory
ClineCore.create normalizes capabilities, obtains a runtime host and constructs the core. Automation is optional; if enabled and not configured with autoStart false, the factory starts it. This is a specific factory branch, not a claim that every CLI session schedules work.
The core exposes settings and pending prompts through host-backed APIs. Its start path prepares input, normalizes session settings and calls host.startSession. Integration code therefore needs to own both startup and session lifecycle.
Track cleanup and evidence separately
The inspected constructor subscribes to ended events and disposes any stored session bootstrap. That cleanup path addresses preparation resources; it does not undo edits or external actions performed by tools.
Use separate records for transport status, agent completion, workspace changes and application tests. This architecture review does not execute the host, inspect every provider adapter or prove the same behavior in all desktop integrations.
Decision guide
| Criterion | Option A | Option B |
|---|---|---|
| Best when | You need predictable behavior and easy auditing | You need adaptive optimization and have reliable telemetry |
| Main risk | May leave performance on the table | Can become difficult to explain or debug |
Implementation steps
- 1
Trace early configuration selection.
- 2
Follow core creation into host.startSession.
- 3
Separate resource cleanup from action rollback.
Copy-ready example
CLI arguments -> configuration root -> command routing
ClineCore.create -> runtime host -> startSession
ended event -> bootstrap cleanupFrequently asked questions
Does creating ClineCore always start a scheduler?
Only when automation options enable it and autoStart is not false in the inspected factory.
Were all provider adapters audited?
No. The review covers named startup and core lifecycle paths.
Sources
- Cline / apps/cli/src/main.tsSource checked 2026-09-23
- Cline / sdk/packages/core/src/ClineCore.tsSource checked 2026-09-23