Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

OpenCode Skills

OpenCode Skills

In OpenCode,Agent Skillsis a mechanism for encapsulating reusable behaviors, defined through SKILL.md files, enabling the LLM toload on demand and execute on demandspecific capabilities.

Compared with ordinary prompts, skills are closer to modular capability units that can be reused across multiple projects or teams.

Skills are OpenCode'scapability plugin system, which upgrades AI behavior from one-off prompts to reusable capability modules, making the development process more standardized and composable, and suitable for complex engineering systems.

Skills exist as Markdown files; they do not execute functions, but achieve efficient and reusable transfer of experience through on-demand, progressive loading.

The biggest difference between Skills and traditional Prompts is: on-demand loading + progressive disclosure (only stuffing the thick SOP into the context when needed, greatly saving tokens).

Comparison Item Ordinary Prompt Skills mechanism
Must be re-described every time Is No (described only once)
Context length usage Fully stuffed in every time Progressive loading (reads the full content only when triggered)
Consistency Depends on the quality of each prompt High (fixed SOP + templates)
Reusability Manual copy and paste Auto-matching / slash commands / project sharing
Maintenance method Changing the prompt once means re-sending it Modify the SKILL.md file, effective globally / per project

Core mechanism

Skills are managed through the built-in skill tool, with the following workflow:

  1. Scan local and global skill directories
  2. Expose the list of available skills in the context
  3. The agent automatically selects skills based on the task
  4. Load SKILL.md content on demand

This mechanism avoids loading all rules at once, improving performance and context utilization.

The Core Structure of a Skill

The core of Skills is: one folder + one SKILL.md file.

The SKILL.md file contains:

A Skill is essentially a Markdown file (the filename is fixed as SKILL.md)

my-skill/

└── SKILL.md   (唯一必需)

SKILL.md basic template:

---

name: pdf-processing

description: 从 PDF 中提取文本和表格,填写表单,并合并文档

---



# PDF 处理



## Use Cases

Use when operating on PDF files, for example:



- 提取 PDF 文本或表格数据

- 填写 PDF 表单

- 合并多个 PDF 文件



## 提取文本

- 使用 `pdfplumber` 提取文本型 PDF 内容  

- 扫描版 PDF 需配合 OCR 工具  



## 填写表单

- 读取 PDF 表单字段  

- 按输入数据填充并生成新文件  

Minimal required example:

---

name: skill-name

description: 说明该 Skill 的功能以及适用场景

---

Example with optional fields:

---

name: pdf-processing

description: 从 PDF 中提取文本和表格,填写表单,并合并文档

license: Apache-2.0

metadata:

  author: example-org

  version: "1.0"

---

Field Required Description
name Is Skill name, up to 64 characters, may only use lowercase letters, digits and -, and cannot start or end with - at the beginning or end
description Is Description of features and use cases, up to 1024 characters, cannot be empty
license No License name or a pointer to the license file bundled with the Skill
compatibility No Environment and dependency notes (products, system packages, network permissions, etc.), up to 500 characters
metadata No Custom key-value pairs for extending metadata (e.g., author, version)
allowed-tools No List of allowed tools (space-separated, experimental feature)

If you need reference materials, reference examples, or execution scripts, you can copy the Skill's directory structure:

my-skill/

├── SKILL.md      # 必需:指令 + 元数据

├── scripts/      # 可选:可执行代码

├── references/   # 可选:文档资料

└── assets/       # 可选:模板、资源

How Skills Work

Skills use progressive loading to manage context efficiently:

This design keeps the AI fast while letting it fetch more information on demand.


File placement

Each skill needs its own folder, containing a SKILL.md file (note: the filename must be all uppercase). OpenCode automatically searches the following six locations:

Type Path Scope of application
Project configuration .opencode/skills//SKILL.md Only the current project
Global configuration ~/.config/opencode/skills//SKILL.md All projects
Project Claude-compatible .claude/skills//SKILL.md Only the current project
Global Claude-compatible ~/.claude/skills//SKILL.md All projects
Project agent-compatible .agents/skills//SKILL.md Only the current project
Global agent-compatible ~/.agents/skills//SKILL.md All projects

A typical project directory structure is as follows:



your-repo/

├── .opencode/

│   └── skills/

│       ├── git-release/

│       │   └── SKILL.md      ← 发版流程技能

│       ├── code-review/

│       │   └── SKILL.md      ← 代码审查技能

│       └── api-doc/

│           └── SKILL.md      ← API 文档编写技能

├── src/

└── package.json


Discovery mechanism

OpenCode's skill discovery has two levels:

Skills from both levels are merged and provided to the agent together. If a project-local skill has the same name as a global skill,the project-local skill takes priority。


Writing SKILL.md

1. Frontmatter fields

Each SKILL.md The file must start with YAML frontmatter (i.e., the --- section). OpenCode only recognizes the following fields; unknown fields are automatically ignored:

Field Required Type Description
name Required String The skill's unique identifier, which must match the containing folder name and follow naming rules
description Required String The skill's description; the agent decides whether to invoke based on this content, 1–1024 characters
license Optional String The license type of the skill content, e.g. MIT、Apache-2.0
compatibility Optional String Indicates which tool it's compatible with, e.g. opencode、claude
metadata Optional object (string-to-string mapping) Custom additional metadata such as target audience, workflow type, etc., with string keys and values

