|
| 1 | +# Skills |
| 2 | + |
| 3 | +Skills are reusable instruction sets that provide domain-specific workflows and guidance to OpenCode AI agents. They are stored as `SKILL.md` files and can be scoped globally or per-project. |
| 4 | + |
| 5 | +## Scopes |
| 6 | + |
| 7 | +| Scope | Location | Description | |
| 8 | +|-------|----------|-------------| |
| 9 | +| **Global** | `<workspace>/.config/opencode/skills/<name>/SKILL.md` | Available across all repositories | |
| 10 | +| **Project** | `<repo>/.opencode/skills/<name>/SKILL.md` | Scoped to a specific repository | |
| 11 | + |
| 12 | +## Skill File Format |
| 13 | + |
| 14 | +Each skill is a `SKILL.md` file with YAML frontmatter and a markdown body: |
| 15 | + |
| 16 | +```markdown |
| 17 | +--- |
| 18 | +name: my-skill |
| 19 | +description: Short description of what this skill does |
| 20 | +license: MIT |
| 21 | +compatibility: opencode >= 1.0 |
| 22 | +metadata: |
| 23 | + author: your-name |
| 24 | + version: 1.0.0 |
| 25 | +--- |
| 26 | +Your skill instructions go here. This is the content that gets |
| 27 | +injected into the AI agent's context when the skill is loaded. |
| 28 | +``` |
| 29 | + |
| 30 | +### Frontmatter Fields |
| 31 | + |
| 32 | +| Field | Required | Description | |
| 33 | +|-------|----------|-------------| |
| 34 | +| `name` | Yes | Lowercase alphanumeric with hyphens (e.g., `my-skill`). Max 64 characters. | |
| 35 | +| `description` | Yes | What the skill does. Max 1024 characters. | |
| 36 | +| `license` | No | License identifier (e.g., `MIT`) | |
| 37 | +| `compatibility` | No | Version compatibility note | |
| 38 | +| `metadata` | No | Key-value pairs for additional context | |
| 39 | + |
| 40 | +### Naming Rules |
| 41 | + |
| 42 | +Skill names must match the pattern `^[a-z0-9]+(-[a-z0-9]+)*$`: |
| 43 | + |
| 44 | +- Lowercase letters and numbers only |
| 45 | +- Hyphens allowed between words |
| 46 | +- No spaces, underscores, or uppercase letters |
| 47 | +- Examples: `test-skill`, `code-review`, `deploy-helper` |
| 48 | + |
| 49 | +## Managing Skills |
| 50 | + |
| 51 | +Skills are managed through the Settings UI under the Skills section, or via the API. |
| 52 | + |
| 53 | +### API Endpoints |
| 54 | + |
| 55 | +All endpoints are under `/api/settings/skills`. |
| 56 | + |
| 57 | +| Method | Path | Description | |
| 58 | +|--------|------|-------------| |
| 59 | +| `GET` | `/skills` | List all skills (optional `?repoId=` filter) | |
| 60 | +| `GET` | `/skills/:name` | Get a specific skill (requires `scope` query param, optional `repoId`) | |
| 61 | +| `POST` | `/skills` | Create a new skill | |
| 62 | +| `PUT` | `/skills/:name` | Update an existing skill (requires `scope` query param, optional `repoId`) | |
| 63 | +| `DELETE` | `/skills/:name` | Delete a skill (requires `scope` query param, optional `repoId`) | |
| 64 | + |
| 65 | +### Create Request |
| 66 | + |
| 67 | +```json |
| 68 | +{ |
| 69 | + "name": "my-skill", |
| 70 | + "description": "Runs type check and lint", |
| 71 | + "body": "Instructions for the AI agent...", |
| 72 | + "scope": "global", |
| 73 | + "license": "MIT", |
| 74 | + "compatibility": "opencode >= 1.0", |
| 75 | + "metadata": { "author": "your-name" }, |
| 76 | + "repoId": 1 |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +`repoId` is required when `scope` is `"project"`. |
| 81 | + |
| 82 | +### Update Request |
| 83 | + |
| 84 | +All fields are optional. Set a field to `null` to clear it. |
| 85 | + |
| 86 | +```json |
| 87 | +{ |
| 88 | + "description": "Updated description", |
| 89 | + "body": "Updated instructions", |
| 90 | + "license": null |
| 91 | +} |
| 92 | +``` |
0 commit comments