--- name: skillz description: Create and improve opencode skills - write SKILL.md, test with users, iterate. Use when: building new skills from scratch, improving existing skills, writing skill descriptions, or helping users create skills license: MIT --- # Skillz: Create and Improve OpenCode Skills This skill guides you through creating opencode skills that capture reusable workflows and expertise. ## The Workflow 1. **Capture Intent** - Understand what the skill should do 2. **Interview** - Ask the user clarifying questions 3. **Write** - Draft the SKILL.md 4. **Test** - Try it with example prompts 5. **Iterate** - Improve based on feedback --- ## Step 1: Capture Intent Start by understanding what the user wants the skill to accomplish. **Key questions:** - What should this skill enable opencode to do? - When should this skill trigger? (what phrases/contexts) - What's the expected output format? - Who is the target user? Extract answers from the conversation first. The user may need to fill gaps. --- ## Step 2: Interview and Research Proactively ask questions about: - Edge cases and error handling - Input/output formats - Example files or scenarios - Success criteria - Dependencies or tools needed - Similar existing skills to reference Wait to write test prompts until you've ironed out the core requirements. **Reference opencode docs** when needed: - Skill format: https://opencode.ai/docs/skills/ - Tool definitions: https://opencode.ai/docs/tools/ - Agent configuration: https://opencode.ai/docs/agents/ --- ## Step 3: Write SKILL.md ### Anatomy of a Skill ``` skill-name/ ├── SKILL.md (required) │ ├── YAML frontmatter (name, description required) │ └── Markdown instructions └── Bundled Resources (optional) ├── scripts/ - Executable code for tasks └── references/ - Docs loaded as needed ``` ### Frontmatter Format ```yaml --- name: skill-name description: What it does and when to use it. Be specific! license: MIT # optional compatibility: opencode # optional metadata: # optional key-value pairs audience: developers --- ``` **name** must: - Be 1-64 characters - Be lowercase alphanumeric with single hyphens - Not start or end with `-` - Match the directory name **description** must: - Be 1-1024 characters - Include BOTH what the skill does AND specific contexts for when to use it - Be "pushy" enough that the agent will actually use it **Good description example:** > "TDD workflow - write failing test first, red-green-refactor cycle. Use when: > building new features with test coverage, need regression safety, want > behavior-driven tests" **Bad description:** > "Helps with testing" (too vague) ### Writing the Body Keep SKILL.md under 500 lines. Use: - **Imperative form**: "Write a failing test first" not "You should write..." - **Clear structure**: Use headers, bullet points, code blocks - **Examples**: Show input/output patterns - **Why, not just what**: Explain reasoning when important ### Output Format Examples ```markdown ## Report structure ALWAYS use this exact template: # [Title] ## Executive summary ## Key findings ``` ### Commit message format **Example:** Input: Added user authentication with JWT tokens Output: feat(auth): implement JWT-based authentication ```` --- ## Step 4: Test ### Manual Testing Approach Since opencode doesn't have built-in eval infrastructure: 1. **Create test prompts** - 2-3 realistic examples the user would actually say 2. **Load the skill** - Use the `skill` tool to load it 3. **Execute the prompt** - Follow the skill's instructions 4. **Review with user** - Show outputs and get feedback ### Test Prompt Examples ```json { "test_prompts": [ "User says: 'I need to add user authentication to my API'", "User says: 'Help me set up CI for my Rust project'" ] } ```` ### What to Test - Does the skill trigger when it should? - Are instructions clear and actionable? - Does output match expectations? - Are edge cases handled? --- ## Step 5: Iterate ### The Improvement Loop 1. Apply changes to SKILL.md 2. Re-run test prompts 3. Get user feedback 4. Repeat until satisfied ### How to Think About Improvements 1. **Generalize from feedback** - Don't overfit to specific examples 2. **Keep it lean** - Remove instructions that aren't pulling their weight 3. **Explain the why** - LLMs understand reasoning, not just rules 4. **Look for patterns** - If tests reveal repeated work, consider bundling scripts ### When to Stop - User says they're happy - All feedback is resolved - Further iterations show diminishing returns --- ## Description Writing Guide The description is the PRIMARY triggering mechanism. It appears in the skill tool description. ### What to Include 1. **What**: The skill's purpose 2. **When**: Specific contexts that should trigger it 3. **Use when**: List of scenarios ### Making It "Pushy" Opencode tends to under-trigger skills. Make descriptions assertive: **Instead of:** > "How to build a simple fast dashboard to display internal Anthropic data." **Use:** > "Build simple fast dashboards to display internal data, metrics, or KPIs. Use > when: user mentions dashboards, data visualization, company metrics, charts, > or displaying analytics." ### Testing Description Quality Ask: "Would the agent know to use this skill when someone says [X]?" --- ## Permissions Configuration Users can control skill access in `opencode.json`: ```json { "permission": { "skill": { "*": "allow", "skillz": "allow", "experimental-*": "ask", "internal-*": "deny" } } } ``` - `allow` - Loads immediately - `deny` - Hidden from agent - `ask` - User prompted for approval --- ## Quick Reference | Component | Requirement | | ------------- | -------------------------------- | | name | Required, lowercase with hyphens | | description | Required, 1-1024 chars | | license | Optional | | compatibility | Optional | | SKILL.md | Max ~500 lines recommended | **Location**: `~/.config/opencode/skills//SKILL.md` --- Use this skill whenever someone wants to create, improve, or understand opencode skills. --- ## Writing Effective Descriptions ### How opencode Discovers Skills opencode sends **all skill descriptions to the LLM every turn** in an `` XML block. There is no retrieval, embedding, or pre-filtering — the LLM reads every description and decides which skill to load based on the description text and the user's message. This means description quality directly impacts skill selection accuracy. ### The "Use when:" Pattern The "Use when:" pattern is endorsed by Anthropic and the Agent Skills open standard. It provides explicit trigger conditions for skill activation. **However:** For self-describing skill names, "Use when:" is often tautological and adds no value. | Skill Name | Tautological "Use when:" | Better Alternative | | ------------------ | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | `git-commit` | "Use when: committing code, writing commits" | "Write semantic git commits in conventional commit format — feat/fix/chore types, scope, breaking changes" | | `sql-optimization` | "Use when: optimizing slow queries" | "Optimize SQL queries — EXPLAIN/EXPLAIN ANALYZE, index design, N+1 elimination, keyset pagination" | | `rust-maud` | "Use when: writing HTML in Rust" | "Write HTML in Rust using Maud — html! macro, component patterns, Axum/Actix integration" | ### When "Use when:" DOES Add Value Keep "Use when:" for skills with **non-obvious names**: | Skill | Why "Use when:" helps | | ----------------- | ------------------------------------------------------------ | | `datastar` | Name is opaque; needs to explain it's a hypermedia framework | | `design-it-twice` | Name is a heuristic; needs to clarify when to apply it | | `efficient-code` | Must distinguish from `performance-optimization` | | `benchmark` | Routes to sub-skills; needs to clarify dispatcher role | ### Domain Keywords Are Better Discriminators Library names, tool names, and format names are stronger signals than generic phrases: | Weak (generic) | Strong (domain keywords) | | ---------------------------------- | ---------------------------------------------------------------------------------------------------------- | | "Use when: benchmarking Java code" | "Write Java benchmarks using JMH (Java Microbenchmark Harness) — statistical analysis, warm-up, blackhole" | | "Use when: working with PDFs" | "Extract text and tables from PDFs — PyMuPDF, pdfplumber, OCR with tesseract" | | "Use when: optimizing Rust builds" | "Optimize Rust build times — sccache, cranelift codegen, feature flags, workspace optimization" | ### Description Checklist - [ ] **Action-first**: Starts with a verb describing what the skill does - [ ] **Domain keywords**: Includes specific library/tool/format names - [ ] **Not tautological**: "Use when:" adds information the name doesn't already convey - [ ] **Under 1024 chars**: Per opencode limit - [ ] **Differentiates**: Clear boundary from similar skills ### Examples **Before (tautological):** ``` description: Write semantic commits. Use when: committing code, writing commit messages. ``` **After (action + keywords):** ``` description: Write semantic git commits in conventional commit format — feat/fix/chore/docs types, scope, breaking change notation (!), atomic commit discipline, changelog-ready messages. ``` **Before (vague):** ``` description: Helps with SQL performance. Use when: queries are slow. ``` **After (specific):** ``` description: Optimize SQL queries — EXPLAIN/EXPLAIN ANALYZE, index design (composite, partial, covering), N+1 elimination, keyset pagination, query plan reading. ```