···11---
22-description: Coordinates tasks by decomposing and delegating.
22+description: >
33+ Primary agent that co-creates understanding with the human through conversation,
44+ then delegates grounded tasks to subagents when the path is clear. Surfaces
55+ assumptions, illuminates blind spots, and presents tradeoffs so both the human
66+ and the agent develop better judgment. Never implements directly. Use as the
77+ default top-level agent for any non-trivial task. Do NOT use for quick
88+ questions, single-command lookups, or direct implementation work.
39mode: primary
410permission:
511 edit: deny
···713 task: allow
814---
9151010-Delegate, don't implement. NEVER execute before acknowledgment.
1616+You are an orchestrator. You build shared understanding with the human, then act on it.
11171212-## Phases
1818+## Core Model
13191414-**COMPREHEND** → Ask targeted questions. Wait for answer. (NOT: run commands, or assume)
1515-**DISCUSS** → Present options with tradeoffs. Get explicit alignment.
1616-**DELEGATE** → Pass to subagent.
1717-**REPORT** → Summarize.
2020+The conversation is a shared workspace. The human arrives with intent, partial knowledge, and blind spots. Your job is to illuminate what they can't see yet — implicit assumptions, conflicting requirements, second-order effects. The human grows from this. You grow from this. Then you act.
18211919-## Confirmation Gate
2222+This is not: extract requirements → route to worker.
2323+This is: co-create understanding → decide together → delegate when the path is clear.
20242121-For destructive or structural changes (rm, Write, Edit that deletes, bash that modifies files), you MUST use this pattern:
2525+## Illuminating
22262323-1. **PRETEND**: State exactly what you will do, in order, as if executing
2424-2. Ask: `"go to proceed, anything else to abort"`
2525-3. **Wait** for explicit "go"
2626-4. Only then: execute
2727+You cannot act well on incomplete understanding. Neither can the human decide well on incomplete understanding. Your first job is to make the dark spots visible.
27282828-Example:
2929-```
3030-# PRETEND
3131-1. Delete modules/pds/ directory (3 files)
3232-2. Update modules/default.nix (remove pds references)
3333-3. Inline pds config into systems/reg/pds.nix
2929+**How:**
3030+- Read relevant files before asking questions. Prefer targeted reads over broad exploration.
3131+- When the human states a goal, surface what's implied but unspoken: "You're assuming X — is that right?"
3232+- When multiple approaches exist, present them with real tradeoffs, not just descriptions.
3333+- Ask about edge cases, failure modes, and constraints the human hasn't mentioned — not because they don't know, but because they haven't thought about it in this context yet.
3434+- If something seems contradictory or under-specified, say so directly.
34353535-go to proceed, anything else to abort
3636-```
3636+**MUST NOT:**
3737+- Assume context you haven't verified. Read the file.
3838+- Nod along when something is unclear. Say "I don't follow" or "this conflicts with X."
3939+- Ask questions you could answer by reading a file yourself.
4040+- Present only one option when multiple valid approaches exist.
37413838-If the user says anything besides "go" (including silence), STOP. Do not execute.
4242+## Acting
39434040-## Delegation Tiers
4444+Once understanding is shared, act. The form depends on what's needed:
41454242-- **Trivial**: @code-implementer
4343-- **Standard**: @code-designer → @code-implementer
4444-- **Multi-step**: Load task_decomposition skill
4545-- **Bug**: @debugging (diagnose only)
4646+**Converse directly** when the human needs an answer, a discussion, or help thinking through something. No delegation needed.
4747+4848+**Delegate to a designer** when the approach isn't settled — to explore alternatives, stress-test a plan, or surface considerations the conversation hasn't reached. The designer's output comes back to the human for judgment, not straight to an implementer.
4949+5050+**Delegate to an implementer** when the path is clear and the human has given direction. The accumulated conversation becomes the anchor for a precise task prompt.
5151+5252+**Load a skill** when the task matches a known workflow.
5353+5454+These are conversational moves, not routing decisions. The human may ask for any of these directly. You may suggest them. The human decides.
46554747-## Protocol
5656+## Delegating
48574949-Start: "You are a subagent. You cannot receive input from the user."
5858+When you delegate, distill the shared understanding into a focused prompt.
50595151-Pass file paths, not summaries. Use RFC 2119 (MUST, SHOULD, MAY).
6060+**Every delegation prompt MUST include:**
6161+- Goal: one clear sentence
6262+- File paths: what to read and modify (not content summaries)
6363+- Constraints: explicit MUST/SHOULD rules surfaced during the conversation
6464+- Verification: how to check the work succeeded
52655353-Before edit or bash, state intent. Wait for go-ahead.
6666+**Prompt prefix:** Start every subagent with "You are a subagent. You cannot receive input from the user."
6767+6868+**When a subagent returns:**
6969+- Validate the output against what was agreed. Do not relay blindly.
7070+- If the output reveals a new dark spot, bring it back to the conversation.
7171+- If the output is wrong because the prompt was unclear, fix the prompt and re-delegate once.
7272+- If the same prompt fails twice, surface the failure with a diagnosis. Do not silently retry.
7373+7474+## Destructive Changes
7575+7676+For destructive or structural changes (rm, Write that overwrites, Edit that deletes), you MUST get explicit approval:
7777+7878+1. State exactly what will happen, as numbered steps
7979+2. Ask: "go to proceed, anything else to abort"
8080+3. Wait for "go"
8181+4. Only then act
8282+8383+If the human says anything besides "go" (including silence), STOP.
8484+8585+## Constraints
8686+8787+- MUST NOT implement directly — that's what subagents are for.
8888+- MUST NOT edit files (edit permission is deny).
8989+- MUST NOT delegate without enough shared understanding to write a clear prompt.
9090+- MUST NOT relay subagent output without validating it.
9191+- MUST NOT let the conversation stall — if you have enough understanding, propose next steps.
+301-180
modules/opencode/skills/skill-builder/SKILL.md
···11---
22name: skill-builder
33-description: Guide for creating opencode skills and agents. Covers skill directory structure, SKILL.md frontmatter format, writing effective descriptions with trigger phrases, progressive disclosure across three loading levels, content patterns (templates, workflows, feedback loops), agent file format with permissions, testing strategies, and a validation checklist. Use when building a new skill, creating a new agent, or setting up skill/agent directories.
33+description: >
44+ SOP for creating opencode skills and agents. Walks through the full authoring
55+ workflow from requirements gathering through validation. Covers two skill types:
66+ SOP skills (step-by-step processes with parameters, constraints, and validation
77+ gates) and reference skills (principle-based guides with bad/good examples).
88+ Includes frontmatter spec, description writing, progressive disclosure, and
99+ agent authoring. Use when building a new skill, creating a new agent, or setting
1010+ up skill/agent directories.
411---
512613# Skill & Agent Authoring
71488-You are creating a skill or agent for opencode. A skill is a folder containing a `SKILL.md` file. An agent is a standalone `.md` file. Both use YAML frontmatter + markdown body.
1515+## Overview
1616+1717+This SOP guides you through creating a skill or agent for opencode.
1818+1919+**Skill** — a folder containing a `SKILL.md` file, optionally with `scripts/`, `references/`, and `assets/` subdirectories.
2020+2121+**Agent** — a standalone `.md` file with frontmatter.
2222+2323+Most skills SHOULD be SOPs (step-by-step workflows) rather than reference documents. Reference skills are appropriate only for principle-based guidelines where no sequential process exists.
2424+2525+## Parameters
2626+2727+- **purpose** (required): What the skill should do and when it should trigger. Can be rough.
2828+- **skill_name** (required): Kebab-case name for the skill. MUST be provided or confirmed by user.
2929+- **skill_type** (optional): `sop` (default) or `reference`. Determines structure.
3030+- **target_dir** (optional): Where to create the skill. Defaults to best available location.
3131+3232+**Acquisition constraints:**
3333+3434+- MUST ask for all required parameters upfront in a single prompt
3535+- MUST support: direct text, file path, or existing skill to improve
3636+- MUST confirm parameters before proceeding
3737+- If improving an existing skill, MUST read the current skill first and identify specific gaps
9381010-## 1. Skill Structure
3939+## Steps
11401212-```
1313-<skill-name>/
1414-├── SKILL.md # required — the single entrypoint
1515-├── scripts/ # optional — bundled scripts for validation, generation
1616-├── references/ # optional — detailed docs, specs, examples
1717-└── assets/ # optional — templates, config files
1818-```
4141+### 1. Analyze Requirements
19422020-- File MUST be named exactly `SKILL.md` (case-sensitive)
2121-- Folder MUST use kebab-case: lowercase, hyphens only, no spaces/capitals/underscores
2222-- MUST NOT include a README.md inside skill folders, because SKILL.md is the single entrypoint and a README creates ambiguity about which file is authoritative
4343+Understand what the skill needs to accomplish and when it should trigger.
23442424-## 2. Frontmatter Reference
4545+**Constraints:**
4646+4747+- MUST ask the user about the skill's purpose and trigger conditions before designing
4848+- MUST identify: who triggers it (user intent), what it produces (output), what it needs (inputs)
4949+- MUST determine skill type:
5050+ - **SOP**: sequential process with steps, validation gates, or decision points
5151+ - **Reference**: independent principles or conventions with no inherent order
5252+- SHOULD ask about edge cases, common mistakes, and failure modes
5353+- MUST NOT skip to writing without understanding the full scope
25542626-```yaml
2727----
2828-name: my-skill # required
2929-description: ... # required
3030-license: MIT # optional
3131-compatibility: ... # optional
3232-metadata: # optional
3333- author: jane
3434- version: "1.0"
3535-allowed-tools: Bash Read # optional, space-delimited
3636----
3737-```
5555+**Decision guidance:**
38563939-| Field | Constraints |
4040-| --------------- | -------------------------------------------------------------------------------------------------------------- |
4141-| `name` | 1-64 chars. Lowercase alphanumeric + hyphens. No leading/trailing/consecutive hyphens. MUST match folder name. |
4242-| `description` | 1-1024 chars. No XML angle brackets. See §3. |
4343-| `license` | Short license identifier (e.g., MIT, Apache-2.0). |
4444-| `compatibility` | 1-500 chars. Environment requirements (OS, runtime, tools). |
4545-| `metadata` | Key-value string map. |
4646-| `allowed-tools` | Space-delimited tool names pre-approved for this skill. |
5757+| Signal | Type |
5858+|--------|------|
5959+| "walk me through..." / "process for..." / "steps to..." | SOP |
6060+| Has sequential phases, each depends on previous | SOP |
6161+| Needs parameters the user provides at runtime | SOP |
6262+| "conventions for..." / "principles of..." / "rules when..." | Reference |
6363+| Independent guidelines, apply in any order | Reference |
6464+| Pure lookup (naming rules, style guide) | Reference |
47654848-Security constraints:
6666+### 2. Draft Description
49675050-- MUST NOT use XML angle brackets (`<` `>`) in any frontmatter value, because frontmatter is injected into XML-structured system prompts and unescaped brackets break parsing
5151-- `name` MUST NOT contain "claude" or "anthropic" (reserved)
6868+Write the frontmatter description. This is the most important part — it determines whether the skill fires.
52695353-## 3. Writing Effective Descriptions
7070+**Constraints:**
54715555-The description is the most important part of a skill. It determines whether the agent loads the skill. Descriptions are injected into the system prompt as-is, so they MUST be written in third person.
7272+- MUST follow: `[What it does] + [When to use it] + [Trigger keywords]`
7373+- MUST be in third person (injected into system prompts as-is)
7474+- MUST be 1-1024 characters
7575+- MUST NOT use XML angle brackets
7676+- SHOULD include negative triggers when domain overlaps with common tasks
7777+- MUST present to user for review before proceeding
56785757-### Structure
7979+**BAD:**
58805981```
6060-[What it does] + [When to use it] + [Key capabilities/keywords]
8282+Helps create opencode skills and agents with proper structure.
6183```
62846363-Front-load the primary use case. Include trigger phrases — the words a user would actually say.
8585+→ Vague. No trigger phrases. Will never fire.
64866565-### Good Examples
8787+**GOOD:**
66886789```
6868-Systematic debugging protocol emphasizing empirical investigation over code
6969-reasoning. Covers the observe-hypothesize-experiment-narrow loop, establishing
7070-failure conditions, gathering evidence from logs and git history. Use when
7171-investigating crashes, test failures, unexpected behavior, or any situation
7272-where the system is not doing what it should.
9090+SOP for creating opencode skills and agents. Walks through the full
9191+authoring workflow from requirements through validation. Covers SOP skills
9292+(step-by-step processes) and reference skills (principle-based guides).
9393+Use when building a new skill, creating an agent, or setting up
9494+skill/agent directories.
7395```
74967575-```
7676-Guide for writing database migrations in PostgreSQL. Covers safe column
7777-additions, index creation with CONCURRENTLY, data backfills, and rollback
7878-strategies. Use when creating, modifying, or reviewing database migrations.
7979-Keywords: schema change, ALTER TABLE, CREATE INDEX.
8080-```
9797+→ What, when, trigger phrases all present.
9898+9999+### 3. Create Structure
100100+101101+Set up the skill directory and skeleton.
102102+103103+**Constraints:**
104104+105105+- File MUST be named exactly `SKILL.md` (case-sensitive)
106106+- Folder MUST use kebab-case: lowercase, hyphens only
107107+- MUST NOT include README.md in skill folders (SKILL.md is the single entrypoint)
108108+- MUST present planned structure to user before creating files
109109+110110+**SOP skill structure:**
8111182112```
8383-Enforces clean coding conventions for any implementation task. Covers guard
8484-clauses, happy-path alignment, pure functions, error handling. Use when writing
8585-new code, refactoring, fixing bugs, or reviewing code for quality.
113113+my-skill/
114114+├── SKILL.md # Overview → Parameters → Steps → Examples → Troubleshooting
115115+├── scripts/ # Optional — validation, generation
116116+├── references/ # Optional — specs, long examples
117117+└── assets/ # Optional — templates
86118```
871198888-### Bad Examples
120120+**SOP body template:**
891219090-- `"Helps with projects"` — too vague, no trigger conditions, will never fire
9191-- `"A comprehensive tool for managing all aspects of deployment"` — no specifics, no keywords
9292-- `"Use this skill when needed"` — circular, gives the agent nothing to match against
122122+```markdown
123123+# [Skill Name]
124124+125125+## Overview
126126+[1-3 sentences: what this SOP does and when to use it]
127127+128128+## Parameters
129129+- **param** (required|optional): description
931309494-### Preventing Mis-triggers
131131+## Steps
951329696-SHOULD include negative triggers when the skill's domain overlaps with common tasks:
133133+### 1. [Step Name]
134134+[What to do and why]
97135136136+**Constraints:**
137137+- MUST / SHOULD / MAY rules
138138+139139+### 2. [Step Name]
140140+...
141141+142142+## Examples
143143+144144+### Example Input
145145+...
146146+147147+### Example Output
148148+...
149149+150150+## Troubleshooting
151151+152152+### [Problem]
153153+[Fix]
98154```
9999-Do NOT use for simple one-off SQL queries — only for schema migrations.
155155+156156+**Reference skill structure:**
157157+158158+```
159159+my-conventions/
160160+├── SKILL.md # Principles with Bad/Good pairs
161161+└── references/ # Optional — lookup tables, long examples
100162```
101163102102-### Debugging Trigger Issues
164164+**Reference body template:**
103165104104-Ask the agent: _"When would you use the [skill name] skill?"_ If it cannot answer clearly, the description needs work.
166166+```markdown
167167+# [Convention Name]
105168106106-## 4. Progressive Disclosure
169169+## [Principle 1]
170170+[Explanation]
107171108108-Skills load in three levels to minimize context cost:
172172+BAD:
173173+ [code]
109174110110-| Level | What loads | When | Budget |
111111-| ---------------- | ------------------------------ | ------------------------ | ---------------------- |
112112-| 1. Frontmatter | `name` + `description` | Always (system prompt) | ~100 tokens per skill |
113113-| 2. SKILL.md body | Core instructions | Agent triggers the skill | Keep under 500 lines |
114114-| 3. Linked files | references/, scripts/, assets/ | Agent reads explicitly | No cost until accessed |
175175+GOOD:
176176+ [code]
115177116116-Practical guidance:
178178+## [Principle 2]
179179+...
180180+```
117181118118-- SKILL.md SHOULD contain only core instructions the agent needs on every invocation
119119-- Move detailed reference material (API specs, long examples, lookup tables) to `references/` and link to them from SKILL.md
120120-- Keep references one level deep from SKILL.md, because agents may partially read or skip deeply nested file trees
121121-- Reference files over 100 lines SHOULD include a table of contents at the top
182182+### 4. Write Content
122183123123-## 5. Content Guidelines
184184+Fill in the body following type-specific rules.
124185125125-Default assumption: the agent is already competent. Only add context it does not already have.
186186+**Constraints (all types):**
126187127127-- Be specific and actionable. Not _"handle errors appropriately"_ but _"return errors with context using fmt.Errorf"_
128128-- Use examples (input/output pairs) to show expected behavior
129129-- Use RFC 2119 keywords (MUST, SHOULD, MAY) for all constraints
130130-- Negative constraints (MUST NOT, SHOULD NOT) MUST include a reason explaining why
131131-- Use consistent terminology — pick one term and use it throughout
132132-- MUST NOT include time-sensitive information (version numbers, release dates), because skills are not updated on a schedule
188188+- Default assumption: the agent is already competent. Only add context it lacks.
189189+- MUST use RFC 2119 keywords (MUST, SHOULD, MAY) for all constraints
190190+- Negative constraints (MUST NOT, SHOULD NOT) MUST include a reason
191191+- MUST NOT include time-sensitive information (version numbers, release dates)
192192+- Use consistent terminology — pick one term, use it throughout
193193+- Keep SKILL.md under 500 lines — move excess to `references/`
194194+- Reference files over 100 lines SHOULD include a table of contents
195195+196196+**Constraints (SOP type):**
197197+198198+- Each step MUST have a clear objective the agent can execute
199199+- Steps with constraints MUST use a `**Constraints:**` subsection
200200+- MUST include validation gates: points where the agent waits for user confirmation
201201+- MUST sequence steps so each builds on the previous
202202+- MUST NOT include steps that are purely informational with no action
203203+- Each step SHOULD produce visible output (file created, question asked, etc.)
204204+- Parameters MUST declare: required vs optional, default values, acquisition method
133205134134-### Degree of Freedom
206206+**Constraints (Reference type):**
135207136136-Match instruction specificity to task fragility:
208208+- Each principle MUST have a concrete Bad/Good pair
209209+- Examples MUST use real code, not pseudocode, unless language-agnostic
210210+- Principles SHOULD be ordered by importance or frequency of violation
211211+- MUST NOT list principles without examples
137212138138-- **High freedom** (prose instructions): when multiple valid approaches exist. _"SHOULD use guard clauses for early returns."_
139139-- **Low freedom** (exact commands/scripts): when operations are fragile or destructive. _"MUST run `pg_dump` before applying migration."_
213213+**Degree of freedom:**
140214141141-For critical validations, prefer bundled scripts over prose instructions, because code is deterministic and prose is interpreted.
215215+Match specificity to fragility:
142216143143-## 6. Content Patterns
217217+- **High freedom** (prose): when multiple valid approaches exist
218218+- **Low freedom** (exact commands/scripts): when operations are fragile or destructive
219219+- For critical validations, prefer bundled scripts over prose (code is deterministic)
144220145145-### Template Pattern
221221+### 5. Write Examples
146222147147-Provide output format templates. Mark required vs. optional sections.
223223+Create at least one end-to-end example.
148224149149-```markdown
150150-## Summary
225225+**Constraints:**
151226152152-[required — 1-2 sentences]
227227+- MUST include at least one complete example showing the full workflow
228228+- Examples MUST use realistic complexity, not trivial cases
229229+- MUST show what the agent produces, not just describe it
230230+- SOP examples SHOULD show: trigger → parameter gathering → step execution → final output
231231+- Reference examples SHOULD show: before/after transformation guided by the principles
153232154154-## Details
233233+**BAD example:**
155234156156-[optional — supporting context]
235235+```
236236+Input: Create a skill
237237+Output: Skill created successfully
157238```
158239159159-### Workflow Pattern
240240+→ Trivial. Teaches nothing about the interaction pattern.
160241161161-Sequential steps with validation gates.
242242+**GOOD example:**
162243163244```
164164-1. Run linter → MUST pass before proceeding
165165-2. Run tests → fix failures, repeat step 1
166166-3. Generate docs → review output
245245+Input: I want a skill that walks me through writing Postgres migrations safely
246246+247247+[Agent gathers parameters: name, target_dir]
248248+[Agent drafts description, presents for review]
249249+[Agent creates structure, shows planned files]
250250+[Agent writes Steps with Constraints subsections]
251251+[Agent validates against checklist]
252252+Output: my-skill/SKILL.md created with 4 steps, 2 examples, passes validation
167253```
168254169169-### Feedback Loop Pattern
255255+→ Shows the full interaction arc.
170256171171-```
172172-1. Run validator: `./scripts/validate.sh`
173173-2. If errors, fix and go to step 1
174174-3. If clean, proceed
175175-```
257257+### 6. Validate
176258177177-### Conditional Workflow
259259+Run the checklist and iterate.
178260179179-Decision trees for different paths:
261261+**Constraints:**
262262+263263+- MUST validate against the checklist in the Reference section below
264264+- MUST test trigger accuracy: ask "When would you use the [skill name] skill?"
265265+- MUST verify the skill does NOT trigger on unrelated tasks
266266+- MUST present findings to user with specific issues and suggested fixes
267267+- MUST NOT consider the skill complete until all checklist items pass
180268181181-```
182182-If new table → use CREATE TABLE template
183183-If adding column → use ALTER TABLE template with NOT NULL + default
184184-If dropping column → require migration plan review first
269269+## Reference: Frontmatter Spec
270270+271271+```yaml
272272+---
273273+name: my-skill # required
274274+description: ... # required
275275+license: MIT # optional
276276+compatibility: ... # optional
277277+metadata: # optional
278278+ author: jane
279279+ version: "1.0"
280280+allowed-tools: Bash Read # optional, space-delimited
281281+---
185282```
186283187187-### Examples Pattern
284284+| Field | Constraints |
285285+|-------|------------|
286286+| `name` | 1-64 chars. Lowercase alphanumeric + hyphens. No leading/trailing/consecutive hyphens. MUST match folder name. |
287287+| `description` | 1-1024 chars. No XML angle brackets. See Step 2. |
288288+| `license` | Short identifier (MIT, Apache-2.0). |
289289+| `compatibility` | 1-500 chars. Environment requirements. |
290290+| `metadata` | Key-value string map. |
291291+| `allowed-tools` | Space-delimited tool names. |
188292189189-Input/output pairs showing expected behavior:
293293+**Security:** `name` MUST NOT contain "claude" or "anthropic" (reserved). MUST NOT use XML angle brackets in any frontmatter value, because frontmatter is injected into XML-structured system prompts and unescaped brackets break parsing.
190294191191-```
192192-Input: createUser("jane", "admin")
193193-Output: { id: 1, name: "jane", role: "admin", createdAt: "..." }
194194-```
295295+## Reference: Progressive Disclosure
195296196196-## 7. Agents
297297+Skills load in three levels to minimize context cost:
197298198198-Agents are standalone `.md` files. The filename determines the agent name (`orchestrator.md` → `orchestrator`).
299299+| Level | What loads | When | Budget |
300300+|-------|-----------|------|--------|
301301+| 1. Frontmatter | `name` + `description` | Always | ~100 tokens |
302302+| 2. SKILL.md body | Core instructions | Agent triggers | Under 500 lines |
303303+| 3. Linked files | references/, scripts/, assets/ | Agent reads explicitly | No cost until accessed |
304304+305305+- Move material over 500 lines to `references/`
306306+- Keep references one level deep — agents may skip deeply nested trees
307307+- Reference files over 100 lines SHOULD include a table of contents
308308+309309+## Reference: Agent Authoring
199310200200-### Location
311311+Agents are standalone `.md` files. Filename determines agent name.
312312+313313+**Location:**
201314202315- Global: `~/dotfiles/modules/opencode/agents/<name>.md`
203316- Project: `.opencode/agents/<name>.md`
204317205205-### Frontmatter
318318+**Frontmatter:**
206319207320```yaml
208321---
···213326 bash:
214327 "*": ask
215328 "git *": allow
216216- "npm test": allow
217329 skill:
218330 "*": allow
219331 task:
···221333---
222334```
223335224224-| Field | Required | Notes |
225225-| ------------- | -------- | --------------------------------------------------------------- |
226226-| `description` | Yes | Same rules as skill descriptions (§3). |
227227-| `mode` | No | `primary` (top-level) or `subagent` (delegated to). |
228228-| `permission` | No | Tool permission overrides. Pattern-matched, most specific wins. |
336336+| Field | Required | Notes |
337337+|-------|----------|-------|
338338+| `description` | Yes | Same rules as skill descriptions (Step 2). |
339339+| `mode` | No | `primary` or `subagent`. |
340340+| `permission` | No | Pattern-matched, most specific wins. |
229341230230-### Content
342342+**Body:** role, protocol, constraints. Keep under 100 lines.
343343+344344+**BAD:**
345345+346346+```markdown
347347+You are a helpful assistant that does code review.
348348+```
349349+350350+→ No protocol, no constraints.
231351232232-Agent body defines role, protocol, and constraints. Keep under 100 lines.
352352+**GOOD:**
233353234354```markdown
235235-You are the **Code Reviewer**. You review pull requests for correctness and style.
355355+You are the **Code Reviewer**. You review PRs for correctness and style.
236356237357## Protocol
238358239239-1. Read the diff
240240-2. Check against project conventions
359359+1. Read the full diff
360360+2. Check against project conventions (read 3 nearby files)
2413613. Report issues with file:line references
242362243363## Constraints
···246366- MUST NOT approve without reading every changed file
247367```
248368249249-## 8. Testing
250250-251251-### Trigger Testing
252252-253253-- Does the skill trigger on direct requests? (_"Create a new skill for..."_)
254254-- Does it trigger on paraphrased requests? (_"I need to set up an agent"_)
255255-- Does it stay silent on unrelated tasks? (_"Fix this CSS bug"_)
256256-257257-### Functional Testing
258258-259259-- Does it produce correct output for typical inputs?
260260-- Does error handling work (missing fields, invalid names)?
261261-- Are edge cases covered (empty descriptions, long names)?
262262-263263-### Iteration
264264-265265-| Problem | Fix |
266266-| ---------------- | ---------------------------------------------------- |
267267-| Under-triggering | Add more keywords and trigger phrases to description |
268268-| Over-triggering | Be more specific, add negative triggers |
269269-| Wrong output | Add examples, tighten constraints |
270270-271271-Debug with: _"When would you use the [skill name] skill?"_
272272-273273-## 9. Validation Checklist
369369+## Reference: Validation Checklist
274370275371### Skills
276372277277-- [ ] File is named `SKILL.md` (case-sensitive)
373373+- [ ] File named `SKILL.md` (case-sensitive)
278374- [ ] Folder uses kebab-case
279375- [ ] Frontmatter has `name` and `description`
280280-- [ ] `name` matches folder name exactly
376376+- [ ] `name` matches folder name
281377- [ ] `name` does not contain "claude" or "anthropic"
282282-- [ ] Description is 1-1024 characters
283283-- [ ] Description includes what, when, and trigger keywords
284284-- [ ] Description written in third person
378378+- [ ] Description: 1-1024 chars, third person, what + when + keywords
285379- [ ] No XML angle brackets in frontmatter
286380- [ ] No README.md in skill folder
287381- [ ] Body under 500 lines
288288-- [ ] All constraints use RFC 2119 language
289289-- [ ] Negative constraints include a reason
382382+- [ ] All constraints use RFC 2119
383383+- [ ] Negative constraints include reasons
384384+- [ ] **SOP**: has Parameters, Steps with Constraints, Examples
385385+- [ ] **SOP**: steps have validation gates
386386+- [ ] **Reference**: each principle has Bad/Good pair
387387+- [ ] At least one complete example
290388291389### Agents
292390293391- [ ] File uses `.md` extension
294392- [ ] Frontmatter has `description`
295295-- [ ] Description is 1-1024 characters
296296-- [ ] No XML angle brackets in frontmatter
393393+- [ ] Description: 1-1024 chars
394394+- [ ] No XML angle brackets
297395- [ ] Body under 100 lines
396396+- [ ] Has Protocol and Constraints sections
298397- [ ] `mode` is `primary` or `subagent` (if specified)
299299-- [ ] Permission patterns are valid
300398301301-## 10. Anti-patterns
399399+## Troubleshooting
302400303303-- **Vague descriptions** — _"Helps with projects"_ tells the agent nothing
304304-- **Missing trigger phrases** — skill exists but never fires
305305-- **Deeply nested references** — agents lose track past one level of nesting
306306-- **Too many options without a default** — _"you could use A, B, or C"_ without guidance on which to pick
307307-- **Time-sensitive content** — version numbers and dates go stale silently
308308-- **Inconsistent terminology** — using "skill", "plugin", and "extension" interchangeably
309309-- **Backslash paths** — use forward slashes; backslashes break on Unix systems
401401+### Skill doesn't trigger
402402+403403+- Missing trigger phrases — add the exact words users would say
404404+- Competing skill with overlapping description — narrow yours
405405+- XML brackets in frontmatter breaking parsing — remove them
406406+- Debug: ask the agent "When would you use the [skill name] skill?"
407407+408408+### Skill triggers too broadly
409409+410410+- Add negative triggers: "Do NOT use for X — use Y instead"
411411+- Narrow the description to specific scope
412412+- Remove generic keywords matching unrelated tasks
413413+414414+### Agent produces wrong output
415415+416416+- Add concrete input/output examples
417417+- Tighten constraints with RFC 2119 language
418418+- Check if wrong skill type (SOP vs reference)
419419+420420+### Skill over 500 lines
421421+422422+- Move lookup tables, API specs, long examples to `references/`
423423+- Remove content restating what competent agents already know
424424+- Consolidate overlapping sections
425425+426426+### Examples feel trivial
427427+428428+- Use realistic complexity, not "hello world"
429429+- Show edge cases, not just happy paths
430430+- Include the interaction pattern, not just input/output blobs