opencode-skills

repository·main·Indexed 17 days ago

https://github.com/malhashemi/opencode-skills

An Anthropic Agent Skills Specification plugin for OpenCode that enables the discovery and execution of skills via dynamic tool registration using Markdown files. Version 1.0.0 is now deprecated as skills functionality is native to OpenCode (v1.0.190+). The plugin allows creating skills with SKILL.md files containing YAML frontmatter and Markdown instructions, with automatic tool name generation based on directory structure.

Tokens
2.2K
Snippets
6
Records
12
Agent score
17%

What's inside opencode-skills

  1. Create a Skill (Legacy Plugin Method)

    main

    If you are using the legacy opencode-skills plugin (pre-v1.0.190), follow these steps to create a skill:

    1. Create the directory: Create a folder inside .opencode/skills/ (e.g., .opencode/skills/my-skill).
    2. Create SKILL.md: Every skill requires a SKILL.md file with YAML frontmatter containing name and description.
    3. Add Instructions: Write your skill's logic in Markdown format within the same file.

    Example Directory Structure:

    my-skill/
    ├── SKILL.md              # Required
    ├── scripts/              # Optional: Executable code
    │   └── helper.py
    └── references/           # Optional: Documentation
        └── api-docs.md

    Example SKILL.md:

    ---
    name: my-skill
    description: A custom skill that helps with specific tasks in my project
    license: MIT
    ---
    
    # My Custom Skill
    
    This skill helps you accomplish specific tasks.
    
    ## Instructions
    
    1. First, do this
    2. Then, do that
    mkdir -p .opencode/skills/my-skill
  2. Migrate from opencode-skills plugin to Native Skills

    main

    As skills support has become native to OpenCode, you should migrate from the opencode-skills plugin to the native implementation. Follow these three steps:

    1. Remove the Plugin: Uninstall or remove the opencode-skills plugin from your configuration.
    2. Move Your Skills Directory: The native implementation uses skill/ (singular) at the project root, whereas the plugin used .opencode/skills/. Move your skill files to the new location.
      • Note for Global Skills: If you are using global skills, ensure they are moved to the appropriate native global directory.
    3. Update Your Config (Optional): Review your configuration for any remaining plugin-specific keys that may no longer be required by the native implementation.
  3. Migrate from OpenCode Skills Plugin to Native Skills Support

    main

    The opencode-skills plugin is deprecated because skills functionality is now built into OpenCode (v1.0.190+). Follow these steps to migrate:

    1. Remove the Plugin: Delete the opencode-skills entry from your opencode.json file.
    2. Move Your Skills Directory:
      • Project-local skills: Move from .opencode/skills/ to skill/ at your project root.
      • Global skills: Move from ~/.opencode/skills/ to ~/.config/opencode/skill.
    3. Update Permissions (Optional): Native skills use pattern-based permissions in opencode.json instead of the old tools configuration. Use the permission.skill key to allow or deny specific skills.

    Key Differences Table:

    AspectPluginNative (v1.0.190+)
    Tool nameskills_my_skillskill (single tool)
    Directory.opencode/skills/skill/
    LoadingEager (all at startup)Lazy (on-demand)
    Permissionstools configpermission.skill patterns
    // opencode.json
    {
    -  "plugin": ["opencode-skills"]
    }
    
    // New permission structure
    {
    +  "permission": {
    +    "skill": {
    +      "my-skill": "allow",
    +      "*": "deny"
    +    }
    +  }
    }
  4. Skill discovery locations and priority

    main

    The plugin searches for SKILL.md files in several locations. If duplicate tool names are found, the location with the highest priority wins.

    Discovery Order (Lowest to Highest Priority):

    1. XDG Config: $XDG_CONFIG_HOME/opencode/skills or ~/.config/opencode/skills
    2. Global Home: ~/.opencode/skills
    3. Custom Config: $OPENCODE_CONFIG_DIR/skills (if OPENCODE_CONFIG_DIR is set)
    4. Project Local: [project_root]/.opencode/skills
  5. How skill tool names are generated

    main

    The plugin automatically generates tool names for the agent based on the directory structure relative to the skill's base directory. The pattern is skills_{{path_components_joined_by_underscore}}, where hyphens in directory names are replaced with underscores.

    Examples:

    • .opencode/skills/brand-guidelines/SKILL.md $\rightarrow$ skills_brand_guidelines
    • .opencode/skills/document-skills/docx/SKILL.md $\rightarrow$ skills_document_skills_docx
  6. Configure Native Skill Permissions

    main

    In OpenCode v1.0.190+, permissions for the skill tool are managed via the permission.skill object in opencode.json. This allows you to use pattern-based matching to control access. Use allow to grant access and deny to restrict it.

    Example configuration to allow a specific skill while denying all others:

    {
      "permission": {
        "skill": {
          "my-skill": "allow",
          "*": "deny"
        }
      }
    }
  7. Create skills using SKILL.md files

    main

    The opencode-skills plugin implements Anthropic's Agent Skills Specification. To create a skill, you must create a SKILL.md file within a directory. The directory name must match the name field in the YAML frontmatter.

    Frontmatter Requirements

    • name: Must be lowercase alphanumeric with hyphens (e.g., my-skill).
    • description: Must be at least 20 characters long.
    • license: (Optional) String.
    • allowed-tools: (Optional) Array of strings.
    • metadata: (Optional) Key-value pairs.

    Example SKILL.md

    ---
    name: brand-guidelines
    description: Provides the official brand colors and typography rules.
    license: MIT
    ---
    
    # Brand Guidelines
    Use #FF5733 for primary buttons.
  8. Troubleshoot OpenCode Skills Plugin

    main

    Common issues when using the opencode-skills plugin:

    • Skills not discovered:
      • Verify SKILL.md exists in discovery paths (.opencode/skills/, ~/.opencode/skills/, or ~/.config/opencode/skills/).
      • Check that frontmatter is valid YAML.
    • Tool not appearing:
      • Ensure the name in SKILL.md matches the directory name exactly.
      • Restart OpenCode after adding/modifying skills.
    • Paths not resolving:
      • Ensure paths in SKILL.md are relative to the skill directory.
      • Check the base directory provided in the skill output.
    • Invalid skill errors:
      • Name must be lowercase with hyphens only ([a-z0-9-]+).
      • Description must be at least 20 characters.
    • Plugin not updating:
      • Check version: cat ~/.cache/opencode/node_modules/opencode-skills/package.json | grep version
      • Force update: rm -rf ~/.cache/opencode and then restart OpenCode.
  9. Skill Naming Rules (Legacy Plugin)

    main

    When using the opencode-skills plugin, tool names are automatically generated based on your directory structure. To ensure compatibility, follow these rules:

    • Directory Name: Must be lowercase with hyphens (e.g., my-skill).
    • Frontmatter name: Must match the directory name exactly.
    • Generated Tool Name: The plugin converts the directory name to an underscore-separated format prefixed with skills_ (e.g., skills_my_skill).
    DirectoryFrontmatter NameTool Name
    brand-guidelines/brand-guidelinesskills_brand_guidelines
    tools/analyzer/analyzerskills_tools_analyzer
  10. The Skill interface

    main

    The Skill interface defines the structure of a parsed skill discovered by the plugin. Each skill is derived from a SKILL.md file containing YAML frontmatter and Markdown content.

    Key properties include:

    • name: The identifier from frontmatter (must be lowercase alphanumeric with hyphens).
    • toolName: The automatically generated tool name used by the agent (e.g., skills_brand_guidelines).
    • description: The skill's purpose, used for agent discovery.
    • content: The raw Markdown body of the skill.
    • fullPath: The directory containing the skill.
    • path: The absolute path to the SKILL.md file.
    export interface Skill {
      name: string // From frontmatter (e.g., "brand-guidelines")
      fullPath: string // Full directory path to skill
      toolName: string // Generated tool name (e.g., "skills_brand_guidelines")
      description: string // From frontmatter
      allowedTools?: string[] // Parsed but not enforced (agent-level restrictions instead)
      metadata?: Record<string, string>
      license?: string
      content: string // Markdown body
      path: string // Full path to SKILL.md
    }