Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Kilo Code Getting Started Tutorial

Kilo Code Getting Started Tutorial

Kilo Code is an open-source AI coding Agent that runs in your VS Code, JetBrains, or command line, supports 500+ AI models, currently has 3M+ developer users, and has processed 40T+ Tokens.

Kilo Code is an open-source AI coding Agent installed in your existing IDE (VS Code, JetBrains).

Kilo Code is not a new editor fork - no changing tools, no changing shortcuts, no changing plugins - you get AI Agent capabilities directly in your existing development environment.

Official Address:https://kilo.ai/

Differences from other AI tools

Dimension Cursor / Windsurf GitHub Copilot Kilo Code
Installation method Requires switching to a new editor VS Code plugin VS Code / JetBrains plugin
Open source Closed source Closed source Open source (MIT license)
Model selection Limited Limited 500+ models, switchable at any time
Pricing Subscription with markup Subscription Zero markup, billed directly at the model provider's rates
Bring your own API Key You can No Yes (BYOK)
Agent modes Basics Basics Code / Ask / Plan / Debug + custom
Parallel Agents None None Supported (git worktrees isolation)

Overview of core features

Quickly understand the main features and capabilities that Kilo Code provides.


Installation

Kilo Code supports multiple installation methods such as VS Code, JetBrains, and CLI, described separately below.

VS Code plugin (recommended)

Open VS Code and press Ctrl+Shift+X(Windows/Linux) or Cmd+Shift+X(macOS) to open the plugin marketplace.

Search for Kilo Code and click Installation .

You can also install from the command line:



code --install-extension kilocode.Kilo-Code

After successful installation, click the Kilo Code icon in the upper-right corner to start using it; there is a certain free quota:

You can define your own model on the settings page:

JetBrains plugin

Open the JetBrains IDE (IntelliJ, PyCharm, WebStorm, etc.).

Enter Settings → Plugins → Marketplace, search for Kilo Code and install it, then restart the IDE.

CLI installation (Linux/macOS)

One-click install command:



curl -fsSL https://kilo.ai/cli/install | bash

Other installation methods:



# npm 安装

npm install -g @kilocode/cli



# Homebrew installation (macOS/Linux)

brew install Kilo-Org/tap/kilo



# pnpm 安装

pnpm add -g @kilocode/cli



# Arch Linux (AUR) Installation

paru -S kilo-bin

Other VS Code compatible editors

VS Code compatible editors such as Cursor, Windsurf, VSCodium, Gitpod, and Eclipse Theia can be installed via Open VSX Registry installation.

System Requirements

VS Code 1.84.0 or higher.

Windows users need to ensure PowerShell is added to the system PATH.


Initial configuration: connect a model provider

After installing the plugin, open the Kilo Code icon in the VS Code sidebar and enter the welcome page to start configuration.

Method 1: Register a Kilo account (fastest)

Register directly app.kilo.ai an account; after creating it, you can access 500+ models through the Kilo Gateway.

Supported models include GPT-5.5, Claude Opus 4.7, Claude Sonnet 4.6, Gemini 3.1 Pro Preview, etc., billed at the provider's original price with no markup.

After registering an account, you will get a certain free quota for trial.

Method 2: BYOK (bring your own API Key)

If you already have an API Key from a model provider, you can configure it directly:

Click on the Kilo Code welcome page Use your own API key.

Select your provider in the Provider drop-down menu (Anthropic, OpenAI, OpenRouter, Google AI Studio, etc.).

Enter the API Key and save.

BYOK mode is completely zero markup - Kilo does not earn any margin from your Key.

Common provider configurations

Provider Recommended use
Anthropic (Claude Sonnet 4.6) Architecture design, complex reasoning
OpenAI (GPT-5.5) Code generation, completion
Google (Gemini 3.1 Pro) Ultra-large context, document analysis
OpenRouter Multi-provider routing, one Key to access almost all models
Ollama / LM Studio Fully local operation, data never leaves the machine

