Cline AI Coding Agent for VS Code: Complete Guide
Cline (formerly Claude Dev) is an open-source AI coding agent extension for Visual Studio Code that brings agentic capabilities directly into your existing editor without switching to a different IDE. Unlike GitHub Copilot, Cline can autonomously read files, write code, run terminal commands, and even browse the web — all within your VS Code workflow. Best of all, you bring your own API key and choose your own model.
What Cline Can Do
Cline operates as a true coding agent with access to:
- File system: Read and write files across your project
- Terminal: Execute shell commands and interpret output
- Browser: Navigate websites, click elements, and take screenshots (via Playwright)
- MCP servers: Connect to databases, APIs, and custom tools via the Model Context Protocol
- Code editing: Make precise, surgical edits to existing files or create new ones
This is meaningfully different from autocomplete tools. You describe a goal, and Cline works toward it iteratively.
Installation
From the VS Code Marketplace
- Open VS Code
- Press
Ctrl+Shift+Xto open Extensions - Search for “Cline”
- Click Install (the extension by
saoudrizwan)
Or install via the command line:
code --install-extension saoudrizwan.claude-dev
After installation, the Cline icon appears in the VS Code sidebar.
Connecting to AI Models
Cline is model-agnostic. You configure it with your preferred provider in the Cline settings panel.
Using Claude (Anthropic)
- Open the Cline panel in the sidebar
- Click the settings gear icon
- Set API Provider to
Anthropic - Paste your Anthropic API key (from console.anthropic.com)
- Select your preferred model:
claude-opus-4-5,claude-sonnet-4, orclaude-haiku-3-5
Claude is the recommended backend for Cline — the model’s strong instruction-following and long-context abilities make it excellent for agentic coding tasks.
Using OpenAI
Provider: OpenAI
API Key: sk-...
Model: gpt-4o
Using Local Models via Ollama
For fully private, offline operation:
- Install and run Ollama with a capable model:
ollama pull llama3.1:8b
ollama serve # starts the API server on port 11434
- In Cline settings:
Provider: OpenAI Compatible
Base URL: http://localhost:11434/v1
API Key: ollama
Model: llama3.1:8b
Note: Local 8B models work for simple tasks but struggle with complex multi-file agentic workflows. A 70B model or a frontier API model gives much better results.
Connecting to LM Studio
Provider: LM Studio
Base URL: http://localhost:1234/v1
Model: (whatever you have loaded in LM Studio)
Your First Cline Task
Click the + button in the Cline panel to start a new task. Type a concrete goal:
Create a Python FastAPI app with a /health endpoint that returns {"status": "ok"}
and a /echo endpoint that returns whatever JSON body is sent to it. Add a
requirements.txt and a brief README.
Cline will:
- Propose a plan and list the files it intends to create
- Ask for your approval before making changes (by default)
- Create each file, showing you the content
- Run any commands needed (like
pip install fastapiif needed)
Every action Cline proposes shows up as an approval prompt. You can accept, reject, or modify before proceeding.
Agentic File Editing
Cline uses a precise diff-based approach to file edits. Rather than rewriting entire files, it makes targeted changes using a format that shows exactly what’s being added or removed.
Example — asking Cline to add input validation to an existing function:
In user_service.py, add email format validation to the create_user function.
Use the email-validator package. Raise a ValueError with a clear message if
the email is invalid.
Cline will:
- Read
user_service.pyto understand the existing code - Check
requirements.txtfor existing dependencies - Propose the specific code changes as a diff
- Add
email-validatorto requirements if not present
Terminal Command Execution
Cline can run shell commands and interpret the results. This is powerful for:
- Running tests and fixing failures automatically
- Installing dependencies
- Starting servers and checking they’re running
- Git operations
Run the test suite with pytest, and if there are any failures, fix them and
run again until all tests pass.
Cline will execute pytest, read the output, identify failing tests, make code changes, and iterate. By default, each terminal command requires your approval — you can see exactly what will run before it does.
MCP Server Integration
One of Cline’s most powerful features is Model Context Protocol (MCP) integration. MCP lets you connect Cline to external data sources and tools.
Setting Up an MCP Server
In Cline’s settings panel, go to MCP Servers and add a server configuration. For example, connecting to a filesystem MCP server:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/projects"]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_..."
}
}
}
}
With MCP servers connected, Cline can pull live data from GitHub, databases, or your custom APIs as part of its reasoning.
Cline vs GitHub Copilot
| Feature | Cline | GitHub Copilot |
|---|---|---|
| Agentic (multi-step tasks) | Yes | Very limited |
| File system access | Yes | No |
| Terminal execution | Yes | No |
| Model choice | Any provider | GPT-4o only |
| Open source | Yes (MIT) | No |
| MCP integration | Yes | No |
| Cost | Pay per token | $10–19/month |
| Autocomplete | Basic | Excellent |
| IDE | VS Code only | VS Code, JetBrains, etc. |
Copilot’s edge: Real-time autocomplete is significantly better in Copilot — it feels seamless and fast. Cline doesn’t compete on autocomplete.
Cline’s edge: For completing complex, multi-step tasks — “build this feature” or “refactor this module” — Cline is in a different league than Copilot.
Cost Management
Since you’re paying per token, costs can add up on complex tasks. Tips to manage spending:
- Use claude-haiku-3-5 for simple tasks, save Opus for complex reasoning
- Enable cache breakpoints in Cline settings to reuse context across similar tasks
- Set a token budget per task in settings
- For private data, use a local model to avoid any API costs
Typical costs for a medium-complexity task (creating a REST endpoint with tests) with Claude Sonnet: ~$0.05–0.20. For large refactoring sessions with Opus: $0.50–2.00.
Tips for Better Results
- Be specific: “Add a login form to the homepage with email/password fields, client-side validation, and a POST to /api/auth/login” beats “add a login page”
- Give context upfront: Mention your tech stack, frameworks, and conventions
- Use
.clinerules: Create a.clinerulesfile in your project root with persistent instructions (coding style, test requirements, etc.) - Review diffs carefully: Cline is powerful but verify multi-file changes before accepting
Cline represents a new category of coding tool — not just an autocomplete enhancer, but a genuine AI collaborator that can take on real engineering tasks.