@runecraft/grimoire 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -0
  3. package/catalog.json +9 -0
  4. package/dist/grimoire.js +1758 -0
  5. package/package.json +54 -0
  6. package/references/definition-of-done.md +67 -0
  7. package/references/testing-patterns.md +260 -0
  8. package/skills/code-review-and-quality/README.md +13 -0
  9. package/skills/code-review-and-quality/SKILL.md +389 -0
  10. package/skills/code-simplification/README.md +13 -0
  11. package/skills/code-simplification/SKILL.md +338 -0
  12. package/skills/debugging-and-error-recovery/README.md +13 -0
  13. package/skills/debugging-and-error-recovery/SKILL.md +343 -0
  14. package/skills/debugging-and-error-recovery/scripts/__pycache__/triage_state.cpython-314.pyc +0 -0
  15. package/skills/debugging-and-error-recovery/scripts/triage_state.py +206 -0
  16. package/skills/deprecation-and-migration/README.md +13 -0
  17. package/skills/deprecation-and-migration/SKILL.md +248 -0
  18. package/skills/deprecation-and-migration/scripts/__pycache__/migration_tracker.cpython-314.pyc +0 -0
  19. package/skills/deprecation-and-migration/scripts/migration_tracker.py +237 -0
  20. package/skills/doubt-driven-development/README.md +13 -0
  21. package/skills/doubt-driven-development/SKILL.md +251 -0
  22. package/skills/git-commit-learning/.skill-meta.json +14 -0
  23. package/skills/git-commit-learning/README.md +205 -0
  24. package/skills/git-commit-learning/SKILL.md +435 -0
  25. package/skills/git-commit-learning/references/commit-patterns.md +595 -0
  26. package/skills/git-worktree/README.md +13 -0
  27. package/skills/git-worktree/SKILL.md +220 -0
  28. package/skills/idea-refine/README.md +13 -0
  29. package/skills/idea-refine/SKILL.md +186 -0
  30. package/skills/interview-me/README.md +13 -0
  31. package/skills/interview-me/SKILL.md +233 -0
  32. package/skills/linkedin-audit/SKILL.md +98 -0
  33. package/skills/linkedin-audit/references/dashboard-spec.md +43 -0
  34. package/skills/memory-management/README.md +13 -0
  35. package/skills/memory-management/SKILL.md +198 -0
  36. package/skills/security-and-hardening/README.md +13 -0
  37. package/skills/security-and-hardening/SKILL.md +472 -0
  38. package/skills/shipping-and-launch/README.md +13 -0
  39. package/skills/shipping-and-launch/SKILL.md +317 -0
  40. package/skills/skill-forge/README.md +153 -0
  41. package/skills/skill-forge/SKILL.md +291 -0
  42. package/skills/skill-forge/assets/SKILL.template.md +73 -0
  43. package/skills/skill-forge/references/authoring-patterns.md +249 -0
  44. package/skills/skill-forge/references/description-optimization.md +171 -0
  45. package/skills/skill-forge/references/output-evaluation.md +276 -0
  46. package/skills/skill-forge/references/scripts-guide.md +232 -0
  47. package/skills/skill-forge/references/spec.md +175 -0
  48. package/skills/skill-forge/scripts/validate.py +536 -0
  49. package/skills/spec-driven/.skill-meta.json +14 -0
  50. package/skills/spec-driven/README.md +335 -0
  51. package/skills/spec-driven/SKILL.md +174 -0
  52. package/skills/spec-driven/references/code-analysis.md +98 -0
  53. package/skills/spec-driven/references/coding-principles.md +56 -0
  54. package/skills/spec-driven/references/context-limits.md +31 -0
  55. package/skills/spec-driven/references/design.md +199 -0
  56. package/skills/spec-driven/references/discuss.md +136 -0
  57. package/skills/spec-driven/references/implement.md +425 -0
  58. package/skills/spec-driven/references/lessons.md +113 -0
  59. package/skills/spec-driven/references/memory.md +126 -0
  60. package/skills/spec-driven/references/specify.md +210 -0
  61. package/skills/spec-driven/references/sub-agents.md +96 -0
  62. package/skills/spec-driven/references/tasks.md +484 -0
  63. package/skills/spec-driven/references/validate.md +350 -0
  64. package/skills/spec-driven/scripts/__pycache__/lessons.cpython-314.pyc +0 -0
  65. package/skills/spec-driven/scripts/lessons.py +370 -0
  66. package/skills/spec-loop/README.md +36 -0
  67. package/skills/spec-loop/SKILL.md +61 -0
  68. package/skills/test-driven-development/README.md +13 -0
  69. package/skills/test-driven-development/SKILL.md +388 -0
  70. package/skills/typescript-patterns/README.md +13 -0
  71. package/skills/typescript-patterns/SKILL.md +346 -0
  72. package/skills/using-agent-skills/README.md +13 -0
  73. package/skills/using-agent-skills/SKILL.md +187 -0