DeepSeek configuration

Enter the project directory and run kilo:

cd /path/to/my-project

Enter /connect in the command bar, open the Connect Provider panel, search for deepseek, select DeepSeek, then fill in your DeepSeek API Key.

Enter /models to open the model selector and choose an available DeepSeek model:

DeepSeek V4 Flash

DeepSeek V4 Pro

Simplest configuration: let the Agent do it

After entering the plugin, just tell the Agent:



帮我配置 OpenAI 提供商,我的 API Key 是 sk-xxxx

Kilo Code has a built-in configuration management skill; the Agent will automatically read and write the kilo.jsonc configuration file, no need to manually edit any configuration.


First task: get started in 5 minutes

Quickly experience Kilo Code's basic workflow through a simple task.

Open Kilo Code

Click the Kilo Code icon (K-shaped) in the VS Code sidebar to open the chat panel.

Send your first task

In the input box at the bottom, describe what you want in natural language:



创建一个名为 hello.txt 的文件,内容写 "Hello, Kilo!"

Press Enter Send.

Review and approval

Kilo Code will analyze your request and then propose specific actions.

By default most tools are auto-approved; only executing Shell commands, accessing external directories, and reading sensitive files require your manual confirmation.

You will see:

The Agent's analysis process (Token usage shown in real time).

Specific operation steps (which file to create, what content to write).

Execution results.

Iterative Optimization

Kilo Code works iteratively; a task can be completed over multiple rounds of conversation:



第一轮:写一个 Python 函数,计算两个数的最大公约数

第二轮:加上类型注解和 docstring

第三轮:写单元测试

第四轮:重构成 class,支持多个数字的 GCD

Each round the Agent continues on top of the previous round; you do not need to re-describe the background.

Useful keyboard shortcuts

Operation Keyboard shortcut
Open the Kilo Code panel Sidebar icon
Switch Agent mode Cmd+. / Ctrl+.
Switch Agent mode in reverse Cmd+Shift+. / Ctrl+Shift+.
Switch Agent selector Input /agents

Agent modes: choose the right tool for the job

Kilo Code provides 4 built-in Agents, each with different tool permissions and behavior strategies.

Choosing the right Agent not only gives better results but also saves Token costs.

code (default)

Role: an all-around software engineer.

Tool permissions: full access - read files, write files, execute terminal commands, search the web, call MCP servers.

Suitable for: writing code, implementing features, bug fixes, everyday development.



切换方式:默认就是 code,或输入 /agents 选择

ask

Role: a read-only technical advisor.

Tool permissions: read-only - can read files, run cat/grep/git log and other read-only commands, with any write operations forbidden.

Suitable for: understanding code, explaining function logic, exploring project structure, learning technical concepts.



Typical usage:

"解释这个 useEffect 的执行顺序"

"这个 SQL 查询会有性能问题吗?"

"分析整个 src 目录的架构"

Analyzing a large codebase with ask mode, you can rest assured the Agent will not accidentally modify any files.

plan

Role: a tech lead and system designer.

Tool permissions: read-only + can write .kilo/plans/ planning files in the directory.

Suitable for: system design, feature planning, architecture decisions, implementation planning.



Typical usage:

"设计一个多租户 SaaS 平台的数据库架构"

"规划如何把单体应用拆分成微服务"

"在写代码之前,先给我一个分页功能的实施方案"

Best practice: plan first with plan mode, then switch to code mode to implement after confirming the approach.

debug

Role: an expert at systematically troubleshooting problems.

Tool permissions: full access (same as code).

Suitable for: tracking bugs, diagnosing errors, analyzing runtime issues.

debug mode takes a more systematic approach - analyze first, narrow the scope, then fix, rather than directly attempting to modify code.



Typical usage:

"运行 npm test 后报错,帮我找出根本原因"

"内存一直增长,帮我定位内存泄漏"

How to switch Agents

All three methods work:

Click next to the chat input box Agent selection drop-down menu.

