关于 opencode-agent-creator
用于创建和配置 OpenCode 专用 Agent 的技能,面向需要特定任务与工作流的团队。内容涵盖 Agent 类型、提示词、模型、工具、权限,以及全局或项目级配置。
主要功能
- 01创建主 Agent 和子 Agent
- 02配置提示词与模型
- 03控制工具和权限
- 04支持 Markdown 与 JSON 配置
- 05说明全局及项目级设置
适用场景
- 01设置代码审查子 Agent
- 02限制工具并配置操作审批
- 03创建项目专用文档 Agent
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ tumf/ skills --skill opencode-agent-creator安装后在 Claude Code 中输入/opencode-agent-creator确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
README.mdexamples/code-reviewer.mddebug.mddocs-writer.mdopencode.jsoncREADME.mdsecurity-auditor.md详细介绍
OpenCode Agent 创建器
在创建 OpenCode Agent 时使用此技能——这些是针对特定任务和工作流配置的专用 AI 助手。
适用场景
当用户希望进行以下操作时,使用此技能:
- 创建新的 OpenCode Agent(主 Agent 或子 Agent)
- 为特定任务配置专用 AI 助手
- 为 Agent 设置自定义提示词、模型和工具访问权限
- 定义 Agent 的权限和行为
Agent 类型
主 Agent
可直接与之交互的主要助手。用户可以使用 Tab 键或 switch_agent 快捷键在它们之间切换。
内置示例:
- Build:启用所有工具的完整开发
- Plan:具有受限权限的分析和规划
子 Agent
由主 Agent 调用或通过 @mention 手动调用的专用助手,用于执行特定任务。
内置示例:
- General:可使用所有工具(todo 除外)的多步骤任务
- Explore:快速、只读地探索代码库
Agent 结构
OpenCode Agent 可以通过以下两种方式定义:
1. Markdown 文件(推荐)
在以下目录中创建 .md 文件:
- 全局:
~/.config/opencode/agents/ - 项目级:
.opencode/agents/
格式:
---
description: Brief description of agent purpose
mode: primary|subagent|all
model: provider/model-id (optional)
temperature: 0.0-1.0 (optional)
maxSteps: number (optional)
tools:
write: true|false
edit: true|false
bash: true|false
permission:
edit: allow|ask|deny
bash:
"*": allow|ask|deny
"specific command": allow|ask|deny
webfetch: allow|ask|deny
task:
"*": allow|ask|deny
"agent-name": allow|ask|deny
hidden: true|false (optional, for subagents)
disable: true|false (optional)
---
System prompt content here.
Define the agent's purpose, behavior, and guidelines.
文件名将成为 Agent 名称:code-reviewer.md → code-reviewer Agent
2. JSON 配置
添加到 opencode.jsonc:
{
"$schema": "https://opencode.ai/config.json",
"agent": {
"agent-name": {
"description": "Brief description",
"mode": "primary",
"model": "anthropic/claude-sonnet-4-20250514",
"prompt": "{file:./prompts/agent.txt}",
"temperature": 0.3,
"maxSteps": 10,
"tools": {
"write": true,
"edit": true,
"bash": true
},
"permission": {
"edit": "allow",
"bash": {
"*": "ask",
"git status": "allow"
}
}
}
}
}
配置选项
必填
description:简要说明 Agent 的用途及适用场景
模式
mode:"primary"、"subagent"或"all"(默认:"all")primary:面向用户的 Agent,可通过 Tab 切换subagent:由其他 Agent 或通过 @mention 调用all:两种方式均可使用
可选
prompt:自定义系统提示词(内联或{file:path})model:覆盖默认模型(格式:provider/model-id)temperature:控制随机性(0.0-1.0)0.0-0.2:专注、确定性强(代码分析)0.3-0.5:均衡(通用开发)0.6-1.0:富有创意(头脑风暴)
maxSteps:仅输出文本响应前的最大 Agent 迭代次数disable:设为true以禁用 Agenthidden:在 @mention 自动补全中隐藏子 Agent(仅限子 Agent)
工具
控制可用工具:
tools:
write: true
edit: false
bash: false
mymcp_*: false # Wildcard to disable MCP server tools
权限
控制哪些操作需要审批:
permission:
edit: ask # ask, allow, or deny
bash:
"*": ask # Default for all commands
"git status": allow
"git log*": allow
"git push": ask
webfetch: deny
task: # Which subagents can be invoked
"*": deny
"code-*": allow # Allow code-prefixed subagents
"reviewer": ask
取值:"allow"(无需审批)、"ask"(询问用户)、"deny"(禁用)
特定提供商的选项
任何其他选项都会传递给提供商:
reasoningEffort: high # OpenAI reasoning models
textVerbosity: low # OpenAI reasoning models
示例
文档撰写者
---
description: Writes and maintains project documentation
mode: subagent
tools:
bash: false
---
You are a technical writer. Create clear, comprehensive documentation.
Focus on:
- Clear explanations
- Proper structure
- Code examples
- User-friendly language
安全审计员
---
description: Performs security audits and identifies vulnerabilities
mode: subagent
tools:
write: false
edit: false
permission:
bash:
"*": deny
---
You are a security expert. Focus on identifying potential security issues.
Look for:
- Input validation vulnerabilities
- Authentication and authorization flaws
- Data exposure risks
- Dependency vulnerabilities
- Configuration security issues
代码审查员
---
description: Reviews code for best practices and potential issues
mode: subagent
model: anthropic/claude-sonnet-4-20250514
temperature: 0.1
tools:
write: false
edit: false
permission:
bash:
"*": ask
"git diff": allow
"git log*": allow
---
You are a code reviewer. Focus on security, performance, and maintainability.
Review checklist:
1. Code quality and best practices
2. Potential bugs and edge cases
3. Performance implications
4. Security considerations
Provide constructive feedback without making direct changes.
调试 Agent
---
description: Focused debugging with investigation tools
mode: primary
temperature: 0.2
tools:
write: false
permission:
bash:
"*": allow
edit: ask
---
You are a debugging specialist. Systematically investigate issues.
Approach:
1. Reproduce the issue
2. Gather relevant logs and context
3. Identify root cause
4. Suggest minimal fix
5. Recommend preventive measures
深度思考者(推理模型)
---
description: High-effort reasoning for complex problems
mode: subagent
model: openai/gpt-5
temperature: 0.1
reasoningEffort: high
textVerbosity: low
maxSteps: 20
---
You solve complex problems with deep reasoning.
For each problem:
1. Break down into components
2. Analyze dependencies
3. Consider edge cases
4. Propose robust solutions
5. Validate approach
最佳实践
- 清晰的描述:帮助用户和 Agent 了解何时调用
- 合适的模式:主要工作选择
primary,专门任务选择subagent - 限制工具:仅启用 Agent 所需的工具
- 细化权限:高风险操作使用
ask,安全操作使用allow - 调整温度:分析任务使用较低值,创意任务使用较高值
- 明确提示词:具体说明 Agent 的角色和约束
- 文件位置:
- 全局:适用于多个项目的通用 Agent
- 项目级:特定于项目的工作流和约定
实现步骤
创建 Agent 时:
-
确定范围:
- 用于主要工作流的主 Agent
- 用于专业任务的子 Agent
-
选择位置:
- 全局(
~/.config/opencode/agents/),用于可复用的 Agent - 项目(
.opencode/agents/),用于特定项目的 Agent
- 全局(
-
定义配置:
- 必填:
description、mode - 可选:
model、temperature、maxSteps、tools、permission
- 必填:
-
编写系统提示词:
- 明确的角色定义
- 具体的指南和限制
- 预期行为
-
测试 Agent:
- 对于主 Agent:按 Tab 切换到它
- 对于子 Agent:使用
@agent-name调用,或让主 Agent 使用它
-
优化:
- 根据输出质量调整温度
- 根据使用情况微调权限
- 更新提示词以获得更好的结果
用法
主 Agent
- 按 Tab 循环切换主 Agent
- 或使用配置的
switch_agent快捷键
子 Agent
- 自动:主 Agent 根据描述调用子 Agent
- 手动:使用
@agent-name message直接调用 - 导航:使用
<Leader>+Right/Left在父级和子级会话之间切换
交互式创建
使用内置命令:
opencode agent create
此命令将:
- 询问 Agent 的位置(全局/项目)
- 请求描述
- 生成系统提示词和标识符
- 让你选择工具
- 创建包含配置的 Markdown 文件
注意事项
- Markdown 文件名决定 Agent 名称
- 自定义 Agent 可以与内置 Agent 协同工作
- 更改 Agent 后需要重启 OpenCode
- 模型格式:
provider/model-id(例如,anthropic/claude-sonnet-4-20250514) - 隐藏的子 Agent(
hidden: true)不会显示在自动补全中,但仍可通过编程方式调用 - 任务权限控制 Agent 可以调用哪些子 Agent
评论
支持 Markdown