cli-reference.mdx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. ---
  2. title: "CLI Reference"
  3. description: "Complete command reference for Cline CLI including configuration, instance management, and task commands"
  4. ---
  5. Complete command reference for Cline CLI. Use this for detailed documentation on all commands, options, and configuration.
  6. For quick help in your terminal:
  7. ```bash
  8. cline --help # Show all commands
  9. cline task --help # Show task-specific commands
  10. man cline # View the full manual page
  11. ```
  12. ## Manual Page
  13. The complete manual page for the Cline CLI:
  14. ```
  15. CLINE(1) User Commands CLINE(1)
  16. NAME
  17. cline - orchestrate and interact with Cline AI coding agents
  18. SYNOPSIS
  19. cline [prompt] [options]
  20. cline command [subcommand] [options] [arguments]
  21. DESCRIPTION
  22. Try: cat README.md | cline "Summarize this for me:"
  23. cline is a command-line interface for orchestrating multiple Cline AI
  24. coding agents. Cline is an autonomous AI agent who can read, write,
  25. and execute code across your projects. He operates through a
  26. client-server architecture where Cline Core runs as a standalone
  27. service, and the CLI acts as a scriptable interface for managing tasks,
  28. instances, and agent interactions.
  29. The CLI is designed for both interactive use and automation, making it
  30. ideal for CI/CD pipelines, parallel task execution, and terminal-based
  31. workflows. Multiple frontends (CLI, VSCode, JetBrains) can attach to
  32. the same Cline Core instance, enabling seamless task handoff between
  33. environments.
  34. MODES OF OPERATION
  35. Instant Task Mode
  36. The simplest invocation: cline "prompt here" immediately spawns
  37. an instance, creates a task, and enters chat mode. This is
  38. equivalent to running cline instance new && cline task new &&
  39. cline task chat in sequence.
  40. Subcommand Mode
  41. Advanced usage with explicit control: cline <command>
  42. [subcommand] [options] provides fine-grained control over
  43. instances, tasks, authentication, and configuration.
  44. AGENT BEHAVIOR
  45. Cline operates in two primary modes:
  46. ACT MODE
  47. Cline actively uses tools to accomplish tasks. He can read
  48. files, write code, execute commands, use a headless browser, and
  49. more. This is the default mode for task execution.
  50. PLAN MODE
  51. Cline gathers information and creates a detailed plan before
  52. implementation. He explores the codebase, asks clarifying
  53. questions, and presents a strategy for user approval before
  54. switching to ACT MODE.
  55. INSTANT TASK OPTIONS
  56. When using the instant task syntax cline "prompt" the following options
  57. are available:
  58. -o, --oneshot
  59. Full autonomous mode. Cline completes the task and stops
  60. following after completion. Example: cline -o "what's 6 + 8?"
  61. -s, --setting setting value
  62. Override a setting for this task
  63. -y, --no-interactive, --yolo
  64. Enable fully autonomous mode. Disables all interactivity:
  65. • ask_followup_question tool is disabled
  66. • attempt_completion happens automatically
  67. • execute_command runs in non-blocking mode with timeout
  68. • PLAN MODE automatically switches to ACT MODE
  69. -m, --mode mode
  70. Starting mode. Options: act (default), plan
  71. -w, --workspace path
  72. Additional workspace paths. Can be specified multiple times to
  73. include multiple directories. The current working directory is
  74. always included as the first workspace. Example: cline -w
  75. /path/to/other/project "refactor shared code"
  76. GLOBAL OPTIONS
  77. These options apply to all subcommands:
  78. -F, --output-format format
  79. Output format. Options: rich (default), json, plain
  80. -h, --help
  81. Display help information for the command.
  82. -v, --verbose
  83. Enable verbose output for debugging.
  84. COMMANDS
  85. Authentication
  86. cline auth [provider] [key]
  87. cline a [provider] [key]
  88. Configure authentication for AI model providers. Launches an
  89. interactive wizard if no arguments provided. If provider is
  90. specified without a key, prompts for the key or launches the
  91. appropriate OAuth flow.
  92. Instance Management
  93. Cline Core instances are independent agent processes that can run in
  94. the background. Multiple instances can run simultaneously, enabling
  95. parallel task execution.
  96. cline instance
  97. cline i
  98. Display instance management help.
  99. cline instance new [-d|--default]
  100. cline i n [-d|--default]
  101. Spawn a new Cline Core instance. Use --default to set it as
  102. the default instance for subsequent commands.
  103. cline instance list
  104. cline i l
  105. List all running Cline Core instances with their addresses and
  106. status.
  107. cline instance default address
  108. cline i d address
  109. Set the default instance to avoid specifying --address in task
  110. commands.
  111. cline instance kill address [-a|--all]
  112. cline i k address [-a|--all]
  113. Terminate a Cline Core instance. Use --all to kill all running
  114. instances.
  115. Task Management
  116. Tasks represent individual work items that Cline executes. Tasks
  117. maintain conversation history, checkpoints, and settings.
  118. cline task [-a|--address ADDR]
  119. cline t [-a|--address ADDR]
  120. Display task management help. The --address flag specifies
  121. which Cline Core instance to use (e.g., localhost:50052).
  122. cline task new prompt [options]
  123. cline t n prompt [options]
  124. Create a new task in the default or specified instance.
  125. Options:
  126. -s, --setting setting value
  127. Set task-specific settings
  128. -y, --no-interactive, --yolo
  129. Enable autonomous mode
  130. -m, --mode mode
  131. Starting mode (act or plan)
  132. cline task open task-id [options]
  133. cline t o task-id [options]
  134. Resume a previous task from history. Accepts the same options
  135. as task new.
  136. cline task list
  137. cline t l
  138. List all tasks in history with their id and snippet
  139. cline task chat
  140. cline t c
  141. Enter interactive chat mode for the current task. Allows
  142. back-and-forth conversation with Cline.
  143. cline task send [message] [options]
  144. cline t s [message] [options]
  145. Send a message to Cline. If no message is provided, reads from
  146. stdin. Options:
  147. -a, --approve
  148. Approve Cline's proposed action
  149. -d, --deny
  150. Deny Cline's proposed action
  151. -f, --file FILE
  152. Attach a file to the message
  153. -y, --no-interactive, --yolo
  154. Enable autonomous mode
  155. -m, --mode mode
  156. Switch mode (act or plan)
  157. cline task view [-f|--follow] [-c|--follow-complete]
  158. cline t v [-f|--follow] [-c|--follow-complete]
  159. Display the current conversation. Use --follow to stream
  160. updates in real-time, or --follow-complete to follow until task
  161. completion.
  162. cline task restore checkpoint
  163. cline t r checkpoint
  164. Restore the task to a previous checkpoint state.
  165. cline task pause
  166. cline t p
  167. Pause task execution.
  168. Configuration
  169. Configuration can be set globally. Override these global settings for
  170. a task using the --setting flag
  171. cline config
  172. cline c
  173. cline config set key value
  174. cline c s key value
  175. Set a configuration variable.
  176. cline config get key
  177. cline c g key
  178. Read a configuration variable.
  179. cline config list
  180. cline c l
  181. List all configuration variables and their values.
  182. Context Window Configuration
  183. For local model providers, you can configure the context window size:
  184. Ollama
  185. cline config s ollama-api-options-ctx-num=32768
  186. LM Studio
  187. cline config s lm-studio-max-tokens=32768
  188. For other providers (Anthropic, OpenRouter, etc.), the context window
  189. is defined per model in the model metadata and is not user-settable.
  190. Cline uses each model's built-in context limits automatically.
  191. TASK SETTINGS
  192. Task settings are persisted in the ~/.cline/x/tasks directory. When
  193. resuming a task with cline task open, task settings are automatically
  194. restored.
  195. Common settings include:
  196. yolo Enable autonomous mode (true/false)
  197. mode Starting mode (act/plan)
  198. hooks_enabled
  199. Enable or disable hooks for the task (true/false)
  200. HOOKS INTEGRATION
  201. Hooks let you inject custom logic into Cline's workflow at key moments.
  202. They can validate operations before they execute, monitor tool usage,
  203. and shape AI decisions. This allows you to integrate hooks into
  204. automated workflows, CI/CD pipelines, and headless task execution.
  205. Enable hooks for a task:
  206. cline "prompt" -s hooks_enabled=true
  207. Configure hooks globally:
  208. cline config set hooks-enabled=true
  209. cline config get hooks-enabled
  210. Note: Hooks in the CLI are only supported on macOS and Linux.
  211. For complete hooks documentation, see:
  212. <https://docs.cline.bot/features/hooks/index>
  213. NOTES & EXAMPLES
  214. The cline task send and cline task new commands support reading from
  215. stdin, enabling powerful pipeline compositions:
  216. cat requirements.txt | cline task send
  217. echo "Refactor this code" | cline -y
  218. Instance Management
  219. Manage multiple Cline instances:
  220. # Start a new instance and make it default
  221. cline instance new --default
  222. # List all running instances
  223. cline instance list
  224. # Kill a specific instance
  225. cline instance kill localhost:50052
  226. # Kill all CLI instances
  227. cline instance kill --all-cli
  228. Task History
  229. Work with task history:
  230. # List previous tasks
  231. cline task list
  232. # Resume a previous task
  233. cline task open 1760501486669
  234. # View conversation history
  235. cline task view
  236. # Start interactive chat with this task
  237. cline task chat
  238. ARCHITECTURE
  239. Cline operates on a three-layer architecture:
  240. Presentation Layer
  241. User interfaces (CLI, VSCode, JetBrains) that connect to Cline
  242. Core via gRPC
  243. Cline Core
  244. The autonomous agent service handling task management, AI model
  245. integration, state management, tool orchestration, and real-time
  246. streaming updates
  247. Host Provider Layer
  248. Environment-specific integrations (VSCode APIs, JetBrains APIs,
  249. shell APIs) that Cline Core uses to interact with the host
  250. system
  251. BUGS
  252. Report bugs at: <https://github.com/cline/cline/issues>
  253. For real-time help, join the Discord community at:
  254. <https://discord.gg/cline>
  255. SEE ALSO
  256. Full documentation: <https://docs.cline.bot>
  257. AUTHORS
  258. Cline is developed by the Cline Bot Inc. and the open source community.
  259. COPYRIGHT
  260. Copyright © 2025 Cline Bot Inc. Licensed under the Apache License 2.0.
  261. ```
  262. ## JSON output (-F json)
  263. When you run a command with `-F json` (or `--output-format json`), Cline prints each client message as JSON.
  264. ### ClineMessage schema
  265. | Field | Type | Required | Notes |
  266. |-------|------|----------|-------|
  267. | `type` | `"ask" or "say"` | Yes | Top-level message category. |
  268. | `text` | `string` | Yes | Human-readable message content. |
  269. | `ts` | `number` | Yes | Unix epoch timestamp in milliseconds. |
  270. | `reasoning` | `string` | No | Omitted when empty. |
  271. | `say` | `string` | No | Omitted when empty. Present when `type` is `"say"`. |
  272. | `ask` | `string` | No | Omitted when empty. Present when `type` is `"ask"`. |
  273. | `partial` | `boolean` | No | Omitted when false. `true` for streaming updates. |
  274. | `images` | `string[]` | No | Omitted when empty. Image URIs when included with a message. |
  275. | `files` | `string[]` | No | Omitted when empty. File paths when attached to a message. |
  276. | `lastCheckpointHash` | `string` | No | Omitted when empty. Git checkpoint hash when available. |
  277. | `isCheckpointCheckedOut` | `boolean` | No | Omitted when false. `true` if Cline checked out a checkpoint. |
  278. | `isOperationOutsideWorkspace` | `boolean` | No | Omitted when false. `true` if an operation happened outside the workspace. |
  279. <Note>
  280. Most fields are optional and omitted when empty. If you parse this output, treat missing fields as “not present”, not as empty strings.
  281. </Note>
  282. ### Example
  283. ```json
  284. {
  285. "type": "say",
  286. "text": "Cline is about to run a command.",
  287. "ts": 1760501486669,
  288. "say": "command",
  289. "partial": false
  290. }
  291. ```
  292. ### Shell Completion
  293. Generate autocompletion scripts for various shells:
  294. #### Bash
  295. ```bash
  296. # Generate bash completion
  297. cline completion bash > /etc/bash_completion.d/cline
  298. # Or for user-level installation
  299. cline completion bash > ~/.local/share/bash-completion/completions/cline
  300. ```
  301. #### Zsh
  302. ```bash
  303. # Generate zsh completion
  304. cline completion zsh > "${fpath[1]}/_cline"
  305. # Or add to your .zshrc
  306. echo 'source <(cline completion zsh)' >> ~/.zshrc
  307. ```
  308. #### Fish
  309. ```bash
  310. # Generate fish completion
  311. cline completion fish > ~/.config/fish/completions/cline.fish
  312. ```
  313. #### PowerShell
  314. ```powershell
  315. # Generate PowerShell completion
  316. cline completion powershell > cline.ps1
  317. # Add to your PowerShell profile
  318. Add-Content $PROFILE "cline completion powershell | Out-String | Invoke-Expression"
  319. ```
  320. ### Version Command
  321. ```bash
  322. # Show version information
  323. cline version
  324. ```
  325. ### Environment Variables
  326. #### CLINE_DIR
  327. Override the default Cline directory location:
  328. ```bash
  329. # Override default Cline directory
  330. export CLINE_DIR=/custom/path
  331. # Default: ~/.cline
  332. ```
  333. This directory is used for:
  334. - Instance registry database
  335. - Configuration files
  336. - Task history
  337. - Checkpoints