Input /agents to trigger the selector.

Press Cmd+.(macOS) or Ctrl+.(Windows/Linux) to quickly cycle through.

Switch models mid-task

Kilo Code supports switching models at any time during a task without restarting the conversation:



/model anthropic/claude-sonnet-4-6    # 切换到 Claude Sonnet

/model openai/gpt-5-chat-latest       # 切换到 GPT-5

/model google/gemini-3-pro-preview    # 切换到 Gemini

You can also switch via the UI using the model selector at the top of the chat panel.


Intelligent completion (Autocomplete)

Kilo Code's Autocomplete analyzes the code before and after the cursor in real time as you type, giving inline completion suggestions.

How It Works

Uses FIM (Fill-in-the-Middle) technology, routed through the Kilo Gateway to a dedicated completion model.

Two available models:

Codestral (default): Mistral AI's code completion model, mature and stable.

Mercury Edit 2: Inception's diffusion-based FIM model, faster (requires BYOK with your own Key).

Basic Usage

Type normally in a code file.

When you see gray ghost text appear, press Tab to accept the suggestion.

Keep typing to ignore the suggestion.

Manual trigger

Press Cmd+L(macOS) or Ctrl+L(Windows/Linux) to actively request a completion at the current cursor position.

Needs to be enabled in VS Code settings kilo-code.new.autocomplete.enableSmartInlineTaskKeybinding, disabled by default.

Guide completions with comments

Writing comments above a function can greatly improve completion quality:

Example

Use binary search to find the target value in a sorted list, return -1 if not found

def

binary_search

(

arr

,

target

)

:

   

Kilo will give a high-quality complete implementation here

Completion vs chat, which to choose?

Scenario Recommended approach
Local code, single function Autocomplete
Multi-file changes, refactoring Chat (Agent)
Need to explain intent Chat (Agent)
Quickly fill in known patterns Autocomplete

Status bar display

The VS Code bottom status bar shows completion status and cumulative cost tracking; click to pause/resume completion.

If GitHub Copilot is installed, Kilo Code will automatically detect and warn about conflicts, suggesting you disable Copilot's inline completion for the best experience.


Context references: @files and code symbols

In the chat box, use the @ syntax to inject files, folders, functions, or URLs into the Agent's context, letting the Agent understand your code precisely.

File reference



@src/auth/login.ts 帮我分析这个登录函数有没有安全问题



@./src/components/ 帮我把这个目录下所有组件的 Props 类型整理成文档

Git reference



@git:diff 帮我给这次改动写 commit message

@git:log 分析最近 10 次提交,找出可能引入性能问题的改动

URL reference



@https://docs.anthropic.com/en/api/messages 根据这个 API 文档帮我写一个 Python 封装

Symbol reference

In supported IDEs, you can use @#函数名 or @#类名 to reference code symbols directly, and the Agent will automatically locate the corresponding code.

Prompt enhancement (Enhance Prompt)

Before sending, click next to the input box Enhance Prompt icon, and Kilo Code will automatically optimize your Prompt to make it clearer and more complete.



原始:帮我优化这个函数



增强后:请分析 @auth/login.ts 中的 loginUser 函数,

识别潜在的性能瓶颈,重构以减少数据库查询次数,

同时保持现有的错误处理逻辑,并补充类型注解


Custom Agents (Custom Modes)

When the 4 built-in Agents do not meet your needs, you can create custom Agents tailored to specific tasks or team workflows.

The simplest way: just let the Agent create it



创建一个叫 "docs-writer" 的自定义 Agent,

只能读文件和编辑 Markdown 文件,

专门用来写技术文档

Kilo will automatically create it in the .kilo/agents/ directory and generate the configuration file.

Manual creation: Markdown file

Create in the project .kilo/agents/docs-writer.md:



---

description: 专门用于编写和维护技术文档

mode: primary

color: "#10B981"

permission:

  edit:

    "*.md": "allow"

    "*": "deny"

  bash: deny

