Cline explained: one coding agent across several interfaces
Reading Cline startup code: the two-pass --config parser
Reproduce eight argument cases and understand why configuration is selected before telemetry.
What you will learn
- Find the early parser
- What the offline test actually runs
- Use the result in diagnosis
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
- The early scan returns the first matching value.
- Eight tests cover parsing only.
- Configuration mismatch can resemble missing credentials.
Find the early parser
resolveConfigDirArg scans arguments for --config followed by a value or --config=value. It trims whitespace and returns the first matching occurrence. Similar names such as --configure are ignored.
This lightweight pass runs before the general Commander parser because configuration-dependent services may initialize early. runCli applies setClineDir before activation telemetry; the authentication action also reapplies a parsed configuration value defensively.
What the offline test actually runs
The local fixture extracts this function from the fixed main.ts capture, removes its TypeScript annotations and executes it in an isolated JavaScript context. Eight cases cover absent, separated, equal-sign, padded, empty, missing, repeated and similar-name inputs.
All eight assertions passed. The test does not start runCli, write configuration, log in, inspect storage permissions or call a model. It establishes argument parsing only, not security isolation or successful authentication.
Use the result in diagnosis
If credentials appear missing, compare the directory used for authentication with the directory used for the task. A valid --config spelling pointing to a different directory can explain different saved settings without any provider outage.
Avoid repeated configuration flags and inspect shell quoting when paths contain spaces. Before deleting any directory, establish what it contains and preserve needed settings; removing configuration is not an appropriate first debugging step.
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
Compare both supported flag spellings.
- 2
Check authentication and task directory consistency.
- 3
Preserve settings before any recovery action.
Copy-ready example
{"argv":["--config=./trial-a","--config=./trial-b"],"earlyResult":"./trial-a","scope":"argument-parser-only"}Frequently asked questions
Does --config create a security sandbox?
The parser returns a path; it does not enforce operating-system access controls.
Which repeated value does the early scan choose?
The first matching occurrence, as shown by the extracted-function fixture.
Sources
- Cline / apps/cli/src/main.tsSource checked 2026-09-23
- Cline / apps/cli/src/main.test.tsSource checked 2026-09-23