Lazy loaded image
技術分享
How to config personal ai agent in vscode using Continue
字數 393閱讀時間≈ 1 分鐘
2025-11-20
2025-12-3
26

Introduction

The Continue VS Code extension transforms your editor into an AI-powered coding companion by allowing you to define custom AI agents that assist with code generation, refactoring, documentation, and more. At the heart of this customization is the config.yaml file — a simple yet powerful configuration file that lets you tailor the behavior, model, prompts, and tools of your AI agent.
This guide walks you through creating a custom AI agent in VS Code using Continue’s config.yaml, enabling you to build a developer assistant tuned to your team’s coding standards, frameworks, or workflows.

Prerequisites

  • An API key for a supported LLM provider (e.g., OpenAI, Anthropic, Ollama, or local models)

Step 1: Locate or Create config.yaml

When you first open Continue in VS Code, it automatically creates a .continue folder in your project root. Inside this folder, you’ll find a default config.yaml.
💡 If the folder doesn’t exist, open VS Code, press Ctrl+Shift+P (or Cmd+Shift+P), type Continue: Open Config, and select it. This will generate the folder and file.
The default config.yaml looks like this:

yaml

# .continue/config.yaml models: - name: gpt-4-turbo provider: openai apiKey: ${{ secrets.MY_AI_SECRET_KEY }} # Default agent settings agent: maxTokens: 2048 temperature: 0.3 systemPrompt: | You are a helpful AI coding assistant. You write clean, efficient, and well-documented code. Always follow the project’s existing patterns and conventions. # Custom commands (optional) commands: - name: "Refactor for performance" description: "Refactor the selected code to improve performance and reduce complexity." prompt: | Analyze the following code and refactor it for better performance. Consider algorithmic efficiency, memory usage, and readability. Return only the improved code with no explanations.
YAML

Step 2: Secure Your API Key

Never hardcode API keys directly in config.yaml. Instead, store them securely in a .env file and load them as environment variables.

Create .env

Create a .env file in the same path of config.yaml (add it to .gitignore!):

json

MY_AI_SECRET_KEY = xxxxxxxxxxxxxxxx
JSON
Add this line to your .gitignore to prevent leaks:

plain

.env
Plain text

Reload configuration

At top-right corner of Continue chat box, drop down Local Config, select Reload
Then you could use your private ai agent in vscode!
Continue will automatically read ${{MY_AI_SECRET_KEY}} from your environment — no secrets are stored in version control.
🔐 Security Note: Never commit secrets.json or .env files. Always use .gitignore to protect them.

Further Reading

  • inception/mercury-coder
 
上一篇
How to Customize VSCode Theme Colors and Identify Color Keys
下一篇
使用不同顏色主題區分本地 VSCode 與 Remote SSH 視窗

留言
Loading...