---



You are a technical documentation expert, skilled at:

- 编写清晰、结构良好的开发文档

- 遵循 Markdown 最佳实践

- 为 API 和函数创建有用的示例



专注于清晰性和完整性,只编辑 Markdown 文件。

The file name (remove the .md) is the Agent's name.

Global Agents vs project Agents

Range File location
Current projects .kilo/agents/my-agent.md
Global (all projects) ~/.config/kilo/agent/my-agent.md

Configurable properties

property Description
description Agent description, shown in the selector
model Lock a specific model, format provider/model
permission Tool permission control (allow / deny / ask)
mode primary(user selectable) / subagent(only for other Agents to call)
color Color marker in the selector
steps Maximum Agent iteration count, to prevent runaway
temperature Model sampling temperature

Team-shared Agents

Custom Agent files can be committed to a git repository, so all team members automatically share the same Agent configuration.

Especially suitable for unifying team workflows such as code review, documentation writing, and test generation.

Organization admins can also push organization-level Agents to all members through the Kilo platform, without each person configuring manually.


Memory Bank: remember your project

Memory Bank works by creating a AGENTS.md(or .kilo/agents.md) file in the project root directory to persist key project information, so the Agent has full project context on every startup.

Create AGENTS.md



帮我创建一个 AGENTS.md 文件,记录这个项目的架构决策、

技术栈、目录结构和开发规范

The Agent will scan your codebase and generate it automatically.

Typical AGENTS.md content



# Project: E-commerce platform backend



## 技术栈

- 运行时:Node.js 22 + TypeScript

- 框架:Fastify

- 数据库:PostgreSQL 16 + Prisma ORM

- 缓存:Redis 7

- 消息队列:BullMQ



## Directory Structure

src/

  routes/       # API 路由(按资源分组)

  services/     # 业务逻辑层

  repositories/ # 数据访问层

  middleware/   # 鉴权、日志、限流

  types/        # TypeScript 类型定义



## Development Guidelines

- 所有 API 返回格式:{ success, data, error, meta }

- 禁止在代码里硬编码任何 Secret,统一使用 process.env

- 数据库事务:所有写操作必须在事务中执行

- 错误处理:使用自定义 AppError 类,带 errorCode 和 httpStatus



## Architecture Decision Record

- 2026-03 选择 Fastify 而非 Express:性能测试下吞吐量高 2.5x

- 2026-05 引入 BullMQ:订单处理异步化,避免超时

Every time a new session starts, Kilo automatically loads this file, so the Agent immediately understands the entire project context without repeated explanations.


MCP integration: extend tool capabilities

Kilo Code has built-in MCP (Model Context Protocol) support, allowing one-click connection to dozens of external services.

Configure MCP through the Agent



帮我添加 GitHub MCP 服务器,我想让 Agent 能读取和创建 PR

The Agent will complete the configuration automatically, no need to manually edit JSON files.

Common MCP servers

Service What You Can Do
GitHub Read repositories, create PRs, manage Issues
PostgreSQL Directly query and operate databases
Slack Send messages, read channel history
Browserbase Cloud browser automation
Filesystem Extend filesystem access permissions

Manual configuration (kilo.jsonc)



{

  "mcpServers": {

    "github": {

      "command": "npx",

      "args": ["-y", "@modelcontextprotocol/server-github"],

      "env": {

        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxx"

      }

    }

  }

}

It is recommended to use Agent configuration rather than manual editing; the Agent will help verify whether the configuration is correct.


CLI usage: Kilo in the terminal

Kilo CLI shares the same sessions, configuration, and context with the VS Code plugin, allowing seamless switching.

Basic Usage



# Start interactive dialogue

kilo



# Execute a single task (non-interactive)

kilo "帮我检查 src 目录下有没有未使用的 import"



# Fully autonomous run (CI/CD scenario, no confirmation prompts needed)

kilo run --auto "运行测试,如果失败则分析原因并修复"

