Run Cline non-interactively in scripts, CI/CD pipelines, and automated workflows — with piped input, JSON output, and full autonomous execution.
Headless mode runs Cline without an interactive UI. It’s designed for automation, scripting, and CI/CD pipelines where no human is present. Cline executes the task, writes output to stdout, and exits when complete.For hands-on development with a terminal UI, see interactive mode instead.
Migrating from Cline CLI 1.x? Instance commands (cline instance new/list/kill) were removed in CLI 2.0. Use cline -y "task" for headless execution instead.
Use -p (Plan) or -a (Act) to control how Cline approaches the task:
# Analyze and plan before making changescline -y -p "Design a REST API for user management"# Execute immediately (Act mode is the default)cline -y -a "Fix the typo in README.md"
Pipe file contents or command output to provide context:
# Summarize a documentcat README.md | cline "Summarize this document"# Review git changesgit diff | cline "Review these changes and suggest improvements"# Analyze test failures and fix themnpm test 2>&1 | cline "Analyze these test failures and fix them"# Review a GitHub PRgh pr diff 123 | cline -y "Review this PR"
When stdin is piped, Cline automatically enters headless mode — the piped content is prepended to the task prompt as context.
Pipe Cline’s output into another Cline invocation to build multi-step workflows:
# Explain changes, then generate a commit messagegit diff | cline -y "explain these changes" | cline -y "write a commit message for this"# Generate a function, then write tests for itcline -y "create a fibonacci function" | cline -y "write unit tests for this code"# Combine with standard shell toolscline -y "list all TODO comments" | grep "FIXME" | wc -l
Use --json to get machine-readable output, one JSON object per line:
cline --json "List all TODO comments in the codebase" | jq '.text'
The --json flag forces headless mode automatically.JSON message schema:
Field
Type
Description
type
"ask" or "say"
Message category
text
string
Human-readable message content
ts
number
Unix timestamp in milliseconds
say
string
Subtype when type is "say" (e.g., "text", "tool")
ask
string
Subtype when type is "ask" (e.g., "tool", "followup")
reasoning
string
Model reasoning (omitted when empty)
partial
boolean
true while streaming; omitted when complete
Example output:
{"type":"say","text":"I'll scan the codebase for TODO comments now.","ts":1760501486669,"say":"text"}{"type":"say","text":"Found 12 TODO comments across 5 files.","ts":1760501490123,"say":"text"}
JSON output follows the same schema as task files stored in ~/.cline/data/tasks/<id>/ui_messages.json.
Attach one or more images to a headless task with -i:
cline -y -i screenshot.png "Fix the layout issue shown in this screenshot"# Multiple imagescline -y -i before.png -i after.png "What changed between these two screenshots?"
You can also reference images inline using @:
cline -y "Fix the UI shown in @./design-mockup.png"
Process multiple files or apply changes across a repository in one pass:
# Fix all TypeScript errors in the projectcline -y "Fix all TypeScript errors in src/"# Add JSDoc comments to all exported functionscline -y "Add JSDoc comments to every exported function in lib/"# Normalize import paths across the codebasecline -y "Update all imports in src/ to use path aliases instead of relative paths"