Skip to main content

CLI Usage

The Cline CLI brings the power of HAI Build Code Generator directly to your terminal. Run AI-powered coding tasks, manage history, and automate workflows without leaving the command line.

Installation

Install globally via npm:
Or use directly with npx:

Modes of Operation

Interactive Mode

Launch the interactive terminal UI when you run cline without arguments:
This provides a rich interface with:
  • Real-time conversation display
  • Task history navigation
  • Live progress updates
  • Interactive approval prompts

Task Mode

Execute tasks directly with a prompt:
Automatically switches between interactive and plain text mode based on the environment.

Plain Text Mode

Activated automatically when:
  • Output is redirected (> or |)
  • stdin is piped
  • --json or --yolo flags are used
Perfect for scripting and CI/CD pipelines:

Core Commands

task (alias: t)

Run a new coding task:
Options: Examples:

history (alias: h)

View and navigate task history:
Options:

config

View current configuration:
Displays global and workspace state, API configurations, and settings.

auth

Authenticate providers and configure models:
Quick Setup Options:

version

Show CLI version:

update

Check for and install updates:

Agent Behavior Modes

Act Mode (Default)

Cline actively uses tools to accomplish tasks:
  • Creates and edits files
  • Executes terminal commands
  • Uses headless browser
  • Searches codebases
  • Makes API calls

Plan Mode

Cline gathers information and creates a plan before implementation:
  • Explores the codebase
  • Asks clarifying questions
  • Presents a detailed strategy
  • Waits for approval before acting

Advanced Usage

Piped Input

Pass data directly from other commands:

Image References

Include images in your prompts:

JSON Output

Parse structured output for automation:
JSON Format:

Resuming Tasks

Continue where you left off:

Scripting Examples

Automated Testing:
CI/CD Integration:
Batch Processing:

Environment Variables

CLINE_DIR

Override the default configuration directory:

CLINE_COMMAND_PERMISSIONS

Restrict shell commands Cline can execute:
Configuration format:

Configuration Files

Directory Structure

View Logs

Tips & Best Practices

Performance Optimization

  1. Use Plan Mode for Large Tasks: Let Cline explore and plan before taking action
  2. Enable Thinking for Complex Problems: --thinking provides better reasoning
  3. Leverage Task Resume: Continue expensive tasks without starting over

Security

  1. Use Command Permissions: Restrict what Cline can execute
  2. Review Before Yolo: Test tasks interactively before automating
  3. Keep API Keys Secure: Store in ~/.cline/data/secrets.json

Workflow Integration

  1. Combine with Git Hooks: Run Cline on pre-commit
  2. Pipe from Build Tools: Process compiler errors automatically
  3. Chain with Other CLIs: Use in complex shell pipelines

Troubleshooting

Authentication Issues

Task Not Starting

Plain Text Mode Unexpected

Plain text mode activates when:
  • Output is redirected
  • stdin is piped
  • --json or --yolo flags are used
To force interactive mode, ensure stdin/stdout are TTYs.

Next Steps

API Integration

Integrate Cline into your VS Code extensions

Custom Experts

Create domain-specific coding experts