> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codealive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cline

> Connect CodeAlive with Cline autonomous coding agent

## Overview

Integrate CodeAlive with Cline - the open-source AI coding agent used by millions of developers. Cline can autonomously create and extend its capabilities through MCP tools. With 30k+ GitHub stars, Cline offers complete transparency and zero vendor lock-in.

<Tip>
  **Quick install:** Run `npx @codealive/installer` to automatically configure CodeAlive for Cline.
  See the [Installation Guide](/installation) for details.
</Tip>

## Prerequisites

* [Cline](https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev) extension installed in VS Code
* CodeAlive account with API key ([Sign up here](https://app.codealive.ai))
* Indexed repositories in your CodeAlive dashboard

## Connecting to CodeAlive

<Steps>
  <Step title="Open Cline Settings">
    Access Cline's MCP configuration:

    1. Click on the Cline icon in the VS Code sidebar
    2. Click the settings gear icon
    3. Navigate to "MCP Servers" section

    Or use Command Palette:

    * Cmd/Ctrl+Shift+P → "Cline: Configure MCP Servers"
  </Step>

  <Step title="Add CodeAlive MCP">
    Configure CodeAlive as an MCP server:

    ```json theme={null}
    {
      "mcpServers": {
        "codealive": {
          "url": "https://mcp.codealive.ai/api",
          "headers": {
            "Authorization": "Bearer YOUR_API_KEY_HERE"
          }
        }
      }
    }
    ```

    <Info>
      **Cline's Unique Feature:** Ask Cline to "add a tool" and it will create and install custom MCP servers tailored to your workflow - no manual configuration needed!
    </Info>

    <Warning>Replace `YOUR_API_KEY_HERE` with your actual CodeAlive API key</Warning>
  </Step>

  <Step title="Enable MCP in Cline">
    Ensure MCP is enabled in Cline settings:

    ```json theme={null}
    {
      "cline.enableMCP": true,
      "cline.mcpAutoConnect": true
    }
    ```
  </Step>

  <Step title="Restart VS Code">
    Restart VS Code to ensure all changes take effect
  </Step>

  <Step title="Verify Integration">
    Test by asking Cline:

    * "Use CodeAlive to show me all available repositories"
    * "Search the codebase for authentication logic"
    * "Analyze the project architecture using CodeAlive"
  </Step>
</Steps>

## Configuration Options

### Advanced Settings

```json theme={null}
{
  "mcpServers": {
    "codealive": {
      "url": "https://mcp.codealive.ai/api",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY_HERE"
      }
    }
  }
}
```

### Docker Deployment

Run CodeAlive locally for better performance:

```json theme={null}
{
  "mcpServers": {
    "codealive": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "CODEALIVE_API_KEY=YOUR_API_KEY_HERE",
        "ghcr.io/codealive-ai/codealive-mcp:main"
      ]
    }
  }
}
```

## Usage Patterns

<Tabs>
  <Tab title="Autonomous Tasks">
    Let Cline use CodeAlive automatically:

    ```
    "Refactor the user service to match our microservices pattern"

    Cline will:
    1. Use CodeAlive to find existing patterns
    2. Analyze the current implementation
    3. Generate refactored code
    4. Update related files
    ```
  </Tab>

  <Tab title="Guided Development">
    Direct Cline to use CodeAlive:

    ```
    "Use CodeAlive to find all payment processing code,
    then add retry logic following our existing patterns"
    ```
  </Tab>

  <Tab title="Code Review">
    Have Cline review code with context:

    ```
    "Use CodeAlive to review this PR for consistency
    with our codebase conventions"
    ```
  </Tab>
</Tabs>

## Cline Rules Configuration

Create `.cline/rules.md` in your project root:

```markdown theme={null}
# CodeAlive Integration Rules

## Always Use CodeAlive For:
- Finding existing implementations before writing new code
- Understanding project architecture and patterns
- Locating all files that might be affected by changes
- Searching for similar code patterns

## Code Generation Guidelines:
- Match the style found via CodeAlive search
- Follow conventions discovered in the codebase
- Reuse existing utilities and helpers
- Maintain consistency with existing patterns

## Before Making Changes:
1. Search with CodeAlive for related code
2. Analyze existing patterns
3. Consider impact on other parts of the system
4. Follow established conventions
```

## Advanced Features

### Task Planning

Configure Cline to use CodeAlive for planning:

```json theme={null}
{
  "cline.planning": {
    "enabled": true,
    "useCodeAlive": true,
    "steps": [
      "Search for similar implementations",
      "Analyze existing patterns",
      "Plan changes based on findings",
      "Execute implementation"
    ]
  }
}
```

### Custom Commands

Create Cline commands that leverage CodeAlive:

```json theme={null}
{
  "cline.customCommands": [
    {
      "name": "Analyze Architecture",
      "command": "Use CodeAlive to analyze and explain the project architecture"
    },
    {
      "name": "Find Security Issues",
      "command": "Use CodeAlive to search for potential security vulnerabilities"
    },
    {
      "name": "Generate Tests",
      "command": "Use CodeAlive to find the code, then generate comprehensive tests"
    }
  ]
}
```

### Model Configuration

Optimize Cline's model usage with CodeAlive:

```json theme={null}
{
  "cline.apiProvider": "anthropic",
  "cline.apiModel": "claude-3-opus-20240229",
  "cline.contextStrategy": "codealive-first",
  "cline.maxContextTokens": 100000
}
```

## Workspace Settings

### Project-Specific Configuration

`.vscode/settings.json`:

```json theme={null}
{
  "mcpServers": {
    "codealive": {
      "type": "http",
      "url": "https://mcp.codealive.ai/api",
      "headers": {
        "Authorization": "Bearer ${env:CODEALIVE_API_KEY}"
      },
      "repositories": ["backend", "frontend", "shared"]
    }
  },
  "cline.autoDetectTasks": true
}
```

### Team Collaboration

Share configuration without exposing API keys:

1. Add to `.vscode/settings.json`:

```json theme={null}
{
  "cline.mcpServers.codealive.headers.Authorization": "Bearer ${env:CODEALIVE_API_KEY}"
}
```

2. Team members set environment variable:

```bash theme={null}
export CODEALIVE_API_KEY="their_api_key"
```

## Performance Optimization

<AccordionGroup>
  <Accordion title="Caching">
    Enable caching for repeated queries:

    ```json theme={null}
    {
      "cline.cache": {
        "enabled": true,
        "codealiveQueries": true,
        "ttl": 3600
      }
    }
    ```
  </Accordion>

  <Accordion title="Context Management">
    Optimize context window usage:

    ```json theme={null}
    {
      "cline.contextOptimization": {
        "useCodeAliveFirst": true,
        "summarizeContext": true,
        "maxFilesPerRequest": 10
      }
    }
    ```
  </Accordion>

  <Accordion title="Parallel Processing">
    Enable parallel CodeAlive queries:

    ```json theme={null}
    {
      "cline.parallel": {
        "enabled": true,
        "maxConcurrent": 3
      }
    }
    ```
  </Accordion>
</AccordionGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Cline not detecting CodeAlive">
    **Solutions:**

    1. Check MCP is enabled in Cline settings
    2. Verify MCP server configuration
    3. Restart VS Code completely
    4. Check Cline output panel for errors
  </Accordion>

  <Accordion title="Slow autonomous operations">
    **Solutions:**

    1. Use Docker for local deployment
    2. Limit repository scope in searches
    3. Enable caching
    4. Optimize context window usage
  </Accordion>

  <Accordion title="Authentication errors">
    **Solutions:**

    1. Regenerate API key
    2. Check Bearer token format
    3. Verify environment variables
    4. Test connection manually
  </Accordion>

  <Accordion title="Context window exceeded">
    **Solutions:**

    1. Enable context optimization
    2. Use CodeAlive for large file searches
    3. Limit files per request
    4. Use summarization features
  </Accordion>
</AccordionGroup>

<Tip>
  For more solutions, see the [Troubleshooting Guide](/troubleshooting).
</Tip>

## Best Practices

<CardGroup cols={2}>
  <Card title="Let Cline Plan" icon="map">
    Allow Cline to use CodeAlive for task planning
  </Card>

  <Card title="Review Changes" icon="eye">
    Always review Cline's changes in context
  </Card>

  <Card title="Iterative Development" icon="repeat">
    Use CodeAlive to verify changes match patterns
  </Card>

  <Card title="Safety First" icon="shield">
    Test Cline's changes in development first
  </Card>
</CardGroup>

## Tips for Effective Use

### Prompting Strategies

**Good Prompts:**

```
"Use CodeAlive to find our API endpoint patterns,
then create a new user profile endpoint"

"Search for our error handling patterns with CodeAlive,
then improve error handling in the payment service"
```

**Avoid:**

```
"Create a new endpoint" (too vague, won't use context)
"Fix the bug" (doesn't leverage CodeAlive)
```

### Task Delegation

Let Cline handle complex multi-file operations:

```
"Use CodeAlive to find all references to the old User model,
then update them to use the new UserProfile model"
```

## Related Resources

* [MCP Overview](/integrations/mcp)
* [Cline Documentation](https://github.com/saoudrizwan/claude-dev)
* [Self-Hosting Guide](/integrations/mcp/self-hosting)
* [VS Code Integration](/integrations/mcp/vscode)

## Instruct Your Agent

Connecting CodeAlive makes its tools available, but the agent may still default to its built-in search. For reliable results, add a short instruction in the agent's native format telling it to prefer `semantic_search` and `grep_search` when exploring indexed code. See [Instructing Coding Agents](https://docs.codealive.ai/guides/instructing-agents).