--auto mode turns off all permission confirmation prompts; the Agent can perform any operation. Only use it in trusted environments.

Switch Agents



kilo --agent ask "解释这个项目的架构"

kilo --agent debug "分析为什么内存使用一直增长"

kilo --agent plan "设计用户认证系统的方案"

Continue sessions across platforms

Tasks started in the terminal can be continued in the Kilo Code panel in VS Code, with session history fully synced.

Remote use over SSH



# Start Kilo CLI on remote server

ssh user@server

kilo "帮我检查 Nginx 日志,找出频繁 500 错误的原因"



# After returning to local, continue viewing the same session in VS Code


Cost management and model selection

Understand Kilo Code's cost structure, saving strategies, and model selection recommendations.

Understanding the cost structure

Kilo Code cost = Input Tokens × input price + Output Tokens × output price.

The Token usage and estimated cost of this call are shown in real time below each message.

Auto Model: smart routing to save costs

Kilo Code's Auto Model feature automatically selects the most suitable model based on the task type:

Simple Q&A → a cheap, fast model (e.g. GPT-4o-mini).

Complex code generation → a more capable model (e.g. Claude Sonnet 4.6).

Architecture design → the frontier model with the strongest reasoning ability.

How to enable: select it in the model picker Auto.

Practical tips for saving Tokens

Reference precisely, don't stuff in the whole directory:



不推荐:@./src/   分析这个项目

推荐:@src/auth/login.ts @src/auth/middleware.ts 分析登录流程

Use ask mode to explore, code mode to implement: ask mode forbids write operations, the system Prompt is shorter, and Token cost is lower.

First use ask to understand the code, then switch to code to execute after deciding on a plan.

Clean up the context promptly:



/compact    # 压缩当前会话的历史上下文,节省后续 Token

Turn off unused MCP servers: unused MCP servers cram large amounts of tool descriptions into the system Prompt, wasting Tokens.

Keep only the servers currently needed.

Set a cost cap: configure it in Kilo Code settings Cost Controls, set a maximum cost limit for a single task to avoid accidental overspending.

Auto top-up

in app.kilo.ai Enable Auto Top-Ups, automatically top up when the balance is low, so ongoing tasks won't be interrupted by insufficient balance.

Recommended models

Recommended models by task type:

Task Recommended model
Daily code generation Claude Sonnet 4.6 / GPT-5.5
Architecture design Claude Opus 4.7
Quick debugging Grok Code 1 Fast
Very large codebase Gemini 3.1 Pro (extra-large context)
Cost-sensitive DeepSeek V4 Pro (high cost-performance)
Fully offline Ollama local models

Comparison with Cursor / GitHub Copilot

The comparison helps you more clearly understand Kilo Code's positioning and advantages.

vs Cursor

Dimension Cursor Kilo Code
Nature VS Code fork (standalone editor) VS Code extension (keeps the original editor)
Switch Cost Requires migrating config, extensions, habits Zero cost, use your current editor directly
Open source Closed source MIT open source
Pricing Subscription + markup Zero markup, charged at model list price
Auditable Prompt and context cannot be audited All Prompts and decisions are viewable

vs GitHub Copilot

Dimension GitHub Copilot Kilo Code
Main capabilities Code completion + basic chat Full AI Agent (executes tasks, controls terminal and browser)
Model Limited options provided by Microsoft/GitHub Free switching among 500+ models
Customization Limited Fully customizable Agent, rules, instructions
Suitable scenarios Mainly completion, light AI assistance Need the Agent to complete tasks autonomously

Resource

Documentation home https://kilo.ai/docs/
GitHub repository https://github.com/Kilo-Org/kilocode
VS Code Marketplace https://marketplace.visualstudio.com
AI learning path https://path.kilo.ai
Discord community https://kilo.ai/discord
YouTube tutorials https://kilo.ai/youtube
Migrating from Cursor https://kilo.ai/docs/getting-started/migrating