Chapter 5 · 6 lessons
Plugins, Commands & Subagents
Choosing between slash commands, skills, subagents, and plugins — and packaging them so a whole team gets the same setup.
Claude Code · Cursor · OpenAI Codex · GitHub Copilot
Show all 6 lessonsHide list
Lesson 1 of 6
Choosing the Right Primitive
| You want… | Use | Why |
|---|---|---|
| A prompt you trigger by name | Slash command / prompt file | Explicit, predictable, no auto-activation |
| Procedure the agent picks up when relevant | Skill | Description-driven, loads on demand |
| Noisy work kept out of the main thread | Subagent | Separate context window, returns a summary |
| A specialist persona with limited tools | Custom agent / subagent definition | Own prompt and tool allowlist |
| A bundle others install in one step | Plugin | Ships skills, agents, hooks, MCP together |
Signal
Say which primitive you would NOT use and why. 'This is a subagent, not a skill, because the exploration output is huge and I only need the conclusion' shows real judgment.
Lesson 2 of 6
Subagents and Context Isolation
A subagent runs in its own context window with its own prompt and (optionally) a restricted tool set, then returns a result to the parent. The parent pays only for the summary, not for every file the subagent read.
- Exploration: 'find every place we parse dates' across a large repo
- Review: a reviewer that never saw the implementer's reasoning, so it cannot rationalize bugs
- Parallel work: independent tasks run at the same time
- Specialists: a read-only security reviewer, a test writer, a docs writer
| Tool | Where definitions live |
|---|---|
| Claude Code | .claude/agents/*.md (project), ~/.claude/agents (user), plugin agents/ |
| Cursor | Built-in subagent types plus custom agents; also Task-based delegation |
| Copilot | .github/agents/*.md custom agents; CLI ships built-in subagents like explore |
Cost
Subagents are not free — each one spends its own tokens. Use them when isolation or parallelism pays for itself, not for trivial lookups.
Lesson 3 of 6
Plugins as Team Distribution
A plugin packages skills, commands, agents, hooks, and MCP configuration so a team installs one thing and gets the same behavior. Claude Code, Cursor, and Codex all have plugin formats; OpenClaw can import all three.
my-plugin/ ├── .claude-plugin/plugin.json # manifest (optional with default layout) ├── skills/<name>/SKILL.md ├── commands/*.md # flat skills (legacy style) ├── agents/*.md # subagent definitions ├── hooks/hooks.json ├── .mcp.json # MCP servers └── settings.json # plugin defaults
- Distribute through a marketplace (e.g. /plugin marketplace add owner/repo in Claude Code)
- Namespaced commands avoid collisions: /my-plugin:review
- Plugin subagents in Claude Code cannot set hooks, mcpServers, or permissionMode — a deliberate security boundary
- Enterprises can restrict marketplaces (strictKnownMarketplaces) and force-enable vetted plugins
Lesson 4 of 6
Slash Commands and Prompt Files
Slash commands and prompt files are the explicit end of the spectrum: you type /review or pick a prompt, and a fixed template runs. In Claude Code, skills and commands have merged — a skill can be invoked as /skill-name. Copilot uses .github/prompts/*.prompt.md with input variables.
- Good commands: /review-pr, /write-migration, /release-notes, /triage-issue
- Keep arguments explicit ($ARGUMENTS or named inputs) so runs are reproducible
- If you find yourself typing the same command every time, consider whether it should be a skill or a hook
Lesson 5 of 6
Portability Across Tools
| Asset | Portable? | Notes |
|---|---|---|
| SKILL.md | High | Open standard; frontmatter strictness varies slightly |
| AGENTS.md | High | Widely read; CLAUDE.md can import it |
| MCP servers | High | Config file path and format differ per tool |
| Hooks | Low | Event names, payloads, and file formats are tool-specific |
| Plugin manifests | Medium | Different manifests; OpenClaw and sync tools can map between them |
Strategy
Write skills and MCP servers once. Keep a thin per-tool layer for hooks and manifests. Tools like OpenClaw bundles or skill sync CLIs can reduce the duplication.
Lesson 6 of 6
Worked Example: Self-Review vs Clean-Context Review
After implementing a password-reset flow, the developer asks for a review.
you: any bugs in what you just wrote?
agent: I reviewed the implementation carefully. It follows best
practices and handles edge cases well. No issues found.you: run the reviewer subagent on this diff against the spec reviewer (read-only, fresh context): 1. HIGH auth/reset.ts:42 reset token never expires — add 30-min TTL 2. HIGH auth/reset.ts:57 token compared with === — use timing-safe compare 3. MED tests/reset.test.ts no test for reused token you: fix 1–3 in the implementer thread
- The reviewer had none of the implementer's reasoning to defend
- Read-only tools meant it reported instead of silently 'fixing'
- Findings had file:line and severity, so they were actionable
Takeaway
Isolation beats intelligence for review. Never let the author grade its own work.