Các tính năng chính
Multi-model Support
OpenCode hỗ trợ 75+ LLM providers thông qua AI SDK và Models.dev.
Providers phổ biến
| Provider | Models | Ghi chú |
|---|---|---|
| Anthropic | Claude 4, Claude 3.5 | Khuyến nghị cho coding |
| OpenAI | GPT-4o, o1, o3 | Hỗ trợ ChatGPT Plus/Pro |
| Gemini 2.5, Gemini Flash | Vertex AI | |
| DeepSeek | DeepSeek Reasoner | Giá rẻ, chất lượng tốt |
| Ollama | Llama, Qwen, Mistral | Chạy local, miễn phí |
| OpenRouter | 100+ models | Gateway cho nhiều providers |
Chuyển đổi model
/models
Chọn model phù hợp với task - dùng model nhỏ cho tasks đơn giản, model lớn cho tasks phức tạp.
MCP Tools Integration
Model Context Protocol (MCP) cho phép mở rộng khả năng của OpenCode.
Ví dụ: Context7
Tìm kiếm documentation:
{
"mcp": {
"context7": {
"type": "remote",
"url": "https://mcp.context7.com/mcp"
}
}
}
Sử dụng:
Configure a Cloudflare Worker to cache API responses. use context7
Ví dụ: Grep (Vercel)
Tìm code examples từ GitHub:
{
"mcp": {
"gh_grep": {
"type": "remote",
"url": "https://mcp.grep.app"
}
}
}
Local MCP Server
{
"mcp": {
"my-mcp": {
"type": "local",
"command": ["npx", "-y", "my-mcp-package"]
}
}
}
Custom Commands
Tạo commands riêng cho workflow của bạn.
Ví dụ
Trong opencode.json:
{
"commands": {
"review": {
"description": "Code review PR hiện tại",
"prompt": "Review code changes trong PR này. Tập trung vào bugs, security issues, và best practices."
},
"test": {
"description": "Viết tests cho file",
"prompt": "Viết unit tests cho file @{file}. Dùng testing framework đã có trong project."
}
}
}
Sử dụng:
/review
/test src/utils/helper.ts
Skills System
Skills là reusable instructions mà agent có thể load khi cần.
Tạo skill
Tạo file .opencode/skills/git-release/SKILL.md:
---
name: git-release
description: Tạo release notes và version bump
---
## Nhiệm vụ
- Draft release notes từ merged PRs
- Đề xuất version bump (major/minor/patch)
- Tạo command `gh release create`
## Khi nào dùng
Khi chuẩn bị tagged release cho project.
Agent sẽ tự động load skill khi cần thiết.
Thư mục skills
- Project:
.opencode/skills/<name>/SKILL.md - Global:
~/.config/opencode/skills/<name>/SKILL.md
Plan mode vs Build mode
| Mode | Phím tắt | Mô tả |
|---|---|---|
| Plan | Tab | Agent chỉ gợi ý approach, không sửa code |
| Build | Tab | Agent thực hiện thay đổi |
Workflow
- Plan mode: Mô tả feature cần làm
- Review plan, đưa feedback
- Build mode: Yêu cầu agent thực hiện
File References
Dùng @ để reference files trong prompt:
Explain authentication flow trong @src/auth/middleware.ts
OpenCode sẽ fuzzy search và load file vào context.
Image Support
Kéo thả image vào terminal để thêm vào prompt:
Làm giống design trong [Image #1]
Undo/Redo
/undo # Hoàn tác thay đổi gần nhất
/redo # Làm lại thay đổi đã undo
Có thể chạy /undo nhiều lần để undo nhiều thay đổi.
Share Conversations
/share
Tạo link chia sẻ conversation. Hữu ích khi cần review với team.
Ví dụ: opencode.ai/s/4XP1fce5
AGENTS.md
File AGENTS.md ở root project chứa context về codebase. OpenCode tự động tạo khi chạy /init.
Bạn nên commit file này vào Git để OpenCode hiểu project structure và coding patterns.
Themes & Keybinds
Customize giao diện và phím tắt:
/theme
Xem thêm:
IDE Integration
OpenCode có thể chạy như extension trong:
- VS Code
- JetBrains IDEs
- Neovim
Xem thêm: opencode.ai/docs/ide
GitHub/GitLab Integration
Làm việc trực tiếp với PRs và issues:
/github
/gitlab
Xem thêm: