|
| 1 | +--- |
| 2 | +title: "Skill Authoring Best Practices" |
| 3 | +description: Core principles, common patterns, quality dimensions, and anti-patterns for writing effective BMad skills |
| 4 | +--- |
| 5 | + |
| 6 | +Practical guidance for writing skills that work reliably and adapt gracefully. These patterns apply to agents, workflows, and utilities alike. |
| 7 | + |
| 8 | +## Core Principle: Informed Autonomy |
| 9 | + |
| 10 | +Give the executing agent enough context to make good judgment calls — not just enough to follow steps. The test for every piece of content: "Would the agent make *better decisions* with this context?" If yes, keep it. If it is genuinely redundant, cut it. |
| 11 | + |
| 12 | +Simple utilities need minimal context — input/output is self-explanatory. Interactive workflows need domain understanding, user perspective, and rationale for non-obvious choices. When in doubt, explain *why* — an agent that understands the mission improvises better than one following blind steps. |
| 13 | + |
| 14 | +## Freedom Levels |
| 15 | + |
| 16 | +Match specificity to task fragility. |
| 17 | + |
| 18 | +| Freedom | When to Use | Example | |
| 19 | +| ------- | ----------- | ------- | |
| 20 | +| **High** (text instructions) | Multiple valid approaches, context-dependent | "Analyze structure, check for issues, suggest improvements" | |
| 21 | +| **Medium** (pseudocode/templates) | Preferred pattern exists, some variation OK | `def generate_report(data, format="markdown"):` | |
| 22 | +| **Low** (exact scripts) | Fragile operations, consistency critical | `python scripts/migrate.py --verify --backup` (do not modify) | |
| 23 | + |
| 24 | +**Analogy:** Narrow bridge with cliffs = low freedom. Open field = high freedom. |
| 25 | + |
| 26 | +## Quality Dimensions |
| 27 | + |
| 28 | +Six dimensions to keep in mind during the build phase. The quality scanners check these automatically during optimization. |
| 29 | + |
| 30 | +| Dimension | What It Means | |
| 31 | +| --------- | ------------- | |
| 32 | +| **Informed Autonomy** | Overview establishes domain framing, theory of mind, and design rationale — enough for judgment calls | |
| 33 | +| **Intelligence Placement** | Scripts handle plumbing (fetch, transform, validate). Prompts handle judgment (interpret, classify, decide). If a script contains an `if` that decides what content *means*, intelligence has leaked | |
| 34 | +| **Progressive Disclosure** | SKILL.md stays focused; stage instructions go in `prompts/`, reference data in `resources/` | |
| 35 | +| **Description Format** | Two parts: `[5-8 word summary]. [Use when user says 'X' or 'Y'.]` — default to conservative triggering | |
| 36 | +| **Path Construction** | Never use `{skill-root}`. Only use `{project-root}` for `_bmad` paths. Config variables used directly — they already contain `{project-root}` | |
| 37 | +| **Token Efficiency** | Remove genuine waste (repetition, defensive padding). Preserve context that enables judgment (domain framing, rationale) | |
| 38 | + |
| 39 | +## Common Patterns |
| 40 | + |
| 41 | +### Soft Gate Elicitation |
| 42 | + |
| 43 | +For guided workflows, use "anything else?" soft gates at natural transition points instead of hard menus. |
| 44 | + |
| 45 | +```markdown |
| 46 | +Present what you've captured so far, then: |
| 47 | +"Anything else you'd like to add, or shall we move on?" |
| 48 | +``` |
| 49 | + |
| 50 | +Users almost always remember one more thing when given a graceful exit ramp rather than a hard stop. This consistently produces richer artifacts than rigid section-by-section questioning. Use at every natural transition in collaborative discovery workflows. Skip in autonomous/headless execution. |
| 51 | + |
| 52 | +### Intent-Before-Ingestion |
| 53 | + |
| 54 | +Never scan artifacts or project context until you understand WHY the user is here. Without knowing intent, you cannot judge what is relevant in a 100-page document. |
| 55 | + |
| 56 | +```markdown |
| 57 | +1. Greet and understand intent |
| 58 | +2. Accept whatever inputs the user offers |
| 59 | +3. Ask if they have additional context |
| 60 | +4. ONLY THEN scan artifacts, scoped to relevance |
| 61 | +``` |
| 62 | + |
| 63 | +### Capture-Don't-Interrupt |
| 64 | + |
| 65 | +When users provide information beyond the current scope — dropping requirements during a product brief, mentioning platforms during vision discovery — capture it silently for later use rather than redirecting them. |
| 66 | + |
| 67 | +Users in creative flow share their best insights unprompted. Interrupting to say "we'll cover that later" kills momentum and may lose the insight entirely. |
| 68 | + |
| 69 | +### Dual-Output: Human Artifact + LLM Distillate |
| 70 | + |
| 71 | +Any artifact-producing workflow can output two complementary documents: a polished human-facing artifact AND a token-conscious, structured distillate optimized for downstream LLM consumption. |
| 72 | + |
| 73 | +| Output | Purpose | |
| 74 | +| ------ | ------- | |
| 75 | +| **Primary** | Human-facing document — concise, well-structured | |
| 76 | +| **Distillate** | Dense, structured summary for downstream LLM workflows — captures overflow, rejected ideas (so downstream does not re-propose them), detail bullets with enough context to stand alone | |
| 77 | + |
| 78 | +The distillate bridges the gap between what belongs in the human document and what downstream workflows need. Always offered to the user, never forced. |
| 79 | + |
| 80 | +### Three-Mode Architecture |
| 81 | + |
| 82 | +Interactive workflows can offer three execution modes matching different user contexts. |
| 83 | + |
| 84 | +| Mode | Trigger | Behavior | |
| 85 | +| ---- | ------- | -------- | |
| 86 | +| **Guided** | Default | Section-by-section with soft gates; drafts from what it knows, questions what it doesn't | |
| 87 | +| **YOLO** | `--yolo` or "just draft it" | Ingests everything, drafts complete artifact upfront, then walks user through refinement | |
| 88 | +| **Autonomous** | `--autonomous` / `-A` | Headless; takes inputs, produces artifact, no interaction | |
| 89 | + |
| 90 | +Not every workflow needs all three — but considering them during design prevents painting yourself into a single interaction model. |
| 91 | + |
| 92 | +### Parallel Review Lenses |
| 93 | + |
| 94 | +Before finalizing any significant artifact, fan out multiple reviewers with different perspectives. |
| 95 | + |
| 96 | +| Reviewer | Focus | |
| 97 | +| -------- | ----- | |
| 98 | +| **Skeptic** | What is missing? What assumptions are untested? | |
| 99 | +| **Opportunity Spotter** | What adjacent value? What angles? | |
| 100 | +| **Contextual** | LLM picks the best third lens for the domain (regulatory risk for healthtech, DX critic for devtools) | |
| 101 | + |
| 102 | +Graceful degradation: if subagents are unavailable, the main agent does a single critical self-review pass. |
| 103 | + |
| 104 | +### Graceful Degradation |
| 105 | + |
| 106 | +Every subagent-dependent feature should have a fallback path. Skills run across different platforms, models, and configurations. A skill that hard-fails without subagents is fragile. A skill that gracefully falls back to sequential processing is robust everywhere. |
| 107 | + |
| 108 | +### Verifiable Intermediate Outputs |
| 109 | + |
| 110 | +For complex tasks: plan, validate, execute, verify. |
| 111 | + |
| 112 | +1. Analyze inputs |
| 113 | +2. Create `changes.json` with planned updates |
| 114 | +3. Validate with script before executing |
| 115 | +4. Execute changes |
| 116 | +5. Verify output |
| 117 | + |
| 118 | +Catches errors early, is machine-verifiable, and makes planning reversible. |
| 119 | + |
| 120 | +## Writing Guidelines |
| 121 | + |
| 122 | +| Do | Avoid | |
| 123 | +| -- | ----- | |
| 124 | +| Consistent terminology — one term per concept | Switching between "workflow" and "process" for the same thing | |
| 125 | +| Third person in descriptions — "Processes files" | First person — "I help process files" | |
| 126 | +| Descriptive file names — `form_validation_rules.md` | Sequence names — `doc2.md` | |
| 127 | +| Forward slashes in all paths | Backslashes or platform-specific paths | |
| 128 | +| One level deep for references — SKILL.md → resource.md | Nested references — SKILL.md → A.md → B.md | |
| 129 | +| Table of contents for files over 100 lines | Long files without navigation | |
| 130 | + |
| 131 | +## Anti-Patterns |
| 132 | + |
| 133 | +| Anti-Pattern | Fix | |
| 134 | +| ------------ | --- | |
| 135 | +| Too many options upfront | One default with escape hatch for edge cases | |
| 136 | +| Deep reference nesting (A→B→C) | Keep references one level from SKILL.md | |
| 137 | +| Inconsistent terminology | Choose one term per concept | |
| 138 | +| Vague file names | Name by content, not sequence | |
| 139 | +| Scripts that classify meaning via regex | Intelligence belongs in prompts, not scripts | |
| 140 | +| Over-optimization that flattens personality | Preserve phrasing that captures the intended voice | |
| 141 | +| Hard-failing when subagents are unavailable | Always include a sequential fallback path | |
0 commit comments