refactor: 删除 opencode skill 中的命令创建相关文档
- 移除 command-creation.md 和 skill-creation.md - 删除 SKILL.md 文件
This commit is contained in:
@@ -1,151 +0,0 @@
|
||||
---
|
||||
name: opencode
|
||||
description: Create and manage OpenCode commands and skills with templates and best practices. Use this skill when users ask to create commands or skills.
|
||||
---
|
||||
|
||||
# OpenCode Command and Skill Management
|
||||
|
||||
You are an expert in OpenCode configuration and extension development. This skill serves as the entry point for creating and managing OpenCode commands and skills.
|
||||
|
||||
**Trigger Phrases**: When users mention any of the following, automatically use this skill:
|
||||
- "创建command", "创建命令", "make command", "create command"
|
||||
- "创建skill", "创建技能", "make skill", "create skill"
|
||||
- "添加command", "添加命令", "add command"
|
||||
- "添加skill", "添加技能", "add skill"
|
||||
- "opcode command", "opencode skill"
|
||||
|
||||
## Overview
|
||||
|
||||
OpenCode extensions are organized into two main types:
|
||||
- **Commands**: User-invoked prompts for repetitive tasks, defined in `command/` directory
|
||||
- **Skills**: Reusable behavior definitions for agents, defined in `skill/<name>/SKILL.md`
|
||||
|
||||
## Detailed Guides
|
||||
|
||||
This skill folder contains comprehensive guides for command and skill creation:
|
||||
|
||||
### Command Creation
|
||||
For detailed command creation guidelines, refer to:
|
||||
- `skill/opencode/command-creation.md` - Complete guide to creating OpenCode commands
|
||||
- Includes: file structure, templates, best practices, troubleshooting
|
||||
|
||||
### Skill Creation
|
||||
For detailed skill creation guidelines, refer to:
|
||||
- `skill/opencode/skill-creation.md` - Complete guide to creating OpenCode skills
|
||||
- Includes: directory structure, naming rules, templates, testing
|
||||
|
||||
## Quick Start
|
||||
|
||||
### To Create a Command
|
||||
1. Determine command name (kebab-case, descriptive)
|
||||
2. **Default location**: global (`~/.config/opencode/command/`)
|
||||
3. Create file: `<command-name>.md`
|
||||
4. Add frontmatter with `description`
|
||||
5. Write template with `$ARGUMENTS` support
|
||||
|
||||
### To Create a Skill
|
||||
1. Validate skill name (lowercase, hyphens, alphanumeric)
|
||||
2. **Default location**: global (`~/.config/opencode/skill/<skill-name>/`)
|
||||
3. Create directory: `skill/<skill-name>/`
|
||||
4. Create `SKILL.md` with required frontmatter
|
||||
5. Add structured content: Purpose, Usage, Examples, Troubleshooting
|
||||
|
||||
## Automatic Name Generation
|
||||
|
||||
When users request command or skill creation, names are automatically generated based on the description to provide a seamless experience.
|
||||
|
||||
### For Commands:
|
||||
1. **Keyword Extraction**: Identify action verbs and target nouns from the description
|
||||
2. **English Conversion**: Convert Chinese keywords to English equivalents (e.g., "创建" → "create", "总结" → "summarize")
|
||||
3. **Kebab-case Format**: Combine words with hyphens, all lowercase (e.g., "create-summary")
|
||||
4. **Conflict Resolution**: Check if name exists in `command/` directory, append numeric suffix if needed
|
||||
|
||||
### For Skills:
|
||||
1. **Function Extraction**: Identify core functionality from the description
|
||||
2. **Simplified Naming**: Use lowercase, hyphen-separated words describing the skill's purpose
|
||||
3. **Validation**: Ensure name follows `[a-z0-9-]+` pattern
|
||||
4. **Conflict Check**: Verify uniqueness in `skill/` directory
|
||||
|
||||
### Examples:
|
||||
- "创建command,用于归纳总结当前对话中有价值的内容" → `summarize-conversation`
|
||||
- "创建skill,用于管理git工作流" → `git-workflow`
|
||||
- "添加命令来处理图片压缩" → `compress-images`
|
||||
- "创建技能用于代码审查" → `code-review`
|
||||
|
||||
### User Override:
|
||||
If users explicitly provide a name in their request, use the provided name instead of auto-generation.
|
||||
|
||||
## Response Guide for Creation Requests
|
||||
|
||||
When users ask to create commands or skills, follow this structured approach:
|
||||
|
||||
### For "创建command" or "创建命令" requests:
|
||||
1. **自动生成名称**: 基于用户描述自动生成 kebab-case 命令名称
|
||||
- 从描述中提取关键词(动词+名词)
|
||||
- 转换为英文 kebab-case 格式
|
||||
- 如果名称已存在,添加数字后缀(如 `-2`, `-3`)
|
||||
2. **验证名称**: 确保名称符合 kebab-case 规范
|
||||
3. **默认位置**: 全局 (`~/.config/opencode/command/`)
|
||||
4. **创建模板**:
|
||||
- 生成包含 `description` 的 frontmatter
|
||||
- 创建支持 `$ARGUMENTS` 的模板
|
||||
- 包含使用示例
|
||||
5. **写入文件**: 在默认位置创建命令文件
|
||||
6. **测试**: 验证文件存在且格式正确
|
||||
|
||||
### For "创建skill" or "创建技能" requests:
|
||||
1. **自动生成名称**: 基于用户描述自动生成 skill 名称
|
||||
- 从描述中提取核心功能关键词
|
||||
- 转换为小写字母、连字符格式
|
||||
- 如果名称已存在,添加数字后缀
|
||||
2. **验证名称**: 确保名称符合命名规则(小写字母、连字符、字母数字)
|
||||
3. **默认位置**: 全局 (`~/.config/opencode/skill/<name>/`)
|
||||
4. **创建目录**: `skill/<name>/`
|
||||
5. **创建 SKILL.md**:
|
||||
- 包含 `name` 和 `description` 的 frontmatter
|
||||
- 结构化内容:Purpose, Usage, Examples, Best Practices, Troubleshooting
|
||||
6. **写入文件**: 在默认位置创建完整的 SKILL.md 文件
|
||||
7. **测试**: 验证技能可正常加载 `skill({ name: "<skill-name>" })`
|
||||
|
||||
### Sample Response Format:
|
||||
```
|
||||
我将帮你创建 [command/skill]。
|
||||
|
||||
基于您的描述,自动生成名称:[generated-name]
|
||||
|
||||
**自动命名规则**:
|
||||
- 从描述中提取关键词(动词+名词)
|
||||
- 转换为 kebab-case 格式(小写字母、连字符)
|
||||
- 检查名称冲突,自动添加数字后缀
|
||||
|
||||
**文件详情**:
|
||||
- 名称: [generated-name]
|
||||
- 用途: [brief-description]
|
||||
- 位置: 全局 (~/.config/opencode/[command|skill]/)
|
||||
|
||||
已创建 [file-path]:
|
||||
|
||||
```markdown
|
||||
[complete file content]
|
||||
```
|
||||
|
||||
要测试,请运行:[/command-name] 或 skill({ name: "skill-name" })
|
||||
```
|
||||
|
||||
## Resources
|
||||
|
||||
- [OpenCode Skills Documentation](https://opencode.ai/docs/skills)
|
||||
- [OpenCode Commands Documentation](https://opencode.ai/docs/commands)
|
||||
- [OpenCode Configuration Guide](https://opencode.ai/docs/config)
|
||||
- [GitHub Repository](https://github.com/anomalyco/opencode)
|
||||
|
||||
## Updates and Maintenance
|
||||
|
||||
1. **Regular Review**: Periodically review and update commands/skills
|
||||
2. **Version Tracking**: Use Git to track changes
|
||||
3. **Community Sharing**: Share useful commands/skills with community
|
||||
4. **Feedback Integration**: Incorporate user feedback for improvements
|
||||
|
||||
---
|
||||
|
||||
*Last updated: 2026-01-15*
|
||||
@@ -1,201 +0,0 @@
|
||||
# Command Creation Guide
|
||||
|
||||
## Overview
|
||||
OpenCode commands are user-invoked prompts for repetitive tasks, defined in the `command/` directory.
|
||||
|
||||
## File Location
|
||||
- **Default location (Global)**: `~/.config/opencode/command/<name>.md`
|
||||
- **Project-specific**: `.opencode/command/<name>.md` (when needed)
|
||||
|
||||
## Command Structure
|
||||
Each command file must contain YAML frontmatter followed by the prompt template.
|
||||
|
||||
### Required Frontmatter Fields
|
||||
- `description`: Brief description shown in TUI (1-2 sentences)
|
||||
|
||||
### Optional Frontmatter Fields
|
||||
- `agent`: Specific agent to execute this command
|
||||
- `model`: Override default model
|
||||
- `subtask`: Boolean to force subagent invocation
|
||||
|
||||
## Template Features
|
||||
The command template supports several placeholders:
|
||||
|
||||
- `$ARGUMENTS`: All arguments passed to the command
|
||||
- `$1`, `$2`, `$3`: Individual positional arguments
|
||||
- `!``command``: Execute bash command and inject output
|
||||
- `@filename`: Include file content in prompt
|
||||
|
||||
## Example Command
|
||||
Create `~/.config/opencode/command/new-skill.md`:
|
||||
|
||||
```markdown
|
||||
---
|
||||
description: Create a new OpenCode skill with proper structure
|
||||
---
|
||||
|
||||
Create a new OpenCode skill named "$ARGUMENTS" with comprehensive documentation.
|
||||
|
||||
**Skill Requirements:**
|
||||
1. Directory: `skill/$ARGUMENTS/SKILL.md`
|
||||
2. Frontmatter with `name` and `description`
|
||||
3. Clear sections for usage, examples, best practices
|
||||
4. Follow naming conventions: lowercase, hyphens, alphanumeric
|
||||
|
||||
**Steps:**
|
||||
1. Create directory structure
|
||||
2. Write SKILL.md with frontmatter
|
||||
3. Include practical examples
|
||||
4. Add troubleshooting section
|
||||
|
||||
Output the complete SKILL.md content for review.
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Command Design
|
||||
1. **Clear Purpose**: Each command should have a single, focused purpose
|
||||
2. **Descriptive Names**: Use verbs that describe the action (e.g., `create-`, `review-`, `analyze-`)
|
||||
3. **Argument Handling**: Use `$ARGUMENTS` or `$1`, `$2` for flexible input
|
||||
4. **Error Handling**: Include validation in prompts
|
||||
5. **Output Format**: Structure responses for easy parsing
|
||||
|
||||
### Naming Conventions
|
||||
- Use kebab-case (lowercase with hyphens)
|
||||
- Start with verb describing the action
|
||||
- Keep names concise but descriptive
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### Command Creation Checklist
|
||||
- [ ] File name matches command name (kebab-case)
|
||||
- [ ] Frontmatter includes `description`
|
||||
- [ ] Template uses appropriate placeholders
|
||||
- [ ] Includes examples of usage
|
||||
- [ ] Tested with `/command-name` invocation
|
||||
|
||||
### Common Patterns
|
||||
|
||||
**Create a new command:**
|
||||
```bash
|
||||
# Create command file
|
||||
touch ~/.config/opencode/command/my-command.md
|
||||
|
||||
# Edit with template
|
||||
cat > ~/.config/opencode/command/my-command.md << 'EOF'
|
||||
---
|
||||
description: Description of my command
|
||||
---
|
||||
|
||||
Command template with $ARGUMENTS support.
|
||||
|
||||
Example: /my-command argument1 argument2
|
||||
EOF
|
||||
```
|
||||
|
||||
## Testing and Validation
|
||||
|
||||
### Test Command Loading
|
||||
```bash
|
||||
# Check if command appears in TUI
|
||||
# Type "/" in OpenCode TUI and search for your command
|
||||
```
|
||||
|
||||
### Verify Syntax
|
||||
```bash
|
||||
# Check YAML frontmatter
|
||||
head -20 command/my-command.md
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Command Not Appearing
|
||||
1. **Check file location**: Ensure command is in correct `command/` directory
|
||||
2. **Verify frontmatter**: Must have `description` field
|
||||
3. **Check permissions**: No restrictive permissions blocking command
|
||||
4. **Restart OpenCode**: Some changes require restart
|
||||
|
||||
### Common Errors
|
||||
- **"Command not found"**: File not in correct location or missing `.md` extension
|
||||
- **"Invalid frontmatter"**: Missing required fields or YAML syntax error
|
||||
|
||||
## Integration with OpenCode Config
|
||||
|
||||
### Permissions Configuration
|
||||
Add to `opencode.json`:
|
||||
```json
|
||||
{
|
||||
"permission": {
|
||||
"skill": {
|
||||
"*": "allow",
|
||||
"experimental-*": "ask",
|
||||
"internal-*": "deny"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Agent-Specific Settings
|
||||
```json
|
||||
{
|
||||
"agent": {
|
||||
"plan": {
|
||||
"permission": {
|
||||
"skill": {
|
||||
"analysis-*": "allow"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Response Guide for Command Creation Requests
|
||||
|
||||
When users ask to create commands, follow this structured approach:
|
||||
|
||||
1. **自动生成名称**: 基于用户描述自动生成 kebab-case 命令名称
|
||||
- 从描述中提取关键词(动词+名词)
|
||||
- 转换为英文 kebab-case 格式
|
||||
- 如果名称已存在,添加数字后缀(如 `-2`, `-3`)
|
||||
2. **验证名称**: 确保名称符合 kebab-case 规范
|
||||
3. **默认位置**: 全局 (`~/.config/opencode/command/`) - commands are created here by default
|
||||
4. **创建模板**:
|
||||
- 生成包含 `description` 的 frontmatter
|
||||
- 创建支持 `$ARGUMENTS` 的模板
|
||||
- 包含使用示例
|
||||
5. **写入文件**: 创建命令文件并写入内容
|
||||
6. **测试**: 验证文件存在且格式正确
|
||||
|
||||
### Sample Response Format:
|
||||
```
|
||||
我将帮你创建命令。
|
||||
|
||||
基于您的描述,自动生成名称:[generated-name]
|
||||
|
||||
**自动命名规则**:
|
||||
- 从描述中提取关键词(动词+名词)
|
||||
- 转换为 kebab-case 格式(小写字母、连字符)
|
||||
- 检查名称冲突,自动添加数字后缀
|
||||
|
||||
**文件详情**:
|
||||
- 名称: [generated-name]
|
||||
- 用途: [brief-description]
|
||||
- 位置: 全局 (~/.config/opencode/command/)
|
||||
|
||||
已创建 [file-path]:
|
||||
|
||||
```markdown
|
||||
[complete file content]
|
||||
```
|
||||
|
||||
要测试,请运行:[/command-name]
|
||||
```
|
||||
|
||||
## Resources
|
||||
- [OpenCode Commands Documentation](https://opencode.ai/docs/commands)
|
||||
- [OpenCode Configuration Guide](https://opencode.ai/docs/config)
|
||||
|
||||
---
|
||||
|
||||
*Last updated: 2026-01-15*
|
||||
@@ -1,251 +0,0 @@
|
||||
# Skill Creation Guide
|
||||
|
||||
## Overview
|
||||
OpenCode skills are reusable behavior definitions for agents, defined in `skill/<name>/SKILL.md` files.
|
||||
|
||||
## Directory Structure
|
||||
**Default location (Global):**
|
||||
```
|
||||
~/.config/opencode/skill/
|
||||
└── <skill-name>/
|
||||
└── SKILL.md
|
||||
```
|
||||
|
||||
**Project-specific location (when needed):**
|
||||
```
|
||||
.opencode/skill/
|
||||
└── <skill-name>/
|
||||
└── SKILL.md
|
||||
```
|
||||
|
||||
## Skill File Requirements
|
||||
|
||||
### Frontmatter (Required)
|
||||
- `name`: Skill name (must match directory name)
|
||||
- `description`: Concise description (1-1024 characters)
|
||||
|
||||
### Frontmatter (Optional)
|
||||
- `license`: License identifier
|
||||
- `compatibility`: Compatibility constraints
|
||||
- `metadata`: Key-value pairs for additional context
|
||||
|
||||
## Naming Rules
|
||||
Skill names must:
|
||||
- Be 1-64 characters
|
||||
- Use lowercase alphanumeric with single hyphens
|
||||
- Not start or end with hyphen
|
||||
- Not contain consecutive hyphens
|
||||
- Match regex: `^[a-z0-9]+(-[a-z0-9]+)*$`
|
||||
|
||||
## Skill Content Structure
|
||||
A well-structured skill should include:
|
||||
|
||||
1. **Introduction**: Purpose and scope
|
||||
2. **Usage Instructions**: When and how to use the skill
|
||||
3. **Examples**: Practical implementation examples
|
||||
4. **Best Practices**: Recommended approaches
|
||||
5. **Troubleshooting**: Common issues and solutions
|
||||
6. **References**: Related documentation
|
||||
|
||||
## Example Skill Template
|
||||
```markdown
|
||||
---
|
||||
name: example-skill
|
||||
description: Brief description of what this skill does
|
||||
---
|
||||
|
||||
# Skill Title
|
||||
|
||||
## Purpose
|
||||
Explain what this skill helps achieve and when to use it.
|
||||
|
||||
## Core Concepts
|
||||
- Key principle 1
|
||||
- Key principle 2
|
||||
|
||||
## Usage
|
||||
Step-by-step instructions for using this skill.
|
||||
|
||||
## Examples
|
||||
### Basic Example
|
||||
```bash
|
||||
# Example code or commands
|
||||
```
|
||||
|
||||
### Advanced Example
|
||||
Detailed example with explanation.
|
||||
|
||||
## Best Practices
|
||||
1. Recommended approach 1
|
||||
2. Recommended approach 2
|
||||
|
||||
## Troubleshooting
|
||||
| Issue | Solution |
|
||||
|-------|----------|
|
||||
| Common problem | How to fix it |
|
||||
|
||||
## References
|
||||
- [Documentation link](https://opencode.ai/docs)
|
||||
- Related skills or commands
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Skill Development
|
||||
1. **Modular Design**: Keep skills focused on specific domains
|
||||
2. **Comprehensive Documentation**: Include examples and edge cases
|
||||
3. **Consistent Formatting**: Follow existing skill patterns
|
||||
4. **Testing**: Verify skill loads correctly with `skill({ name: "skill-name" })`
|
||||
5. **Version Control**: Track skill changes in Git
|
||||
|
||||
### Organization
|
||||
1. **Default location**: Global (`~/.config/opencode/skill/`) - skills are created here by default for reuse across projects
|
||||
2. **Naming Conventions**: Use kebab-case for all skill names
|
||||
3. **Documentation**: Maintain README or index of available skills
|
||||
4. **Permissions**: Configure access controls in `opencode.json`
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### Skill Creation Checklist
|
||||
- [ ] Directory name matches skill name
|
||||
- [ ] SKILL.md contains required frontmatter
|
||||
- [ ] Description is 1-1024 characters
|
||||
- [ ] Name follows naming rules
|
||||
- [ ] Content includes usage and examples
|
||||
- [ ] Skill loads without errors
|
||||
|
||||
### Common Patterns
|
||||
|
||||
**Create a new skill:**
|
||||
```bash
|
||||
# Create skill directory
|
||||
mkdir -p ~/.config/opencode/skill/my-skill
|
||||
|
||||
# Create SKILL.md
|
||||
cat > ~/.config/opencode/skill/my-skill/SKILL.md << 'EOF'
|
||||
---
|
||||
name: my-skill
|
||||
description: Description of my skill
|
||||
---
|
||||
|
||||
# My Skill
|
||||
|
||||
## Usage
|
||||
Instructions here.
|
||||
|
||||
## Examples
|
||||
Example content.
|
||||
EOF
|
||||
```
|
||||
|
||||
## Testing and Validation
|
||||
|
||||
### Test Skill Loading
|
||||
```bash
|
||||
# In OpenCode session
|
||||
skill({ name: "my-skill" })
|
||||
```
|
||||
|
||||
### Verify Syntax
|
||||
```bash
|
||||
# Check YAML frontmatter
|
||||
head -20 skill/my-skill/SKILL.md
|
||||
|
||||
# Validate naming
|
||||
echo "skill-name" | grep -E '^[a-z0-9]+(-[a-z0-9]+)*$'
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Skill Not Loading
|
||||
1. **Directory name**: Must match skill name in frontmatter
|
||||
2. **File name**: Must be `SKILL.md` (all caps)
|
||||
3. **Frontmatter**: Requires `name` and `description`
|
||||
4. **Naming rules**: Verify name follows conventions
|
||||
5. **Permissions**: Check `opencode.json` permissions
|
||||
|
||||
### Common Errors
|
||||
- **"Skill not found"**: Directory name mismatch or missing SKILL.md
|
||||
- **"Invalid frontmatter"**: Missing required fields or YAML syntax error
|
||||
- **"Permission denied"**: Skill blocked by permission configuration
|
||||
|
||||
## Integration with OpenCode Config
|
||||
|
||||
### Permissions Configuration
|
||||
Add to `opencode.json`:
|
||||
```json
|
||||
{
|
||||
"permission": {
|
||||
"skill": {
|
||||
"*": "allow",
|
||||
"experimental-*": "ask",
|
||||
"internal-*": "deny"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Agent-Specific Settings
|
||||
```json
|
||||
{
|
||||
"agent": {
|
||||
"plan": {
|
||||
"permission": {
|
||||
"skill": {
|
||||
"analysis-*": "allow"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Response Guide for Skill Creation Requests
|
||||
|
||||
When users ask to create skills, follow this structured approach:
|
||||
|
||||
1. **自动生成名称**: 基于用户描述自动生成 skill 名称
|
||||
- 从描述中提取核心功能关键词
|
||||
- 转换为小写字母、连字符格式
|
||||
- 如果名称已存在,添加数字后缀
|
||||
2. **验证名称**: 确保名称符合命名规则(小写字母、连字符、字母数字)
|
||||
3. **默认位置**: 全局 (`~/.config/opencode/skill/<name>/`) - skills are created here by default
|
||||
4. **创建 SKILL.md**:
|
||||
- 包含 `name` 和 `description` 的 frontmatter
|
||||
- 结构化内容:Purpose, Usage, Examples, Best Practices, Troubleshooting
|
||||
5. **写入文件**: 创建完整的 SKILL.md 文件
|
||||
6. **测试**: 验证技能可正常加载 `skill({ name: "<skill-name>" })`
|
||||
|
||||
### Sample Response Format:
|
||||
```
|
||||
我将帮你创建技能。
|
||||
|
||||
基于您的描述,自动生成名称:[generated-name]
|
||||
|
||||
**自动命名规则**:
|
||||
- 从描述中提取核心功能关键词
|
||||
- 转换为小写字母、连字符格式
|
||||
- 检查名称冲突,自动添加数字后缀
|
||||
|
||||
**文件详情**:
|
||||
- 名称: [generated-name]
|
||||
- 主要功能: [brief-description]
|
||||
- 位置: 全局 (~/.config/opencode/skill/)
|
||||
|
||||
已创建 [file-path]:
|
||||
|
||||
```markdown
|
||||
[complete file content]
|
||||
```
|
||||
|
||||
要测试,请运行:skill({ name: "skill-name" })
|
||||
```
|
||||
|
||||
## Resources
|
||||
- [OpenCode Skills Documentation](https://opencode.ai/docs/skills)
|
||||
- [OpenCode Configuration Guide](https://opencode.ai/docs/config)
|
||||
- [GitHub Repository](https://github.com/anomalyco/opencode)
|
||||
|
||||
---
|
||||
|
||||
*Last updated: 2026-01-15*
|
||||
Reference in New Issue
Block a user