1. AI App
Nebula-API操作文档
🇺🇸English
  • 🇨🇳中文
  • 🇺🇸English
  • Chat
    • General Text Dialogue Interface Document
    • Tongyi Qianwen General Dialogue Interface Document
    • DeepSeek General Dialogue Document
    • GPT Chat General Dialogue Document
    • Grok Model (xAI) General Dialogue Interface Document
  • Image
    • General Image Generation Interface Document
    • Nano Banana Image Generation Interface Document
    • Tongyi Qianwen Text to Image Model Interface Document
    • Tongyi Qianwen Image Editing Model Interface Document
  • Video
    • Sora-2 interface document
    • Alibaba Wanxiang Wan2.5 Tu Sheng Video Interface Document
    • Google Veo Video Model Interface Document
    • General Video Generation Interface Document
  • AI App
    • Cherry Studio Integration Guide
    • LangChain Development Framework Integration Guide
    • Cursor Code Editor Integration Guide
    • Claude Code and other client integration guidelines
    • Cline (VS Code) AI Programming Assistant Integration Guide
    • Immersive Translation Integration Guide
  • Real time conversation
    • Realtime real-time conversation document
  1. AI App

Cline (VS Code) AI Programming Assistant Integration Guide

Cline (VS Code) User Guide#

I. Introduction#

Cline (formerly Claude Dev) is a powerful VS Code AI programming assistant extension that supports multiple AI models. By integrating Nebula lab, you can flexibly switch between mainstream AI models to assist with programming, covering the entire development process including code generation, explanation, refactoring, and testing.

II. Quick Installation and Configuration#

1. Install Extension#

Search for "Cline" in the VS Code Extension Marketplace, click "Install" and enable it.

2. Configure Nebula API#

1.
Click the Cline Icon on the left side of VS Code to open the extension panel.
2.
Click the settings button (gear icon) in the panel and select "OpenAI Compatible".
3.
Fill in the configuration parameters:
Base URL: https://llm.ai-nebula.com/v1 (Fixed address)
API Key: Enter your Nebula Lab key (obtained from the Nebula Lab console)
Model Name: Enter the target model name (refer to "Recommended Models" below)

III. Recommended Models#

🎯 Top Choice for Coding Development#

Model IDFeatures
claude-sonnet-4-20250514Claude 4 latest version, extremely strong coding capability
o4-miniOpenAI reasoning model, top choice for programming tasks
gemini-2.5-proSupports 2M context, strong multimodal capability
deepseek-coderCode-specialized model, 128K context

💡 Complex Reasoning Tasks#

Model IDFeatures
o3Latest reasoning model, significantly reduced price
claude-sonnet-4-20250514-thinkingClaude 4 Chain of Thought mode, transparent reasoning process
deepseek-r1Latest reasoning model, 64K context
grok-3-miniLightweight model with reasoning capability

🚀 Fast Response#

Model IDFeatures
gpt-3.5-turboClassic model, high cost-performance ratio
gemini-2.5-flashFast speed, low cost, 1M context
claude-3-haikuLightweight fast version, 200K context
gpt-4o-miniLightweight fast version, 128K context

💰 High Cost-Performance Ratio#

Model IDFeatures
deepseek-chat128K context, strong comprehensive capability
qwen-turboAlibaba Tongyi Qianwen Turbo version
gpt-4.1-nanoUltra-low cost version, 128K context

IV. Core Functions#

1. Intelligent Code Completion#

Enter comments or code snippets, and AI automatically completes the implementation:

2. Code Explanation#

After selecting a code snippet, use the following commands:
Cline: Explain Code: Explains code logic, purpose, and key steps.
Cline: Explain Error: Analyzes error messages, locates error causes, and provides fix suggestions.

3. Code Refactoring#

Supports multiple refactoring scenarios:
Performance Optimization: Identifies redundant logic and inefficient algorithms, providing optimization plans.
Readability Improvement: Renames variables, splits complex functions, adds comments.
Issue Fixing: Automatically fixes syntax errors and logical vulnerabilities (e.g., null pointers, array out of bounds).

