Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

16A.3 Custom Agents, Skills, and MCP

Agents define a role, invocation mode, and permissions. Skills supply procedures the agent can load when needed. MCP connects tools exposed by another process or service.

Make a read-only reviewer

Put a Markdown definition under .opencode/agents/. The frontmatter sets mode and permissions, the body supplies the system instructions, and the filename becomes the agent ID. The workshop adapts the upstream task-reviewer to check the ranking rule while keeping the evidence-and-verdict exercise. The reviewer denies edits and shell calls. Official agent configuration · Upstream reviewer example

modeWhere it runs
primaryDirectly in the current session
subagentIn a child session started by a parent
allIn either role. The workshop uses this mode so the reviewer is directly selectable from the CLI

A parent agent's subagent permissions determine which child agents it can start. Each child uses its own permissions. In the lab, select task-reviewer with /agents, attach ranking.py and the acceptance script, and inspect the evidence and verdict. Agent modes and delegation rules

Package a procedure as a skill

.opencode/skills/explain-ranking/SKILL.md defines a procedure. Its name and description guide when the model loads it, and the body gives it steps to follow.

---
name: explain-ranking
description: Explain how a ranking change chooses the winner, including ties and validation.
---

1. Give a two-item example with equal scores and name the expected winner.
2. Point to the comparison in `ranking.py` that determines the result.
3. State which check would confirm it and whether that check was run.

Ask the agent to use the explain-ranking skill on the latest tie-break change. Check for an example, a code location, and the validation result. You can observe the on-demand loading mechanism introduced in Chapter 9. OpenCode skills guide · Chapter 9

Connect MCP in a project that needs it

To try a documentation search server in a temporary project, use the Context7 endpoint from the official guide:

opencode mcp add context7 --url https://mcp.context7.com/mcp
opencode mcp list

Adding a server updates project configuration. Use /mcps to inspect status and any authentication requirements, and make tools available only where useful. In handwritten V2 configuration, put connections in mcp.servers. Local servers use stdio and remote servers use Streamable HTTP. The ranking lab uses local files and runs independently of MCP integrations. MCP setup and management · Chapter 19 on MCP