2. Naming rules

name The field's value must satisfy all of the following conditions simultaneously, otherwise the skill won't load:

Equivalent regular expression:

^[a-z0-9]+(-[a-z0-9]+)*$

Valid naming examples:git-release、api-doc、code-review、deploy2prod

Invalid naming examples:Git-Release(contains uppercase),-release(starts with - ),git--release(consecutive --)

3. Writing the description

description The field's content directly affects whether the agent can correctly select and invoke the skill.It's recommended that the description be specific and clear, explaining what the skill does and in what scenarios it's used, avoiding being too vague:

4. Complete example

Create in the project .opencode/skills/git-release/SKILL.md, with the following content:

Example


name

:

git

release

description

:

Create consistent releases and changelogs

license

:

MIT

compatibility

:

opencode

metadata

:

  audience

:

maintainers # Custom metadata: target audience

  workflow

:

github # Custom metadata: workflow type


 

What I

do

Draft release notes from merged PRs

Propose a version bump

Provide a copy

pasteable gh release create command

 

When to use me

Use

this

when you are preparing a tagged release.

Ask

clarifying questions

if

the target versioning scheme is unclear.

The name value in the frontmatter must match the folder name. In this example, the folder name is git-release, therefore name , so it must also be written as git-release, otherwise the skill won't be recognized.


How agents discover and load skills

After OpenCode starts, it injects all currently available skills in XML format into the skill tool's description. The agent can view the tool description to learn which skills are available:





  

    git-release

    Create consistent releases and changelogs

  

  

    code-review

    Perform structured code reviews with consistent criteria

  



When the agent determines a skill is relevant to the current task, it proactively calls the skill tool to load the skill's full SKILL.md of contents:

skill({ name: "git-release" })

Once loaded, the instructions and context information defined in the skill enter the agent's working memory, thereby influencing subsequent behavior and output. The skill itself doesn't automatically perform any operations; it only provides the agent with additional context and behavior guidelines.


Configure skill permissions

in opencode.json In it, use permission.skill The field controls which skills the agent can access, supporting both exact names and Glob wildcard matching:

Example

{

  "$schema": "https://opencode.ai/config.json",

  "permission": {

    "skill": {

      "*": "allow", // Fallback rule: allow loading all skills by default

      "pr-review": "allow", // Exact match: allow loading the pr-review skill

      "internal-*": "deny", // Glob match: deny loading all skills starting with internal- (completely hidden from the agent)

      "experimental-*": "ask" // Glob match: user confirmation required before loading skills starting with experimental-

    }

  }

}

The specific effects of the three permission actions on skills are as follows:

Permission value effect
"allow" Skill loads immediately, no confirmation needed from the agent
"deny" Skill is completely hidden from the agent, it won't appear in the list, and the agent can't perceive its existence
"ask" A confirmation prompt pops up when the agent tries to load the skill, and the user decides whether to allow it

Override permissions per agent

Different agents may need access to different skill sets; you can configure permissions for each agent individually, overriding global defaults.

1. Configure in a custom agent's frontmatter

# 文件路径:~/.config/opencode/agents/my-agent.md

---

permission:

  skill:

    "documents-*": "allow"    # 该代理可以加载所有 documents- 开头的技能

                               # Other skills follow global permission configuration

---

 

You are a documentation assistant.

2. Configure for built-in agents in opencode.json



{

  "$schema": "https://opencode.ai/config.json",

  "agent": {

    "plan": {                          // 内置代理名称

      "permission": {

        "skill": {

          "internal-*": "allow"        // plan 代理可以加载 internal- 开头的技能,

                                       // even if it is set to deny in the global configuration

        }

      }

    }

  }

}


Disable the skill tool

For agents that don't need skills at all, you can directly disable the skill tool. Once disabled, the list will be completely removed from the agent's context, saving Token consumption and preventing the agent from trying to load any skills.

1. Disable in a custom agent's frontmatter

Example


tools

:

  skill

:

false    

Completely disables skill functionality for that agent; the available_skills list won't appear in the context


 

You are a quick answer assistant. Just answer questions directly.

2. Disable for built-in agents in opencode.json

Example

{

  "$schema": "https://opencode.ai/config.json",

  "agent": {

    "plan": {

      "tools": {

        "skill": false // The plan agent doesn't use any skills

      }

    }

  }

}


Troubleshooting skill loading issues

If a skill doesn't appear in the available list, check the following in order:

  1. Confirm filename case

    SKILL.md filenames must be all uppercase; writing skill.md or Skill.md won't be recognized.

  2. Check frontmatter completeness

    Make sure SKILL.md has correct YAML frontmatter at the start, and contains the name and description two required fields. If either is missing, the skill won't load.

  3. Confirm the skill name is unique and correctly formatted

    If skills with the same name exist in different paths, conflicts may occur. Also check whether the name field follows naming rules (only lowercase letters and digits, separated by hyphens) and matches the folder name exactly.

  4. Check permission configuration

    in opencode.json 's permission.skill In, permissions set to "deny" skills are completely hidden from the agent and won't appear in the list. Check whether any wildcard rule (such as "*": "deny") accidentally matches the skill.

For more Skills, refer to:

  • Skills tutorial:https://www.runoob.com/ai-agent/skills-agent.html