4. Generate Tests#

Automatically generate unit tests based on functions:

V. Common Commands and Shortcuts#

CommandShortcutDescription
Cline: AskCtrl+Shift+LAsk AI (e.g., code questions)
Cline: ExplainCtrl+Shift+EExplain selected code
Cline: RefactorCtrl+Shift+RRefactor selected code
Cline: GenerateCtrl+Shift+GGenerate code based on requirements

VI. Advanced Functions#

1. Multi-file Operations#

Supports cross-file understanding and modification, for example:
"Move the formatDate function from utils.js to helpers.js and update all files referencing this function"

2. Architecture Design#

Generate project architecture plans based on requirements:
Please design an architecture for an e-commerce backend management system, including:
- User management (login, permissions)
- Product management (CRUD, categories)
- Order processing (creation, payment, logistics)
- Data analysis (sales statistics, user profiling)
Tech stack: React + Node.js + PostgreSQL

3. Code Review#

Automated PR review, covering multiple dimensions:
Review PR:
- Check if it conforms to ESLint standards
- Find potential bugs (e.g., unhandled exceptions)
- Performance optimization suggestions (e.g., duplicate calculation optimization)
- Security vulnerability scan (e.g., SQL injection risks)

VII. Usage Tips#

1. Context Management#

Provide detailed context to let AI generate more precise code:

2. Custom Prompts#

Configure common prompt templates in VS Code settings:
{
  "cline.customPrompts": {
    "codeReview": "Review code, focusing on performance, security, and team code standards",
    "optimize": "Optimize code performance (reduce redundant calculations) and readability (add JSDoc comments)",
    "document": "Generate detailed Chinese documentation, including function description, parameter explanation, and usage examples"
  }
}

3. Project-Level Configuration#

Create .cline/config.json in the project root directory to unify code style:
{
  "model": "claude-3-5-sonnet-20241022", // Default model
  "temperature": 0.7, // Generation randomness (0-1)
  "language": "zh-CN", // Prioritize Chinese interaction
  "codeStyle": {
    "naming": "camelCase", // Variable naming style
    "indent": 4, // Indentation spaces
    "quotes": "single" // String quote type
  }
}

VIII. Troubleshooting#

Connection Failed#

Check Configuration: Base URL must be https://llm.ai-nebula.com/v1, and API Key must be valid.
Verify Network: Turn off proxy or VPN and retry to ensure access to the API address.

Response Timeout#

Optimization Plan: Use faster models (e.g., gemini-2.5-flash), split large tasks (e.g., "design function interface first, then implement logic").

Poor Generation Quality#

Improvement Method: Add more context (e.g., tech stack, constraints), switch to more powerful models (e.g., claude-sonnet-4-20250514), clarify requirement details (avoid vague descriptions).

IX. Best Practices#

1. Model Selection Strategy#

Task TypeRecommended ModelCost LevelReason
Simple Completiongpt-3.5-turbo / gemini-2.5-flashVery LowFast speed, low cost, meets basic needs
Code Generationclaude-sonnet-4-20250514 / o4-miniMediumStrongest coding capability, rigorous logic
Complex Reasoningo3 / deepseek-r1Low-MidStrong reasoning capability, o3 cost-performance optimized
Architecture Designdeepseek-r1 + claude-4-sonnetLowPlan first then implement, balancing efficiency and cost
Code Reviewgemini-2.5-pro / claude-4-sonnetMediumLong context support, understands multi-file associations
Batch Refactoringdeepseek-chat / qwen-turboVery LowFast processing of repetitive tasks, controllable cost
Doc Generationgpt-4.1 / qwen-maxLow-MidNatural and fluent expression, adapted for Chinese scenarios
Long Textgemini-2.5-pro (2M Context)MediumSupports understanding of ultra-long codebases or documents

