Opencode logo

Opencode

Community
znlgis
opencode

Use when configuring a model-agnostic terminal AI coding agent through opencode.json — $schema validation, permission allow/ask/deny for bash/edit/webfetch, small_model cost routing, MCP local|remote servers, custom agents and commands, tui.json themes, opencode run for CI and opencode serve for SDK; also for /undo failing outside a Git repo, no model after /connect, and config keys silently merged instead of replaced. OpenCode v1.19.4.

Overview

Publisherznlgis
Repositoryopengis-skills
Skill nameopencode
Stars
76
Forks
12
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by znlgis on GitHub. Read the source before you install it.

Installation

Install the Opencode AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/znlgis/opengis-skills/tree/main/ai/opencode
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/znlgis/opengis-skills.git /tmp/opengis-skills
mkdir -p .claude/skills
cp -r /tmp/opengis-skills/ai/opencode .claude/skills/opencode
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Opencode in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Opencode on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Opencode is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

项目地址: https://github.com/anomalyco/opencode

官网 / 文档: https://opencode.ai | 配置 Schema: https://opencode.ai/config.json | TUI Schema: https://opencode.ai/tui.json

许可证: MIT

版本: v1.19.4(截至 2026-10,实测 releases/latest 重定向与 npm opencode-ai latest 一致);迭代快,以本机 opencode --version 为准

注意: OpenCode 迭代非常快,命令、配置字段与模型名称请以你当前版本的 opencode --help、TUI 内 /help 及在线 JSON Schema 为准。

概述

OpenCode 是一个以终端为核心的开源 AI 编码智能体(区别于 IDE 内联补全),可读代码、改代码、跑命令、调用工具,自主完成多步开发任务。核心理念是「模型无关 + 配置即代码」:

  • 模型无关:基于 AI SDK 与 Models.dev 支持 75+ 提供商,云端(Claude/GPT/Gemini/Qwen)与本地(Ollama/LM Studio/llama.cpp)自由切换。
  • 权限系统:每类工具(edit/bash/read/webfetch 等)可设 allow/ask/deny,支持按命令、路径的细粒度规则。
  • 上下文与成本可控:自动压缩(compaction)、工具输出裁剪(prune)、小模型分流(small_model)。
  • 配置即代码:opencode.json、AGENTS.md、自定义命令/Agent/Skill 都是纯文本,可提交进 Git、团队共享。
  • 三种形态:TUI(终端交互)、CLI(opencode run 脚本化/CI)、Server/SDK(opencode serve 暴露 HTTP API)。
  • Git 快照:/undo、/redo 依赖项目为 Git 仓库,可随时撤销 AI 改动。

安装

bash
# 一键安装脚本(最简单)
curl -fsSL https://opencode.ai/install | bash

# 包管理器
npm install -g opencode-ai          # Node 生态(npm/bun/pnpm/yarn)
brew install anomalyco/tap/opencode # macOS/Linux 官方 tap(更新最及时)
scoop install opencode              # Windows
sudo pacman -S opencode             # Arch
mise use -g opencode
nix run nixpkgs#opencode

opencode --version                  # 验证

Windows 推荐在 WSL 中使用;TUI 在 WezTerm/Alacritty/Ghostty/Kitty 等现代终端渲染更佳。


快速上手

bash
cd your-project        # 建议是 Git 仓库(/undo /redo /快照依赖 Git)
opencode               # 启动 TUI

TUI 内常用斜杠命令:

text
/connect    # 接入模型提供商(粘贴 API Key;或选 OpenCode Zen 网关)
/models     # 选择当前模型
/init       # 生成项目级 AGENTS.md(让 OpenCode 了解你的项目)
/undo /redo # 基于 Git 快照撤销/重做 AI 改动
/share      # 生成会话分享链接
/help       # 查看全部命令

也可用环境变量提供密钥(如 ANTHROPIC_API_KEY、OPENAI_API_KEY),启动时自动识别。

CLI / 无头模式(脚本与 CI)

bash
opencode run "为 utils.ts 补充单元测试并运行"      # 单次执行
opencode run -m anthropic/claude-sonnet-4-5 "重构登录模块"
opencode serve --port 4096                         # 启动 HTTP Server(配合 SDK)

配置体系(核心)

OpenCode 支持 JSON / JSONC(带注释)。务必加 $schema 获得校验与补全。项目根配置文件 opencode.json:

jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "model": "anthropic/claude-sonnet-4-5",
  "small_model": "anthropic/claude-haiku-4-5",
  "autoupdate": true,
  "permission": {
    "edit": "allow",
    "bash": { "git push": "ask", "rm *": "deny", "*": "allow" },
    "webfetch": "ask"
  }
}

配置位置与优先级

角色路径
全局配置~/.config/opencode/opencode.json
项目配置(可提交 Git)项目根 opencode.json
TUI 设置(主题/键位)~/.config/opencode/tui.json 或项目根 tui.json
自定义路径 / 目录OPENCODE_CONFIG / OPENCODE_CONFIG_DIR 环境变量

