AgentSkillsCN

oc-agent

为Claude Code与OpenCode创建并优化代理与子代理。在设计新代理、改进现有代理,或在代理架构中运用提示工程原则时调用此功能。

SKILL.md
--- frontmatter
name: oc-agent
description: Creates and refines agents and subagents for Claude Code and OpenCode. Invoked when designing new agents, improving existing ones, or applying prompt engineering principles to agent architecture.

Agent Editor

Expert at creating and maintaining agents/subagents following Anthropic's prompt engineering best practices, targeting both Claude Code and OpenCode.

Agent Locations

Claude Code

  • .claude/agents/<name>.md

OpenCode

  • Project: .opencode/agents/<name>.md
  • Global: ~/.opencode/agents/<name>.md

Claude Code Agent Format

yaml
---
name: lowercase-hyphenated          # Required
description: When to delegate       # Required
tools: Read, Glob, Grep, Bash       # Comma-separated
model: sonnet | opus | haiku | inherit
permissionMode: default | acceptEdits | dontAsk | bypassPermissions | plan
skills:
  - skill-name
---

Agent instructions go here.

Claude Code Fields

FieldRequiredNotes
nameYesLowercase hyphenated identifier
descriptionYesTriggers delegation decisions
toolsNoComma-separated list of allowed tools
modelNosonnet, opus, haiku, or inherit
permissionModeNoControls permission prompting behavior
skillsNoList of skill names available to the agent

OpenCode Agent Format

yaml
---
description: When to delegate       # Required (name derived from filename)
mode: primary | subagent | all      # Default: all
model: provider/model-id            # Optional, inherits from parent
temperature: 0.3                    # Optional (0.0-1.0)
maxSteps: 10                        # Optional, limit iterations
permission:                         # ask | allow | deny
  edit: deny                        # Disable editing
  write: deny                       # Disable writing
  mcp_toolname_*: deny              # Wildcards supported
  bash:
    "*": ask                        # Default for all bash
    "git diff": allow               # Specific command override
    "rm -rf *": deny
  webfetch: deny
  task:                             # Control subagent invocation
    "*": deny
    "explore": allow
---

Agent instructions go here.

OpenCode Fields

FieldRequiredNotes
descriptionYesTriggers delegation decisions (name comes from filename)
modeNoprimary = main agent, subagent = delegated, all = both
modelNoprovider/model-id format, inherits from parent
temperatureNo0.0-1.0
maxStepsNoLimit agent iterations
permissionNoGranular per-tool permissions with wildcards

OpenCode Permission Patterns

Permissions support three levels: allow, ask, deny. They can be set per-tool with glob patterns:

yaml
permission:
  edit: allow              # Simple: allow all edits
  bash:
    "*": ask               # Default: ask for all bash
    "git *": allow         # Override: allow git commands
    "rm -rf *": deny       # Override: deny dangerous commands
  task:
    "*": deny              # Default: deny all subagents
    "explore": allow       # Override: allow explore subagent

Key Principles

  1. Single purpose - One specific task per agent
  2. Clear description - Triggers delegation decisions in both tools
  3. Minimal permissions - Grant only necessary access
  4. Right-size model - haiku=explore, sonnet=analyze, opus=critical
  5. Mode matters (OpenCode) - Use subagent for delegated work, primary for main agents

Workflow

When creating a new agent:

  1. Determine the agent's purpose and which tools it targets (Claude Code, OpenCode, or both)
  2. Choose a descriptive name (lowercase-hyphenated for Claude Code, filename for OpenCode)
  3. Write a description that clearly states when to delegate to this agent
  4. Determine minimum required permissions/tools
  5. Select appropriate model tier for the complexity level
  6. Draft focused instructions in the body
  7. Create the agent file(s):
    • For Claude Code: .claude/agents/<name>.md
    • For OpenCode: .opencode/agents/<name>.md

Quality Checklist

  • Single, focused purpose
  • Description states delegation triggers clearly
  • Permissions restricted to minimum necessary
  • Model appropriate for task complexity
  • Instructions are concise and actionable
  • Format matches target tool's specification