2. Prompt Optimization#

❌ Bad Example: "Fix this function"
✅ Good Example: "Fix the floating-point precision issue in the calculateTotal function, ensuring amounts are calculated to two decimal places (e.g., 1.995 should be rounded to 2.00)"

3. Progressive Development#

1.
Generate the basic framework first (e.g., function interfaces, component structure).
2.
Gradually add core functions (implement step-by-step to avoid generating complex code at once).
3.
Finally, optimize performance (e.g., caching, async processing) and error handling (e.g., boundary condition checks).

4. Security Awareness#

Avoid including sensitive information (e.g., API keys, database passwords) in prompts.
Review AI-generated code (especially parts involving permissions and encryption).
Verify third-party dependency security (e.g., check vulnerabilities via npm audit).

X. Integration Workflow#

1. Git Integration#

2. Test-Driven Development (TDD)#

1.
Manually write test cases (e.g., Jest, PyTest).
2.
Use Cline to generate implementation code that meets test requirements.
3.
Run tests to verify, and use Cline to fix failing cases.

3. CI/CD Integration#

Generate automated configuration files (e.g., GitHub Actions):

XI. Token Optimization and Cost Control#

1. Monitoring and Management#

Real-time Monitoring: View estimated token costs for the current session in the Cline sidebar.
Session Management: Keep sessions short (one session per task) to avoid meaningless accumulation of context.

2. Intelligent Model Switching Strategy#

Planning Stage → DeepSeek-R1 or o3 (Strong reasoning, low cost)
Implementation Stage → Claude-4-Sonnet or o4-mini (Strongest coding capability)
Simple Tasks → GPT-3.5-Turbo or Gemini-2.5-Flash (Fast speed)
Long Text → Gemini-2.5-Pro (2M Context)

3. Configure Restriction Rules#

Create a .clinerules file in the project root directory to constrain operation scope:
# Limit Cline operation scope
- Not allowed to modify node_modules directory
- Not allowed to delete important files marked in .gitignore
- Limit single modification file count ≤ 5
- Must prompt for confirmation before executing destructive operations (e.g., deleting code blocks)

4. Low-Cost Alternatives#

GitHub Copilot Pro: $10/month, unlimited use, suitable for high-frequency scenarios.
Local Models (Ollama):
Domestic Models: qwen-turbo (Alibaba), glm-4 (Zhipu), ernie-4.0 (Baidu), low cost and adapted for Chinese scenarios.

XII. Advanced Best Practices#

1. Plan/Act Modes#

Plan Mode: Used for design and review (read-only, no changes), suitable for reasoning models (e.g., o3).
Act Mode: Directly implements code (can modify files), suitable for programming models (e.g., claude-sonnet-4).
Model Memory: Cline remembers preferences for both modes and automatically adapts to the scenario.

2. Context Management Skills#

3. Avoid Token Explosion#

❌ Wrong Practice: Handling multiple unrelated tasks in the same session, letting AI read entire large codebases, confusing context with frequent requirement changes.
✅ Correct Practice: Open a new session for each feature, include only relevant files, clarify requirements before starting, and commit code immediately after completion.

4. Workflow Optimization#

# 1. Planning Stage (Reasoning Model)
"Use o3 or DeepSeek-R1 to analyze requirements and output architecture plans and interface designs"

# 2. Implementation Stage (Programming Model)
"Switch to Claude-4-Sonnet or o4-mini to generate core code by module"

# 3. Test Optimization (Fast Model)
"Use Gemini-2.5-Flash to generate unit tests and fix errors"

# 4. Documentation Stage (Comprehensive Model)
"Use GPT-4.1 to generate API documentation and usage instructions"

# 5. Code Review (Long Context Model)
"Use Gemini-2.5-Pro to review full project code and optimize details"
修改于 2025-12-04 07:48:55
上一页
Claude Code and other client integration guidelines
下一页
Immersive Translation Integration Guide
Built with