Skip to content

使用教程

OpenCode 的常见入口是终端 TUI。建议每个项目保留自己的 opencode.json,并用 /init 生成项目上下文。

进入项目

bash
cd /path/to/your/project
opencode

初始化项目上下文

首次进入项目后,建议先初始化项目上下文:

text
/init

这会让 OpenCode 分析项目并生成 AGENTS.md。如果内容准确,可以把它提交到 Git,方便后续会话持续理解项目结构和编码约定。

只读分析

text
Read the current project structure and tell me the start command, build command, and main directory responsibilities. Do not modify files.

小范围任务

text
Fix this build error. First list the files you need to inspect and your plan; do not edit before I confirm.

切换模型

text
/models

重新连接 provider

text
/connect

推荐工作流

  1. 每个项目保留自己的 opencode.json
  2. provider id 和 /connect 中输入的 id 保持一致,例如都用 xikapi
  3. 不要把 API Key 写入项目仓库。
  4. 先只读分析,再授权修改。
  5. 高风险命令先让 OpenCode 解释影响范围。
  6. 修改后运行测试或构建。

参考链接