.opencode/ 与 ~/.config/opencode/ 下使用复数子目录:agents/、commands/、plugins/、skills/、tools/、themes/。

配置优先级(后者覆盖前者):组织远程 < 全局 < 自定义 < 项目 < .opencode/ < 内联 < 托管。覆盖,不替换。

TUI 专属配置(tui.json)

jsonc
{
  "$schema": "https://opencode.ai/tui.json",
  "theme": "tokyonight",
  "diff_style": "auto",
  "attention": { "enabled": true, "notifications": true, "sound": true }
}

opencode.json 旧的顶层 theme/keybinds/tui 键已废弃,会自动迁移到 tui.json。


自定义 Agent / 命令 / 工具

jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "default_agent": "build",
  "agent": {
    "reviewer": {
      "description": "只读代码评审,不允许修改",
      "model": "anthropic/claude-sonnet-4-5",
      "permission": { "edit": "deny", "bash": "deny" }
    }
  },
  "mcp": {
    "playwright": { "type": "local", "command": ["npx", "@playwright/mcp@latest"], "enabled": true },
    "jira": { "type": "remote", "url": "https://jira.example.com/mcp", "enabled": false }
  }
}
  • Agent:可定义只读评审、文档撰写等子代理,并限定模型与权限。
  • 自定义命令:放 commands/*.md,复用提示词模板。
  • MCP 扩展:type: local(启动本地进程)或 type: remote(HTTP),为 Agent 增加外部工具能力。
  • 规则上下文:AGENTS.md(项目根)描述项目约定、构建/测试命令,OpenCode 每次会话注入。

Token 优化与省钱配置

手段配置/做法
小模型分流small_model 处理标题生成、压缩等轻量任务,主任务用强模型
上下文自动压缩长会话触发 compaction,把历史摘要化,避免无限膨胀
工具输出裁剪大输出(如长日志)自动 prune,仅保留关键片段
按需切模型/models 或 opencode run -m ...,简单任务用便宜模型
提示缓存在 provider 选项中开启缓存,复用系统提示降低费用
收紧权限bash/webfetch 设 ask/deny,减少无谓工具调用

典型工作流

bash
# 1. 进入项目并初始化上下文
cd my-app && opencode
> /init                       # 生成 AGENTS.md

# 2. 接入并选择模型
> /connect                    # 接入 Anthropic / OpenCode Zen
> /models                     # 选 claude-sonnet-4-5

# 3. 交给它做多步任务(它会读文件、改代码、跑命令)
> 实现用户注册接口,加上输入校验与单元测试,并运行测试

# 4. 审阅与撤销
> /undo                       # 不满意则基于 Git 快照回滚

# 5. CI 中无头运行
opencode run "升级依赖并修复由此产生的编译错误"

常见问题(FAQ)

问题解决
/undo 不可用当前目录不是 Git 仓库;git init 后再用
没有可用模型先 /connect 接入提供商或设置 ANTHROPIC_API_KEY 等环境变量,再 /models
配置不生效注意「合并而非替换」与优先级:项目配置覆盖全局;用 $schema 校验拼写
主题/键位改了没反应这些属于 TUI 设置,应写在 tui.json 而非 opencode.json
Token 消耗过快设 small_model、收紧 permission、用便宜模型处理简单任务、开启提示缓存
想接公司内部工具通过 mcp(local/remote)接入 MCP server,并在 Agent 权限内开放
升级后命令变了以 opencode --help / /help 与官网 Schema 为准(迭代快)

AI 使用建议

  • 用户提到「终端 AI 编码代理」「opencode.json 配置」「模型无关」「省 Token / 控制成本」「自定义 Agent / MCP」时加载本技能。
  • 区分三种形态:交互用 TUI,脚本/CI 用 opencode run,集成用 opencode serve + SDK。
  • 配置问题先排查「合并 vs 替换」与优先级;主题/键位归 tui.json,行为/模型/权限归 opencode.json。
  • 生成配置时始终带 "$schema",并优先用细粒度 permission 收敛 bash/webfetch 风险。
  • 由于版本迭代快,生成命令/字段后提醒用户以本机 --help 与在线 Schema 校验。

相关技能


参考资源

Frequently asked questions

What does the Opencode AI skill do?

Use when configuring a model-agnostic terminal AI coding agent through opencode.json — $schema validation, permission allow/ask/deny for bash/edit/webfetch, small_model cost routing, MCP local|remote servers, custom agents and commands, tui.json themes, opencode run for CI and opencode serve for SDK; also for /undo failing outside a Git repo, no model after /connect, and config keys silently merged instead of replaced. OpenCode v1.19.4.

Why use Opencode on TypingMind?

Because you install it once and use it with any model. Opencode is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Opencode in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/znlgis/opengis-skills/tree/main/ai/opencode. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Opencode?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Opencode?

As many as you like. As long as a model supports skills, you can use Opencode with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Opencode AI skill free?

Yes. It is published on GitHub by znlgis under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