|
| 1 | +--- |
| 2 | +title: "Agent Skills" |
| 3 | +description: "Define reusable behavior via SKILL.md definitions" |
| 4 | +--- |
| 5 | + |
| 6 | +Agent skills let OpenCode discover reusable instructions from your repo or home directory. |
| 7 | +When a conversation matches a skill, the agent is prompted to read its `SKILL.md`. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Place files |
| 12 | + |
| 13 | +Create one folder per skill name and put a `SKILL.md` inside it. |
| 14 | +OpenCode searches these locations: |
| 15 | + |
| 16 | +- Project config: `.opencode/skill/<name>/SKILL.md` |
| 17 | +- Global config: `~/.opencode/skill/<name>/SKILL.md` |
| 18 | +- Claude-compatible: `.claude/skills/<name>/SKILL.md` |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## Understand discovery |
| 23 | + |
| 24 | +For project-local paths, OpenCode walks up from your current working directory until it reaches the git worktree. |
| 25 | +It loads any matching `skill/*/SKILL.md` in `.opencode/` and any matching `.claude/skills/*/SKILL.md` along the way. |
| 26 | + |
| 27 | +Global definitions are also loaded from `~/.opencode/skill/*/SKILL.md`. |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Write frontmatter |
| 32 | + |
| 33 | +Each `SKILL.md` must start with YAML frontmatter. |
| 34 | +Only these fields are recognized: |
| 35 | + |
| 36 | +- `name` (required) |
| 37 | +- `description` (required) |
| 38 | +- `license` (optional) |
| 39 | +- `compatibility` (optional) |
| 40 | +- `metadata` (optional, string-to-string map) |
| 41 | + |
| 42 | +Unknown frontmatter fields are ignored. |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## Validate names |
| 47 | + |
| 48 | +`name` must: |
| 49 | + |
| 50 | +- Be 1–64 characters |
| 51 | +- Be lowercase alphanumeric with single hyphen separators |
| 52 | +- Not start or end with `-` |
| 53 | +- Not contain consecutive `--` |
| 54 | +- Match the directory name that contains `SKILL.md` |
| 55 | + |
| 56 | +Equivalent regex: |
| 57 | + |
| 58 | +```text |
| 59 | +^[a-z0-9]+(-[a-z0-9]+)*$ |
| 60 | +``` |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## Follow length rules |
| 65 | + |
| 66 | +`description` must be 1-1024 characters. |
| 67 | +Keep it specific enough for the agent to choose correctly. |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +## Use an example |
| 72 | + |
| 73 | +Create `.opencode/skill/git-release/SKILL.md` like this: |
| 74 | + |
| 75 | +```markdown |
| 76 | +--- |
| 77 | +name: git-release |
| 78 | +description: Create consistent releases and changelogs |
| 79 | +license: MIT |
| 80 | +compatibility: opencode |
| 81 | +metadata: |
| 82 | + audience: maintainers |
| 83 | + workflow: github |
| 84 | +--- |
| 85 | + |
| 86 | +## What I do |
| 87 | + |
| 88 | +- Draft release notes from merged PRs |
| 89 | +- Propose a version bump |
| 90 | +- Provide a copy-pasteable `gh release create` command |
| 91 | + |
| 92 | +## When to use me |
| 93 | + |
| 94 | +Use this when you are preparing a tagged release. |
| 95 | +Ask clarifying questions if the target versioning scheme is unclear. |
| 96 | +``` |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Recognize prompt injection |
| 101 | + |
| 102 | +OpenCode adds an `<available_skills>` XML block to the system prompt. |
| 103 | +Each entry includes the skill name, description, and its discovered location. |
| 104 | + |
| 105 | +```xml |
| 106 | +<available_skills> |
| 107 | + <skill> |
| 108 | + <name>git-release</name> |
| 109 | + <description>Create consistent releases and changelogs</description> |
| 110 | + <location>.opencode/skill/git-release/SKILL.md</location> |
| 111 | + </skill> |
| 112 | +</available_skills> |
| 113 | +``` |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +## Troubleshoot loading |
| 118 | + |
| 119 | +If a skill does not show up, verify the folder name matches `name` exactly. |
| 120 | +Also check that `SKILL.md` is spelled in all caps and includes frontmatter. |
0 commit comments