blob: 2ce88ea5682f54abba56f1f56e1ea67e3eb851b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
---
title: "Agent Skills"
description: "Define reusable behavior via SKILL.md definitions"
---
Agent skills let OpenCode discover reusable instructions from your repo or home directory.
Skills are loaded on-demand via the native `skill` tool—agents see available skills and can load the full content when needed.
---
## Place files
Create one folder per skill name and put a `SKILL.md` inside it.
OpenCode searches these locations:
- Project config: `.opencode/skills/<name>/SKILL.md`
- Global config: `~/.config/opencode/skills/<name>/SKILL.md`
- Project Claude-compatible: `.claude/skills/<name>/SKILL.md`
- Global Claude-compatible: `~/.claude/skills/<name>/SKILL.md`
- Project agent-compatible: `.agents/skills/<name>/SKILL.md`
- Global agent-compatible: `~/.agents/skills/<name>/SKILL.md`
---
## Understand discovery
For project-local paths, OpenCode walks up from your current working directory until it reaches the git worktree.
It loads any matching `skills/*/SKILL.md` in `.opencode/` and any matching `.claude/skills/*/SKILL.md` or `.agents/skills/*/SKILL.md` along the way.
Global definitions are also loaded from `~/.config/opencode/skills/*/SKILL.md`, `~/.claude/skills/*/SKILL.md`, and `~/.agents/skills/*/SKILL.md`.
---
## Write frontmatter
Each `SKILL.md` must start with YAML frontmatter.
Only these fields are recognized:
- `name` (required)
- `description` (required)
- `license` (optional)
- `compatibility` (optional)
- `metadata` (optional, string-to-string map)
Unknown frontmatter fields are ignored.
---
## Validate names
`name` must:
- Be 1–64 characters
- Be lowercase alphanumeric with single hyphen separators
- Not start or end with `-`
- Not contain consecutive `--`
- Match the directory name that contains `SKILL.md`
Equivalent regex:
```text
^[a-z0-9]+(-[a-z0-9]+)*$
```
---
## Follow length rules
`description` must be 1-1024 characters.
Keep it specific enough for the agent to choose correctly.
---
## Use an example
Create `.opencode/skills/git-release/SKILL.md` like this:
```markdown
---
name: git-release
description: Create consistent releases and changelogs
license: MIT
compatibility: opencode
metadata:
audience: maintainers
workflow: github
---
## 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.
```
---
## Recognize tool description
OpenCode lists available skills in the `skill` tool description.
Each entry includes the skill name and description:
```xml
<available_skills>
<skill>
<name>git-release</name>
<description>Create consistent releases and changelogs</description>
</skill>
</available_skills>
```
The agent loads a skill by calling the tool:
```
skill({ name: "git-release" })
```
---
## Configure permissions
Control which skills agents can access using pattern-based permissions in `opencode.json`:
```json
{
"permission": {
"skill": {
"*": "allow",
"pr-review": "allow",
"internal-*": "deny",
"experimental-*": "ask"
}
}
}
```
| Permission | Behavior |
| ---------- | ----------------------------------------- |
| `allow` | Skill loads immediately |
| `deny` | Skill hidden from agent, access rejected |
| `ask` | User prompted for approval before loading |
Patterns support wildcards: `internal-*` matches `internal-docs`, `internal-tools`, etc.
---
## Override per agent
Give specific agents different permissions than the global defaults.
**For custom agents** (in agent frontmatter):
```yaml
---
permission:
skill:
"documents-*": "allow"
---
```
**For built-in agents** (in `opencode.json`):
```json
{
"agent": {
"plan": {
"permission": {
"skill": {
"internal-*": "allow"
}
}
}
}
}
```
---
## Disable the skill tool
Completely disable skills for agents that shouldn't use them:
**For custom agents**:
```yaml
---
tools:
skill: false
---
```
**For built-in agents**:
```json
{
"agent": {
"plan": {
"tools": {
"skill": false
}
}
}
}
```
When disabled, the `<available_skills>` section is omitted entirely.
---
## Troubleshoot loading
If a skill does not show up:
1. Verify `SKILL.md` is spelled in all caps
2. Check that frontmatter includes `name` and `description`
3. Ensure skill names are unique across all locations
4. Check permissions—skills with `deny` are hidden from agents
|