opencode 初尝试
2026-01-20 tech opencode 3 mins 9 图 1262 字

最近opencode很火,我也在电脑上装了。这篇文章记录一下安装和使用过程。
官方说明
OpenCode is an open source agent that helps you write code in your terminal, IDE, or desktop.
- [*]LSP enabled Automatically loads the right LSPs for the LLM。自动识别编程语言。
- [*]Multi-session Start multiple agents in parallel on the same project。多个对话同时进行。
- [*]Share links Share a link to any session for reference or to debug。分享编程过程。
- [*]Claude Pro Log in with Anthropic to use your Claude Pro or Max account
- [*]ChatGPT Plus/Pro Log in with OpenAI to use your ChatGPT Plus or Pro account
- [*]Any model 75+ LLM providers through Models.dev, including local models。支持各种AI模型。
- [*]Any editor Available as a terminal interface, desktop app, and IDE extension。什么编辑器,都能用OpenCode。
安装
最简单的方式是使用Homebrew:
brew install anomalyco/tap/opencode

启动OpenCode并配置模型:
cd ~/Workspace # 进入你的工作目录
opencode # 启动OpenCode

在TUI界面中,输入 /connect 配置模型提供商:
- 新手推荐: OpenCode Zen(经过验证的模型)
- 进阶选择: Claude Sonnet 4.5(编程能力强)
首次使用,运行 /init 让OpenCode分析你的项目结构。

基础操作
掌握这几个核心命令就能开始使用:
/help # 查看所有命令
@文件名 # 引用文件内容
!命令 # 执行shell命令
/undo # 撤销操作
/redo # 重做操作
Tab键 # 切换Plan/Build模式
Esc # 退出、打断当前操作
初上手
先拿我的blog项目进行练手:
请分析我这个blog项目的结构和功能,然后告诉我可以用OpenCode做什么改进?






其他类似的上手问答工作都可以试试:
- 检查macOS版本
- 显示内存使用情况
- 列出Homebrew安装的包
- 检查磁盘空间