OpenCode Setup Guide: My AI Programming Workflow

OpenCodeAI coding toollocal AI developmentPlan vs Build modeOpenCode tutorial
Published·Modified·

Previously, I used VS Code + GitHub Copilot as my AI programming solution, but due to increasing Copilot quota limits, I had to find an alternative. About six months ago, I started using OpenCode, and it has since become my primary AI coding tool. Although it took some time to get used to, I now find it increasingly convenient, so I'm writing this article to share my OpenCode programming workflow.

image.png

Note: This article is not suitable for beginners; it is recommended for readers with some programming experience.

About OpenCode

OpenCode is an open-source AI coding tool that offers multiple usage methods, including a terminal interface (TUI), desktop application, WebUI, and IDE extensions.

Installing OpenCode

You can install it directly using the following commands:

# Install using pnpm
pnpm install -g opencode-ai
# Install using bun
bun install -g opencode-ai

Configuring and Using OpenCode

Using WebUI

OpenCode provides multiple usage methods, including TUI, desktop app, and WebUI. I currently use WebUI the most because it allows for quick switching between multiple projects and models. Therefore, the following introduction focuses on the WebUI usage.

To access OpenCode via the web interface, simply enter your project directory and run the command opencode web, as shown below:

CleanShot 2026-06-03 at 10.30.21@2x.png

Then, follow the prompt to access the interface at http://IP:4096.

CleanShot 2026-06-03 at 10.33.08@2x.png

Two Modes

Before starting, it's important to understand OpenCode's two modes: Plan and Build.

  • Plan Mode: A read-only mode that does not modify or create any files. It is ideal for discussing requirements with the AI first.
  • Build Mode: Automatically executes code modifications, creations, and deletions. It is suitable for executing tasks after requirements are confirmed.

I recommend using Plan mode first to discuss specific requirements with the AI. Once the requirements are confirmed, switch to Build mode to execute the task. This approach helps generate better, more expected code compared to jumping straight into Build mode. You can switch modes directly within the chat dialog.

CleanShot 2026-06-03 at 10.36.51@2x.png

Free Models

OpenCode periodically offers free models. You can view available free models at the bottom of the chat dialog under "OpenCode Zen." Recent free models include:

  • DeepSeek V4 Flash Free
  • MiMo V2.5 Free
  • MiniMax M3 Free

CleanShot 2026-06-03 at 10.39.28@2x.png

A great feature of OpenCode is that using these free models requires no account registration or configuration; you can switch to them directly. I've noticed a pattern: top-tier models released in China are often provided for free by OpenCode for a certain period, though these free models change frequently.

Configuring Additional Models

As the name suggests, OpenCode is highly open and supports almost all AI large models available on the market. You can choose to integrate suppliers via settings or configure custom API access (as long as it is compatible with the OpenAI format).

CleanShot 2026-06-03 at 10.43.35@2x.png

Viewing Code

I do not recommend using WebUI for viewing code as it can be inconvenient. Instead, I suggest pairing it with a professional editor. My preferred editors are Zed and VS Code.

Initializing Projects

To fully leverage AI coding tools, avoid diving straight into writing code without preparation, as this may not yield expected results. Enter the /init command in the chat dialog. OpenCode will scan the project structure, technology framework, components, etc., and organize the output into an AGENTS.md file. When writing code later, the AI model will reference the content within AGENTS.md (except for weaker models). If the content does not meet your expectations, you can manually adjust or supplement it.

CleanShot 2026-06-03 at 10.52.09@2x.png

For more reusable specifications, functions, or documentation, you can ask OpenCode to organize them into "skills" to improve code quality.

How Effective is OpenCode for Coding?

Model Capability Differences

OpenCode is essentially an AI coding tool, and the final result heavily depends on the capabilities of the large language model. The quality of code generated varies significantly between different models. My commonly used models include:

  • GPT-5.5, GPT-5.4
  • DeepSeek V4
  • Mimo V2.5
  • Qwen latest models

If possible, using flagship models is the best option.

Usage Tips

  • Use Plan mode to discuss feature requirements first, then switch to Build mode to execute. Do not start with Build mode unless the requirements are very simple and clear.
  • Always use the /init command to initialize and organize the project.
  • When modifying files, describe and specify the file clearly rather than letting the AI guess. Guessing consumes more tokens and may be less accurate.
  • Organize specifications or reusable functions into skills.
  • Use higher-quality large models whenever possible.

Project Maintainability

AI programming has certainly lowered the barrier to entry, but not everyone can become a good developer, especially for projects requiring long-term maintenance. If you do not understand the technical framework, project structure, or business logic, the project is destined to be unsustainable and unmaintainable later. If you cannot clearly explain the framework and workflow to the AI, it cannot provide the code you want. Therefore, with the same tools and models, some developers produce clear, sustainable project structures, while others create a mess that requires a complete rewrite. The difference lies not in the AI, but in the developer's logical ability and engineering literacy.

Before starting a new project, I personally confirm the development language, framework, components, standards, directory structure, and routing organization. I only use the stack I am familiar with to ensure the project remains under control. In a sense, at this stage, you act as an architect or product manager rather than just a programmer.

Other Notes

Upgrading OpenCode Version

# Upgrade OpenCode version
opencode update

Configuration File

OpenCode global configuration is located at: ~/.config/opencode/opencode.json

Documentation

OpenCode now provides Chinese documentation. It is recommended to skim through it before use to significantly improve efficiency and results: https://opencode.ai/docs/zh-cn/

Conclusion

In summary, OpenCode has become my primary AI coding tool thanks to its open and flexible model integration and convenient WebUI. However, tools are merely amplifiers; the long-term maintainability of a project ultimately depends on the developer's engineering literacy and architectural capabilities. By effectively using /init, combining Plan/Build modes, and leveraging high-quality models, you can achieve twice the result with half the effort. Happy coding!