@@ -0,0 +1,291 @@
1
+ ---
2
+ name: skill-forge
3
+ description: >
4
+ Designs, authors, validates, and optimizes new Agent Skills from scratch. Use when creating
5
+ a new skill, packaging a workflow as a skill, improving a skill's triggering accuracy, or
6
+ evaluating whether a skill improves output quality. Covers the full lifecycle: DISCOVER,
7
+ DESIGN, AUTHOR, VALIDATE, OPTIMIZE, DELIVER. Produces skills that follow the open
8
+ SKILL.md format (YAML frontmatter + Markdown body, progressive disclosure, validation loops).
9
+ EN triggers: /forge, create a skill, write a skill, build a skill, new skill, author a skill,
10
+ package this as a skill, validate a skill, improve skill triggering, optimize skill description,
11
+ evaluate skill quality.
12
+ PT triggers: /forge, criar uma skill, escrever uma skill, construir uma skill, nova skill,
13
+ empacotar como skill, validar skill, melhorar disparo, otimizar descrição de skill.
14
+ Do NOT use for: discovering which existing skill to apply (use a dispatch/meta skill),
15
+ planning feature implementation, or designing software architecture.
16
+ license: CC-BY-4.0
17
+ metadata:
18
+ version: 1.0.0
19
+ ---
20
+
21
+ # skill-forge
22
+
23
+ > Meta-skill for creating new Agent Skills from scratch. Produces publishable, validated, trigger-tested skills that compose with the rest of the catalog.
24
+
25
+ ```
26
+ DISCOVER → DESIGN → AUTHOR → VALIDATE → OPTIMIZE → DELIVER
27
+ ```
28
+
29
+ Each phase has explicit exit criteria. Move sequentially. Do not skip to AUTHOR before completing DISCOVER and DESIGN — bad frontmatter is the most common reason skills misfire.
30
+
31
+ ## Critical rules (read before acting)
32
+
33
+ - **The open SKILL.md format is the source of truth.** This skill encodes the format rules (frontmatter schema, naming, progressive disclosure, folder layout). When in doubt, follow what this skill's own validator enforces — it is the single reference implementation.
34
+ - **The description field controls triggering.** It is the only thing the agent sees at startup. Write it last but treat it as the most important field. If triggering is wrong, nothing else matters.
35
+ - **Skills are for agents, not humans.** The `SKILL.md` body is agent instructions. Human-facing docs (README, changelogs) belong outside the skill folder.
36
+ - **Never fabricate domain knowledge.** Build skills from real expertise — your own run history, internal docs, runbooks, schemas, code review comments. Generic "best practices" skills have no edge.
37
+
38
+ ---
39
+
40
+ ## Phase 1: DISCOVER
41
+
42
+ **Goal:** Build a precise mental model of the skill before writing a single line.
43
+
44
+ Ask one cluster at a time (don't dump). Capture answers in your working memory; you'll reuse them in DESIGN.
45
+
46
+ ### 1.1 What workflow are we packaging?
47
+
48
+ - What does the user do today, step by step?
49
+ - Where does it go wrong without the skill (inconsistency, forgotten steps, wasted re-explaining)?
50
+ - What is the "good output" they expect (specific, observable)?
51
+
52
+ ### 1.2 Use cases
53
+
54
+ Nail down 2-3 concrete ones:
55
+
56
+ ```
57
+ Use Case: [Name]
58
+ Trigger phrase: "user would say…"
59
+ Steps: 1. … 2. … 3. …
60
+ Tools: built-in or MCP
61
+ Success: [specific output or state]
62
+ ```
63
+
64
+ If vague, offer examples to react to. Concrete > abstract.
65
+
66
+ ### 1.3 Category
67
+
68
+ | Category | When to choose |
69
+ |---|---|
70
+ | Document & Asset Creation | Consistent output generation (reports, slides, code, diagrams) |
71
+ | Workflow Automation | Multi-step processes with methodology (planning, onboarding, deploys) |
72
+ | MCP Enhancement | Workflow guidance on top of MCP tool access |
73
+ | Domain Intelligence | Specialized knowledge (compliance, finance rules, security checks) |
74
+
75
+ ### 1.4 Out of scope (explicit)
76
+
77
+ List adjacent things this skill must NOT do. Add them to the `Do NOT use for…` clause of the description.
78
+
79
+ **Exit:** 2-3 use cases, category, out-of-scope list.
80
+
81
+ ---
82
+
83
+ ## Phase 2: DESIGN
84
+
85
+ **Goal:** Structural decisions before any writing.
86
+
87
+ ### 2.1 Pick a pattern
88
+
89
+ | Pattern | When |
90
+ |---|---|
91
+ | Sequential Workflow | Steps have dependencies, ordering is load-bearing |
92
+ | Multi-MCP Coordination | Spans multiple external services |
93
+ | Iterative Refinement | Quality improves through review-fix cycles |
94
+ | Context-Aware Selection | Best tool depends on input properties |
95
+ | Domain-Specific Intelligence | Expert rules drive correct execution |
96
+
97
+ Most skills combine. Identify the **primary** pattern.
98
+
99
+ ### 2.2 Folder layout
100
+
101
+ ```
102
+ skill-name/
103
+ ├── SKILL.md # Required. Target <500 lines, <5000 tokens.
104
+ ├── scripts/ # Only if deterministic checks needed
105
+ ├── references/ # Only if deep content >100 lines
106
+ ├── assets/ # Only if templates/static resources are used in output
107
+ └── evals/ # Optional, for output-quality evaluation
108
+ └── evals.json
109
+ ```
110
+
111
+ Decision rules:
112
+ - Logic that must be deterministic → `scripts/`
113
+ - Reference content >100 lines → `references/`
114
+ - Templates/images reused in output → `assets/`
115
+ - Everything else → keep in SKILL.md
116
+
117
+ ### 2.3 Map progressive disclosure
118
+
119
+ | Level | What | Token budget |
120
+ |---|---|---|
121
+ | L1 Frontmatter | `name` + `description` | ~100 words |
122
+ | L2 SKILL.md body | Core workflow, steps, examples | <500 lines |
123
+ | L3 Linked files | Deep ref, API docs, large examples | As needed |
124
+
125
+ SKILL.md must tell the agent **when** to read each linked file. "Read `references/spec.md` if X" beats "see references/".
126
+
127
+ ### 2.4 Draft the description (placeholder, finalize in OPTIMIZE)
128
+
129
+ Format: `[What] + [Use when, with trigger phrases] + [Do NOT use for]`. ≤1024 chars total.
130
+
131
+ **Exit:** Pattern, folder layout, L1/L2/L3 map, description draft.
132
+
133
+ ---
134
+
135
+ ## Phase 3: AUTHOR
136
+
137
+ **Goal:** Write the skill with precision.
138
+
139
+ ### 3.1 Frontmatter hard rules
140
+
141
+ ```yaml
142
+ ---
143
+ name: kebab-case-name # Must match folder. 1-64 chars, [a-z0-9-], no leading/trailing/consecutive hyphens.
144
+ description: > # Folded multiline OK; ≤1024 chars; no XML angle brackets.
145
+ What it does. Use when [triggers]. Do NOT use for [exclusions].
146
+ license: CC-BY-4.0
147
+ metadata:
148
+ version: 1.0.0
149
+ author: your-name-or-org
150
+ ---
151
+ ```
152
+
153
+ Forbidden:
154
+ - Spaces or capitals in `name` or folder
155
+ - `claude` / `anthropic` reserved terms
156
+ - `SKILL.MD`, `Skill.md`, `skill.md` (must be exactly `SKILL.md`)
157
+ - XML angle brackets `<` `>` in description
158
+ - Description > 1024 characters
159
+
160
+ ### 3.2 Body writing principles
161
+
162
+ - Imperative form ("Run X", "Check Y"). Specific > verbose.
163
+ - Critical rules at the top, not buried in the middle.
164
+ - 2-3 concrete examples (input → actions → result).
165
+ - Reference files with explicit load conditions.
166
+ - For deterministic checks, prefer scripts over prose.
167
+ - Do not wrap prose at arbitrary column widths; let sentences flow.
168
+ - Code blocks may wrap for readability.
169
+
170
+ ### 3.3 Supporting files
171
+
172
+ For each `references/*.md` or `scripts/*`:
173
+ - Reference it from SKILL.md with a clear WHEN clause.
174
+ - For files >300 lines, add a Table of Contents.
175
+ - Scripts: see [scripts-guide](references/scripts-guide.md) for PEP 723, agentic design, --help, exit codes.
176
+
177
+ **Exit:** SKILL.md drafted, all hard rules satisfied, supporting files written.
178
+
179
+ ---
180
+
181
+ ## Phase 4: VALIDATE
182
+
183
+ **Goal:** Catch structural and spec errors before delivery.
184
+
185
+ ### 4.1 Run the bundled validator
186
+
187
+ ```bash
188
+ python3 scripts/validate.py <skill-folder>
189
+ # or, with PEP 723 inline dependencies via uv:
190
+ uv run --no-project scripts/validate.py <skill-folder>
191
+ ```
192
+
193
+ The validator checks: folder kebab-case, SKILL.md exists, frontmatter YAML valid, `name` rules, `description` rules, body line count, examples present, references linked, no XML in description.
194
+
195
+ Pass = exit code 0. Warnings are allowed. Errors are not.
196
+
197
+ ### 4.2 Spec re-check
198
+
199
+ Confirm against the full format spec (see [references/spec.md](references/spec.md)):
200
+ - `compatibility` field if the skill needs specific environment
201
+ - `allowed-tools` field if you want to pre-approve specific tools
202
+ - File references are relative to the skill root, one level deep preferred
203
+
204
+ ### 4.3 Trigger sanity
205
+
206
+ Mentally run 5-10 short prompts. Should trigger; should NOT trigger (near-misses). If the description is too narrow, broaden it; if too broad, add exclusions. Save these prompts — they seed the eval in OPTIMIZE.
207
+
208
+ For the full eval-driven optimization, proceed to OPTIMIZE.
209
+
210
+ **Exit:** Validator PASS + spec check + trigger sanity.
211
+
212
+ ---
213
+
214
+ ## Phase 5: OPTIMIZE
215
+
216
+ **Goal:** Make the skill trigger reliably and prove it improves output quality.
217
+
218
+ Two eval loops, run in this order:
219
+
220
+ ### 5.1 Description triggering eval
221
+
222
+ Open [description-optimization](references/description-optimization.md).
223
+
224
+ Write ~20 eval queries (8-10 should-trigger, 8-10 should-NOT-trigger), emphasizing near-misses. Split 60/40 into `train_queries.json` and `validation_queries.json`. Run the trigger script 3x per query. Iterate on the description (using only the train set) until stable. Select the best iteration by validation pass rate.
225
+
226
+ ### 5.2 Output-quality eval (optional, recommended for workflow skills)
227
+
228
+ Open [output-evaluation](references/output-evaluation.md).
229
+
230
+ Build `evals/evals.json` with 2-3 test cases. Run each twice (with-skill, without-skill) into `iteration-1/`. Add assertions, grade, aggregate to `benchmark.json`. Iterate the skill body based on failed assertions and human review. Stop when pass rate plateaus or feedback is empty.
231
+
232
+ **Exit:** Description eval pass rate ≥0.5 on validation set; output eval (if run) shows skill adds value.
233
+
234
+ ---
235
+
236
+ ## Phase 6: DELIVER
237
+
238
+ **Goal:** Install + register.
239
+
240
+ ### 6.1 Local install
241
+
242
+ Drop the skill into the right skills directory for the target agent:
243
+
244
+ | Agent | Path |
245
+ |---|---|
246
+ | VS Code + Copilot | `.agents/skills/` |
247
+ | Claude Code | `.claude/skills/` |
248
+ | Cursor | `.cursor/skills/` |
249
+ | OpenCode | `.opencode/skill/` |
250
+
251
+ Optionally add a slash command to the agent's command file (e.g. `/forge`) so the trigger works without typing a long phrase.
252
+
253
+ ### 6.2 For catalog publication
254
+
255
+ 1. Add a row to the catalog's index (package README) with version, description, main trigger, and link to the skill's README.
256
+ 2. Create a release note in whatever format the catalog uses (changeset, changelog entry, release tag, etc.).
257
+ 3. Bump the skill's own `metadata.version` to match the release.
258
+ 4. Publish through whatever distribution mechanism the catalog uses (npm package, git tag, registry upload).
259
+
260
+ ### 6.3 For distribution elsewhere
261
+
262
+ Keep the skill self-contained. Make sure the skill folder is at a path the target agent scans. Include a top-level human-facing README alongside the skill folder (not inside it).
263
+
264
+ **Exit:** Skill installed, registered, and a test prompt verifies triggering in the target agent.
265
+
266
+ ---
267
+
268
+ ## Bundled resources
269
+
270
+ - **[references/spec.md](references/spec.md)** — the open SKILL.md format reference.
271
+ - **[references/authoring-patterns.md](references/authoring-patterns.md)** — best practices: gotchas, templates, checklists, validation loops, plan-validate-execute, calibrating control.
272
+ - **[references/description-optimization.md](references/description-optimization.md)** — trigger eval methodology with train/val split.
273
+ - **[references/output-evaluation.md](references/output-evaluation.md)** — output-quality eval: with-skill vs without-skill, assertions, benchmark.
274
+ - **[references/scripts-guide.md](references/scripts-guide.md)** — using scripts in skills: PEP 723, agentic script design, --help, exit codes.
275
+ - **[scripts/validate.py](scripts/validate.py)** — stdlib-only validator; `--json-out` for agentic consumption.
276
+ - **[assets/SKILL.template.md](assets/SKILL.template.md)** — blank template for new skills.
277
+
278
+ ## Anti-patterns to avoid
279
+
280
+ - ❌ Vague description: "Helps with documents."
281
+ - ❌ Verbose body the agent will skim.
282
+ - ❌ No examples.
283
+ - ❌ Wrong `SKILL.md` casing.
284
+ - ❌ Spaces or capitals in folder or name.
285
+ - ❌ `claude` or `anthropic` in the name.
286
+ - ❌ XML angle brackets in description.
287
+ - ❌ SKILL.md > 500 lines (move detail to references/).
288
+ - ❌ Description > 1024 chars.
289
+ - ❌ Claiming to be the only skill loaded (skills compose).
290
+ - ❌ Re-explaining what the agent already knows (PDFs, HTTP, etc.).
291
+ - ❌ Referencing internal projects, packages, or repos by name in the skill body.
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: <skill-name>
3
+ description: >
4
+ <What it does — one short sentence>. Use when <trigger conditions, including
5
+ EN and PT trigger phrases if your audience is bilingual>. Do NOT use for
6
+ <explicit exclusions to prevent misfiring>.
7
+ license: CC-BY-4.0
8
+ metadata:
9
+ author: <your-name-or-org>
10
+ version: 0.1.0
11
+ ---
12
+
13
+ # <Skill Name>
14
+
15
+ > One-line tagline that captures the value proposition.
16
+
17
+ ## Overview
18
+
19
+ [2-3 sentences. What this skill does, who it is for, and what kind of output
20
+ the user can expect.]
21
+
22
+ ## When to use
23
+
24
+ - Trigger situation 1
25
+ - Trigger situation 2
26
+ - Trigger situation 3
27
+
28
+ **When NOT to use:**
29
+
30
+ - Adjacent task better served by another skill
31
+ - One-off tweak that doesn't need a workflow
32
+ - Task the agent already handles well without this skill
33
+
34
+ ## Workflow
35
+
36
+ ### Step 1: <Action>
37
+
38
+ [Specific, imperative instructions.]
39
+
40
+ Expected output: [what success looks like]
41
+
42
+ ### Step 2: <Action>
43
+
44
+ [Specific, imperative instructions.]
45
+
46
+ ### Step 3: <Action>
47
+
48
+ [Specific, imperative instructions.]
49
+
50
+ ## Examples
51
+
52
+ ### Example 1: <Common scenario>
53
+
54
+ User says: "..."
55
+
56
+ Steps:
57
+ 1. ...
58
+ 2. ...
59
+
60
+ Result: [specific output]
61
+
62
+ ## Gotchas
63
+
64
+ - Environment-specific fact that defies assumptions
65
+ - Project convention the agent won't know
66
+ - API/library quirk to watch for
67
+
68
+ ## References
69
+
70
+ Load these only when the relevant step is reached:
71
+
72
+ - [references/spec.md](references/spec.md) — domain spec
73
+ - [references/api.md](references/api.md) — API reference (load when step 2 fails)
@@ -0,0 +1,249 @@
1
+ # Authoring Patterns
2
+
3
+ > Best practices for writing skill bodies. Read this when drafting a new skill and deciding between flexible guidance and prescriptive steps.
4
+
5
+ ## Start from real expertise
6
+
7
+ A common pitfall: asking an LLM to generate a skill without providing domain-specific context. The result is vague, generic procedures ("handle errors appropriately", "follow best practices for authentication") rather than the specific API patterns, edge cases, and project conventions that make a skill valuable.
8
+
9
+ Effective skills are grounded in real expertise. Two ways to feed it in:
10
+
11
+ **Extract from a hands-on task.** Do the real work in a session with the agent, providing context, corrections, and preferences. Then extract the reusable pattern. Capture:
12
+
13
+ - Steps that worked (the successful sequence)
14
+ - Corrections you made ("use library X instead of Y", "check for edge case Z")
15
+ - Input/output formats (what data went in, what came out)
16
+ - Context you provided (project facts, conventions, constraints)
17
+
18
+ **Synthesize from existing project artifacts.** Feed the LLM the actual material, not generic articles. A data-pipeline skill built from your team's incident reports and runbooks will outperform one built from "data engineering best practices" because it captures your schemas, failure modes, and recovery procedures. Good sources:
19
+
20
+ - Internal documentation, runbooks, style guides
21
+ - API specifications, schemas, configuration files
22
+ - Code review comments and issue trackers
23
+ - Version control history, especially patches and fixes
24
+ - Real-world failure cases and their resolutions
25
+
26
+ ## Refine with real execution
27
+
28
+ The first draft usually needs refinement. Run the skill against real tasks, then feed all results — not just failures — back into the creation process. Ask: what triggered false positives? What was missed? What could be cut?
29
+
30
+ Read execution traces, not just final outputs. Common causes of wasted steps:
31
+
32
+ - Instructions too vague (agent tries several approaches before finding one)
33
+ - Instructions that don't apply to the current task (agent follows them anyway)
34
+ - Too many options without a clear default
35
+
36
+ Even a single pass of execute-then-revise noticeably improves quality. Complex domains often benefit from several.
37
+
38
+ ## Spending context wisely
39
+
40
+ Once a skill activates, its full `SKILL.md` body loads into the agent's context window alongside conversation history, system context, and other active skills. Every token in your skill competes for the agent's attention.
41
+
42
+ ### Add what the agent lacks, omit what it knows
43
+
44
+ Focus on what the agent wouldn't know without your skill: project conventions, domain procedures, non-obvious edge cases, the particular tools or APIs to use. Don't explain what a PDF is, how HTTP works, or what a database migration does.
45
+
46
+ ```markdown
47
+ <!-- Too verbose — the agent already knows what PDFs are -->
48
+ ## Extract PDF text
49
+
50
+ PDF (Portable Document Format) files are a common file format that contains
51
+ text, images, and other content. To extract text from a PDF, you'll need to
52
+ use a library. pdfplumber is recommended because it handles most cases well.
53
+
54
+ <!-- Better — jumps to what the agent wouldn't know -->
55
+ ## Extract PDF text
56
+
57
+ Use pdfplumber for text extraction. For scanned documents, fall back to
58
+ pdf2image with pytesseract.
59
+ ```
60
+
61
+ Ask: "Would the agent get this wrong without this instruction?" If no, cut it. If unsure, test it. If the agent handles the whole task well without the skill, the skill may not be adding value.
62
+
63
+ ### Design coherent units
64
+
65
+ Skills are functions: encapsulate a coherent unit of work that composes well with other skills.
66
+
67
+ - Too narrow → multiple skills must load for one task (overhead, conflicting instructions).
68
+ - Too broad → hard to activate precisely.
69
+
70
+ A skill for "query a database and format results" is one coherent unit. A skill that also covers database administration is doing too much.
71
+
72
+ ### Aim for moderate detail
73
+
74
+ Comprehensive skills can hurt — the agent struggles to extract what's relevant, may pursue unproductive paths from instructions that don't apply. Concise, stepwise guidance with a working example outperforms exhaustive documentation. When you find yourself covering every edge case, consider whether most are better handled by the agent's own judgment.
75
+
76
+ ### Structure with progressive disclosure
77
+
78
+ Keep `SKILL.md` under 500 lines and 5000 tokens — the core the agent needs on every run. When more is legitimately needed, move detail to `references/` and tell the agent **when** to load each file.
79
+
80
+ > "Read `references/api-errors.md` if the API returns a non-200 status code" is more useful than a generic "see references/ for details."
81
+
82
+ ## Calibrating control
83
+
84
+ Not every part needs the same level of prescriptiveness. Match specificity to fragility.
85
+
86
+ ### Match specificity to fragility
87
+
88
+ **Give the agent freedom** when multiple approaches are valid and the task tolerates variation. Explaining *why* often beats rigid directives.
89
+
90
+ ```markdown
91
+ ## Code review process
92
+
93
+ 1. Check all database queries for SQL injection (use parameterized queries)
94
+ 2. Verify authentication checks on every endpoint
95
+ 3. Look for race conditions in concurrent code paths
96
+ 4. Confirm error messages don't leak internal details
97
+ ```
98
+
99
+ **Be prescriptive** when operations are fragile, consistency matters, or a specific sequence must be followed.
100
+
101
+ ```markdown
102
+ ## Database migration
103
+
104
+ Run exactly this sequence:
105
+
106
+ ```bash
107
+ python scripts/migrate.py --verify --backup
108
+ ```
109
+
110
+ Do not modify the command or add additional flags.
111
+ ```
112
+
113
+ Most skills have a mix. Calibrate each part independently.
114
+
115
+ ### Provide defaults, not menus
116
+
117
+ When multiple tools or approaches could work, pick a default and mention alternatives briefly.
118
+
119
+ ```markdown
120
+ <!-- Too many options -->
121
+ You can use pypdf, pdfplumber, PyMuPDF, or pdf2image...
122
+
123
+ <!-- Clear default with escape hatch -->
124
+ Use pdfplumber for text extraction:
125
+
126
+ ```python
127
+ import pdfplumber
128
+ ```
129
+
130
+ For scanned PDFs requiring OCR, use pdf2image with pytesseract instead.
131
+ ```
132
+
133
+ ### Favor procedures over declarations
134
+
135
+ A skill should teach the agent *how to approach* a class of problems, not *what to produce* for a specific instance.
136
+
137
+ ```markdown
138
+ <!-- Specific answer — only useful for this exact task -->
139
+ Join the `orders` table to `customers` on `customer_id`, filter where
140
+ `region = 'EMEA'`, and sum the `amount` column.
141
+
142
+ <!-- Reusable method — works for any analytical query -->
143
+ 1. Read the schema from `references/schema.yaml` to find relevant tables
144
+ 2. Join tables using the `_id` foreign key convention
145
+ 3. Apply any filters from the user's request as WHERE clauses
146
+ 4. Aggregate numeric columns as needed and format as a markdown table
147
+ ```
148
+
149
+ Specific details (output templates, hard constraints like "never output PII", tool-specific instructions) are valuable. The point: the *approach* should generalize even when individual details are specific.
150
+
151
+ ## Patterns for effective instructions
152
+
153
+ ### Gotchas sections
154
+
155
+ The highest-value content in many skills is a list of gotchas — environment-specific facts that defy reasonable assumptions. These aren't general advice; they're concrete corrections to mistakes the agent will make without being told.
156
+
157
+ ```markdown
158
+ ## Gotchas
159
+
160
+ - The `users` table uses soft deletes. Queries must include
161
+ `WHERE deleted_at IS NULL` or results will include deactivated accounts.
162
+ - The user ID is `user_id` in the database, `uid` in the auth service,
163
+ and `accountId` in the billing API. All three refer to the same value.
164
+ - The `/health` endpoint returns 200 as long as the web server is running,
165
+ even if the database connection is down. Use `/ready` to check full
166
+ service health.
167
+ ```
168
+
169
+ Keep gotchas in `SKILL.md` where the agent reads them before encountering the situation. A reference file works if you tell the agent when to load it, but for non-obvious issues, the agent may not recognize the trigger.
170
+
171
+ When the agent makes a mistake you have to correct, add the correction to the gotchas section. This is one of the most direct ways to improve a skill iteratively.
172
+
173
+ ### Templates for output format
174
+
175
+ When the agent must produce output in a specific format, provide a template. Agents pattern-match well against concrete structures. Short templates can live inline; longer ones go in `assets/`.
176
+
177
+ ```markdown
178
+ ## Report structure
179
+
180
+ Use this template, adapting sections as needed:
181
+
182
+ ```markdown
183
+ # [Analysis Title]
184
+
185
+ ## Executive summary
186
+ [One-paragraph overview of key findings]
187
+
188
+ ## Key findings
189
+ - Finding 1 with supporting data
190
+ - Finding 2 with supporting data
191
+
192
+ ## Recommendations
193
+ 1. Specific actionable recommendation
194
+ 2. Specific actionable recommendation
195
+ ```
196
+ ```
197
+
198
+ ### Checklists for multi-step workflows
199
+
200
+ An explicit checklist helps the agent track progress and avoid skipping steps, especially when steps have dependencies or validation gates.
201
+
202
+ ```markdown
203
+ ## Form processing workflow
204
+
205
+ Progress:
206
+ - [ ] Step 1: Analyze the form (run `scripts/analyze_form.py`)
207
+ - [ ] Step 2: Create field mapping (edit `fields.json`)
208
+ - [ ] Step 3: Validate mapping (run `scripts/validate_fields.py`)
209
+ - [ ] Step 4: Fill the form (run `scripts/fill_form.py`)
210
+ - [ ] Step 5: Verify output (run `scripts/verify_output.py`)
211
+ ```
212
+
213
+ ### Validation loops
214
+
215
+ Instruct the agent to validate its own work before moving on: do, validate, fix, repeat.
216
+
217
+ ```markdown
218
+ ## Editing workflow
219
+
220
+ 1. Make your edits
221
+ 2. Run validation: `python scripts/validate.py output/`
222
+ 3. If validation fails:
223
+ - Review the error message
224
+ - Fix the issues
225
+ - Run validation again
226
+ 4. Only proceed when validation passes
227
+ ```
228
+
229
+ A reference document can also be the "validator" — instruct the agent to check its work against the reference before finalizing.
230
+
231
+ ### Plan-validate-execute
232
+
233
+ For batch or destructive operations: create an intermediate plan, validate it against a source of truth, then execute.
234
+
235
+ ```markdown
236
+ ## PDF form filling
237
+
238
+ 1. Extract form fields: `python scripts/analyze_form.py input.pdf` → `form_fields.json`
239
+ 2. Create `field_values.json` mapping each field to its intended value
240
+ 3. Validate: `python scripts/validate_fields.py form_fields.json field_values.json`
241
+ 4. If validation fails, revise `field_values.json` and re-validate
242
+ 5. Fill the form: `python scripts/fill_form.py input.pdf field_values.json output.pdf`
243
+ ```
244
+
245
+ The key ingredient is step 3: a validation script that checks the plan against the source of truth. Errors like "Field 'signature_date' not found — available fields: customer_name, order_total, signature_date_signed" give the agent enough information to self-correct.
246
+
247
+ ### Bundling reusable scripts
248
+
249
+ When iterating on a skill, compare execution traces across test cases. If the agent independently reinvents the same logic each run (building charts, parsing a format, validating output), that's the signal to write a tested script once and bundle it. See [scripts-guide.md](scripts-guide.md).