opencode-skill-factory
(opencode - Skill) Create and generate new OpenCode skill files with proper YAML frontmatter and Markdown structure. MUST USE when users want to create, build, or define new skills, skill files, SKILL.md files, or need to generate skill documentation.
When & Why to Use This Skill
The OpenCode Skill Factory is a specialized developer tool designed to automate the creation and standardization of OpenCode skill files. It ensures all generated SKILL.md files adhere to strict YAML frontmatter requirements and Markdown structures, facilitating the development of high-performance, modular AI agent capabilities with optimized context management.
Use Cases
- Rapidly bootstrapping new AI agent skills by generating standardized SKILL.md files with correct metadata and triggers.
- Converting complex, single-file prompt instructions into a modular 'Progressive Loading' architecture to optimize context window usage.
- Ensuring consistency across team-developed skills by enforcing naming conventions, directory structures, and permission configurations.
- Generating structured documentation and cross-references for advanced agent workflows that require external assets or scripts.
| name | opencode-skill-factory |
|---|---|
| description | (opencode - Skill) Create and generate new OpenCode skill files with proper YAML frontmatter and Markdown structure. MUST USE when users want to create, build, or define new skills, skill files, SKILL.md files, or need to generate skill documentation. |
| license | MIT |
Skill Factory
What this skill does
Generates complete SKILL.md files with proper YAML frontmatter and structured Markdown content when users want to create new OpenCode skills but don't know the required format or conventions.
When to use this skill
Use this when:
- You want to define a new OpenCode skill
- You need correct YAML frontmatter structure
- You want to ensure the skill's description clearly triggers in OpenCode
- You need standardized structure, behavior rules, and examples
- You want to follow established formatting conventions
Instructions
- Ask the user for the skill name (must be lowercase with hyphens, no spaces)
- Ask for a short description that explains what the skill does and when to use it (20-1024 characters)
- Ask for the scope of the skill (project/global) to determine where it should be available
- Ask any additional context needed for behavior — e.g., inputs, outputs, constraints
- Generate a complete
SKILL.mdincluding:- YAML frontmatter with
name,description, andscope - A Markdown body that includes:
- A clear explanation of what the skill does
- When it should be invoked
- Step-by-step behavior instructions
- Example usage if appropriate
- Cross-references to additional files: For complex content >500 lines, add links like:
See [references/advanced-patterns.md](references/advanced-patterns.md) for detailed examplesRefer to [references/troubleshooting.md](references/troubleshooting.md) for common issues
- YAML frontmatter with
- Validate the generated frontmatter and ensure the description is 20-1024 characters long and speaks to when OpenCode should trigger the skill
- Return only the generated
SKILL.mdcontent
Progressive Loading Guidelines
When to Use Additional Files
Use references/ files for:
- Detailed examples and patterns
- Comprehensive troubleshooting guides
- Advanced techniques or edge cases
- API documentation or reference materials
Use assets/ files for:
- Templates for output formatting
- Configuration files or schemas
- Reusable code snippets
- Static resources (images, icons)
How to Reference Additional Files in SKILL.md
Use markdown cross-references to link to additional content:
## Advanced Examples
See [references/examples.md](references/examples.md) for comprehensive usage examples.
## Troubleshooting
Refer to [references/troubleshooting.md](references/troubleshooting.md) for common issues.
## Template Usage
Use the templates in [assets/templates/](assets/templates/) for consistent output formatting.
Loading Behavior:
SKILL.mdloads when skill triggersreferences/files load only when referencedassets/files load only when explicitly accessedscripts/execute directly without loading into context
Skill Locations and Folder Structure
Skill Discovery Precedence Order
OpenCode searches for skills in these locations (highest to lowest priority):
- Project config:
.opencode/skill/<name>/SKILL.md - Global config:
~/.config/opencode/skill/<name>/SKILL.md - Project Claude-compatible:
.claude/skills/<name>/SKILL.md - Global Claude-compatible:
~/.claude/skills/<name>/SKILL.md
Choosing the Right Location
Use Project Skills (.opencode/skill/) when:
- Skill is specific to a particular project
- Skill contains project-specific logic or configurations
- You want the skill to override global skills with the same name
- Skill should only be available to team members working on this project
Use Global Skills (~/.config/opencode/skill/) when:
- Skill is generally useful across multiple projects
- Skill provides common functionality (e.g., code review, documentation)
- You want the skill available everywhere
- Skill doesn't contain project-specific information
Recommended Folder Structure
Progressive Loading Architecture
OpenCode skills use a three-level progressive disclosure system to optimize context usage and performance:
- Metadata (name + description): Always loaded (~100 words) for skill discovery
- SKILL.md body: Loaded when skill triggers (keep under 5,000 words)
- Bundled resources: Loaded on-demand as needed by Claude (unlimited size)
Basic Skill Directory:
skill-name/
└── SKILL.md # Required - main skill definition (< 5,000 words)
Complete Modular Skill Directory:
skill-name/
├── SKILL.md # Required - main skill definition
├── scripts/ # Optional - executable code files
│ ├── helper.py # Self-contained automation scripts
│ └── deploy.sh # Deployment automation
├── references/ # Optional - documentation for context loading
│ ├── api-docs.md # Detailed API references
│ ├── examples.md # Comprehensive examples
│ └── troubleshooting.md # Debug guidance
└── assets/ # Optional - templates and resources
├── template.html # Output templates
├── config.json # Configuration files
└── icons/ # Visual assets
Modular File Organization Best Practices
Progressive File Loading Pattern:
- Keep
SKILL.mdlean (under 500 lines optimal) for fast loading - Move detailed reference documentation to
references/directory - Place complex examples in
references/examples.md - Store reusable templates in
assets/directory - Keep automation logic in
scripts/directory
Content Separation Strategy:
SKILL.md: Core instructions, triggers, and basic examplesreferences/: Detailed documentation, patterns, troubleshootingscripts/: Validation, testing, deployment automationassets/: Templates, configurations, static resources
Context Optimization:
# Fast-loading skill structure
skill-name/
├── SKILL.md # < 500 lines, core logic only
├── references/
│ ├── advanced-patterns.md # Loaded when complex patterns needed
│ ├── troubleshooting.md # Loaded when errors occur
│ └── api-reference.md # Loaded when API details needed
└── scripts/
└── validate.py # Never loaded into context, executed directly
File Organization Guidelines:
- Each supporting file should serve one clear purpose
- Avoid duplication between
SKILL.mdand reference files - Use clear, descriptive filenames
- Structure reference files for selective loading
- Keep scripts self-contained and executable
Naming Conventions
- Skill directory: lowercase with hyphens only (
my-skill,frontend-design) - SKILL.md filename: Must be exactly
SKILL.md(uppercase) - Frontmatter name: Must match directory name exactly
- Tool invocation: OpenCode converts directory to tool name (e.g.,
skill-name/→skill skill-name)
Precedence Behavior
- Higher priority locations override lower priority locations
- Project skills override global skills with the same name
- OpenCode locations override Claude-compatible locations
- First matching skill found is used, others are ignored
Permissions Configuration
Skills must be enabled in OpenCode configuration:
{
"permission": {
"skill": {
"my-skill": "allow",
"frontend-design": "allow",
"experimental-*": "ask",
"*": "deny"
}
}
}
Permission States:
allow- Skill loads immediately and is available to agentsdeny- Skill is hidden from agents, access rejectedask- User prompted for approval before loading skill
Wildcards Support:
- Use
*as wildcard (e.g.,internal-*denies all skills starting with "internal-") - More specific patterns override general patterns
- Order matters in configuration file
Skill Validation Requirements
Name Validation:
- Must match directory name containing
SKILL.md - Regex:
^[a-z0-9]+(-[a-z0-9]+)*$ - 1-64 characters
- Lowercase alphanumeric with single hyphen separators
- Cannot start/end with
-or contain consecutive--
Description Requirements:
- Required: 20-1024 characters
- Should clearly indicate when OpenCode should trigger the skill
- Be specific enough for agents to choose correctly
- Include target workflow or use case
Required Frontmatter Structure:
---
name: skill-name # Required: matches directory name
description: Skill description # Required: 20-1024 chars
license: MIT # Optional but recommended
scope: project # Optional: project or global
---
Agent-Specific Configuration
Skills can be controlled per agent through:
Custom Agent Frontmatter:
- Override permissions and tool availability
- Configure specific skill access per agent type
Built-in Agent Config:
- Configure in
opencode.jsonunderagentsection - Set default skill availability per agent
Oh-My-OpenCode Plugin:
- Advanced agent-specific skill management
- Dynamic skill enabling/disabling
- Workflow-based skill selection
Migration Notes
If migrating from Claude's skills system:
- Move from
.claude/skills/→.opencode/skill/(for project skills) - Move from
~/.claude/skills/→~/.config/opencode/skill/(for global skills) - Existing SKILL.md files work without changes
- Update permission configuration from
toolstopermission.skill
Example invocation
User: "Create a skill that reviews Python code for PEP-8 style issues."
Result: The skill-factory produces a complete SKILL.md with proper frontmatter and behavior instructions.
Updating Existing Skills
When to Update Skills
Update skills when:
- Adding new functionality or capabilities
- Fixing bugs or improving behavior
- Updating for new OpenCode versions
- Refining based on real usage feedback
- Improving documentation or examples
Skill Update Workflow
Step 1: Backup Current Skill
# Create backup before major changes
cp -r skill-name skill-name.backup-$(date +%Y%m%d)
Step 2: Choose Update Strategy
Minor Updates (Documentation, Examples):
- Edit
SKILL.mddirectly - Update reference files in
references/ - Test with validation script
- Version bump (patch)
Major Updates (Structure, Logic):
- Create new modular structure if missing
- Move detailed content to appropriate directories
- Update automation scripts
- Comprehensive testing
- Version bump (minor/major)
Step 3: Validate Changes
# Run skill validation
./scripts/validate.py skill-name/
# Test skill loading
skill skill-name --test
# Verify syntax
yamllint skill-name/SKILL.md
Step 4: Version Management
Semantic Versioning for Skills:
MAJOR.MINOR.PATCH(e.g., 1.2.3)- MAJOR: Breaking changes, new architecture
- MINOR: New features, backward compatible
- PATCH: Bug fixes, documentation improvements
Update Strategy Options:
In-Place Update (Patch/Minor):
- Directly edit existing files
- Maintain same directory structure
- Suitable for non-breaking changes
Parallel Development (Major):
- Create
skill-name-v2/alongside original - Test thoroughly before migration
- Migrate when ready, archive old version
- Create
Incremental Migration (Complex):
- Create modular structure gradually
- Move content piece by piece
- Maintain backward compatibility during transition
Progressive Loading Implementation
Converting Single-File to Modular:
Analyze Current Content:
# Check current file size wc -l skill-name/SKILL.md # Identify sections to extract grep -n "##" skill-name/SKILL.mdCreate Modular Structure:
mkdir -p skill-name/{scripts,references,assets} # Move detailed examples sed -n '/## Examples/,$p' skill-name/SKILL.md > skill-name/references/examples.md # Keep core in SKILL.md sed -i '/## Examples/,$d' skill-name/SKILL.md echo '## Examples\nSee [references/examples.md](references/examples.md) for detailed examples.' >> skill-name/SKILL.mdUpdate References:
<!-- In SKILL.md --> ## Advanced Patterns See [references/advanced-patterns.md](references/advanced-patterns.md) for comprehensive pattern documentation. ## Troubleshooting Refer to [references/troubleshooting.md](references/troubleshooting.md) for common issues.
Content Migration Guidelines:
- Move content > 500 lines to reference files
- Keep essential triggers and basic instructions in
SKILL.md - Use cross-references between files
- Test each migration step
Testing and Validation
Automated Validation:
# scripts/validate.py
import yaml
import re
import os
def validate_skill(skill_path):
"""Validate skill structure and content"""
errors = []
# Check required files
if not os.path.exists(f"{skill_path}/SKILL.md"):
errors.append("Missing SKILL.md")
# Validate frontmatter
with open(f"{skill_path}/SKILL.md") as f:
content = f.read()
try:
frontmatter = yaml.safe_load(content.split('---')[1])
validate_frontmatter(frontmatter, errors)
except Exception as e:
errors.append(f"Invalid YAML: {e}")
return errors
Manual Testing Checklist:
- Skill loads without errors
- Description triggers appropriately
- All examples work as expected
- Reference files load correctly
- Scripts execute successfully
- No broken links or references
Configuration Updates
Maintain Configuration During Updates: Back up and preserve user configurations:
# Export current permissions
opencode config get permission.skill > permissions-backup.json
# After update, restore if needed
opencode config set permission.skill "$(cat permissions-backup.json)"
Version Pinning (Advanced):
{
"skill": {
"my-skill": {
"permission": "allow",
"version": ">=1.2.0,<2.0.0"
}
}
}
Rollback Procedures
Quick Rollback:
# Restore from backup
rm -rf skill-name
mv skill-name.backup-YYYYMMDD skill-name
Git-Based Rollback:
# If using version control
git checkout HEAD~1 -- skill-name/
Update Notification Pattern
Communicate Changes:
## Changelog
### v1.2.0 (2024-01-15)
- Added modular file structure support
- Improved pattern documentation
- Updated validation scripts
### v1.1.0 (2024-01-01)
- Enhanced example coverage
- Fixed bug in trigger detection
### v1.0.0 (2023-12-15)
- Initial release
Example output
---
name: python-style-review
description: Review a Python file for PEP-8 compliance and provide a list of violations with suggestions on how to fix them.
scope: project
license: MIT
---
# Python Style Review
## When to use this skill
When a user needs a PEP-8 style analysis of a Python file.
## Instructions
1. Take the provided Python source code as input
2. Analyze for PEP-8 violations using common style rules
3. Output a structured list of issues with line numbers and suggestions
## Advanced Patterns
See [references/advanced-patterns.md](references/advanced-patterns.md) for complex PEP-8 scenarios.
## Troubleshooting
Refer to [references/troubleshooting.md](references/troubleshooting.md) for common analysis issues.