pi-gauntlet 4.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 (46) hide show
  1. package/CHANGELOG.md +300 -0
  2. package/LICENSE +24 -0
  3. package/README.md +278 -0
  4. package/agents/code-reviewer.md +48 -0
  5. package/agents/conformance-reviewer.md +139 -0
  6. package/agents/implementer.md +40 -0
  7. package/agents/spec-council-member.md +47 -0
  8. package/agents/spec-council-synthesizer.md +39 -0
  9. package/agents/spec-reviewer.md +47 -0
  10. package/agents/spec-summarizer.md +42 -0
  11. package/bin/install-agents.mjs +141 -0
  12. package/extensions/phase-tracker.ts +622 -0
  13. package/extensions/plan-tracker.ts +308 -0
  14. package/extensions/verify-before-ship.ts +132 -0
  15. package/package.json +43 -0
  16. package/skills/brainstorming/SKILL.md +290 -0
  17. package/skills/dispatching-parallel-agents/SKILL.md +192 -0
  18. package/skills/finishing-a-development-branch/SKILL.md +311 -0
  19. package/skills/receiving-code-review/SKILL.md +200 -0
  20. package/skills/requesting-code-review/SKILL.md +115 -0
  21. package/skills/requesting-code-review/code-reviewer.md +166 -0
  22. package/skills/roasting-the-spec/SKILL.md +139 -0
  23. package/skills/subagent-driven-development/SKILL.md +223 -0
  24. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +25 -0
  25. package/skills/subagent-driven-development/implementer-prompt.md +113 -0
  26. package/skills/subagent-driven-development/spec-reviewer-prompt.md +68 -0
  27. package/skills/systematic-debugging/SKILL.md +151 -0
  28. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  29. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  30. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  31. package/skills/systematic-debugging/find-polluter.sh +63 -0
  32. package/skills/systematic-debugging/reference/rationalizations.md +61 -0
  33. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  34. package/skills/test-driven-development/SKILL.md +230 -0
  35. package/skills/test-driven-development/reference/examples.md +99 -0
  36. package/skills/test-driven-development/reference/rationalizations.md +65 -0
  37. package/skills/test-driven-development/reference/when-stuck.md +31 -0
  38. package/skills/test-driven-development/testing-anti-patterns.md +299 -0
  39. package/skills/using-git-worktrees/SKILL.md +193 -0
  40. package/skills/verification-before-completion/SKILL.md +169 -0
  41. package/skills/verification-before-completion/reference/conformance-check.md +220 -0
  42. package/skills/writing-plans/SKILL.md +244 -0
  43. package/skills/writing-skills/SKILL.md +429 -0
  44. package/skills/writing-skills/reference/anthropic-best-practices.md +1130 -0
  45. package/skills/writing-skills/reference/persuasion.md +187 -0
  46. package/skills/writing-skills/reference/testing-skills-with-subagents.md +384 -0
@@ -0,0 +1,1130 @@
1
+ # Skill authoring best practices
2
+
3
+ Good Skills are concise, well-structured, and tested with real usage. This guide provides practical authoring decisions to help you write Skills that Claude can discover and use effectively.
4
+
5
+ For conceptual background on how Skills work, see the [Skills overview](/en/docs/agents-and-tools/agent-skills/overview).
6
+
7
+ ## Core principles
8
+
9
+ ### Concise is key
10
+
11
+ The [context window](https://platform.claude.com/docs/en/build-with-claude/context-windows) is a public good. Your Skill shares the context window with everything else Claude needs to know, including:
12
+
13
+ * The system prompt
14
+ * Conversation history
15
+ * Other Skills' metadata
16
+ * Your actual request
17
+
18
+ Not every token in your Skill has an immediate cost. At startup, only the metadata (name and description) from all Skills is pre-loaded. Claude reads SKILL.md only when the Skill becomes relevant, and reads additional files only as needed. However, being concise in SKILL.md still matters: once Claude loads it, every token competes with conversation history and other context.
19
+
20
+ **Default assumption**: Claude is already very smart
21
+
22
+ Only add context Claude doesn't already have. Challenge each piece of information:
23
+
24
+ * "Does Claude really need this explanation?"
25
+ * "Can I assume Claude knows this?"
26
+ * "Does this paragraph justify its token cost?"
27
+
28
+ **Good example: Concise** (approximately 50 tokens):
29
+
30
+ ````markdown theme={null}
31
+ ## Extract PDF text
32
+
33
+ Use pdfplumber for text extraction:
34
+
35
+ ```python
36
+ import pdfplumber
37
+
38
+ with pdfplumber.open("file.pdf") as pdf:
39
+ text = pdf.pages[0].extract_text()
40
+ ```
41
+ ````
42
+
43
+ **Bad example: Too verbose** (approximately 150 tokens):
44
+
45
+ ```markdown theme={null}
46
+ ## Extract PDF text
47
+
48
+ PDF (Portable Document Format) files are a common file format that contains
49
+ text, images, and other content. To extract text from a PDF, you'll need to
50
+ use a library. There are many libraries available for PDF processing, but we
51
+ recommend pdfplumber because it's easy to use and handles most cases well.
52
+ First, you'll need to install it using pip. Then you can use the code below...
53
+ ```
54
+
55
+ The concise version assumes Claude knows what PDFs are and how libraries work.
56
+
57
+ ### Set appropriate degrees of freedom
58
+
59
+ Match the level of specificity to the task's fragility and variability.
60
+
61
+ **High freedom** (text-based instructions):
62
+
63
+ Use when:
64
+
65
+ * Multiple approaches are valid
66
+ * Decisions depend on context
67
+ * Heuristics guide the approach
68
+
69
+ Example:
70
+
71
+ ```markdown theme={null}
72
+ ## Code review process
73
+
74
+ 1. Analyze the code structure and organization
75
+ 2. Check for potential bugs or edge cases
76
+ 3. Suggest improvements for readability and maintainability
77
+ 4. Verify adherence to project conventions
78
+ ```
79
+
80
+ **Medium freedom** (pseudocode or scripts with parameters):
81
+
82
+ Use when:
83
+
84
+ * A preferred pattern exists
85
+ * Some variation is acceptable
86
+ * Configuration affects behavior
87
+
88
+ Example:
89
+
90
+ ````markdown theme={null}
91
+ ## Generate report
92
+
93
+ Use this template and customize as needed:
94
+
95
+ ```python
96
+ def generate_report(data, format="markdown", include_charts=True):
97
+ # Process data
98
+ # Generate output in specified format
99
+ # Optionally include visualizations
100
+ ```
101
+ ````
102
+
103
+ **Low freedom** (specific scripts, few or no parameters):
104
+
105
+ Use when:
106
+
107
+ * Operations are fragile and error-prone
108
+ * Consistency is critical
109
+ * A specific sequence must be followed
110
+
111
+ Example:
112
+
113
+ ````markdown theme={null}
114
+ ## Database migration
115
+
116
+ Run exactly this script:
117
+
118
+ ```bash
119
+ python scripts/migrate.py --verify --backup
120
+ ```
121
+
122
+ Do not modify the command or add additional flags.
123
+ ````
124
+
125
+ **Analogy**: Think of Claude as a robot exploring a path:
126
+
127
+ * **Narrow bridge with cliffs on both sides**: There's only one safe way forward. Provide specific guardrails and exact instructions (low freedom). Example: database migrations that must run in exact sequence.
128
+ * **Open field with no hazards**: Many paths lead to success. Give general direction and trust Claude to find the best route (high freedom). Example: code reviews where context determines the best approach.
129
+
130
+ ### Test with all models you plan to use
131
+
132
+ Skills act as additions to models, so effectiveness depends on the underlying model. Test your Skill with all the models you plan to use it with.
133
+
134
+ **Testing considerations by model**:
135
+
136
+ * **Claude Haiku** (fast, economical): Does the Skill provide enough guidance?
137
+ * **Claude Sonnet** (balanced): Is the Skill clear and efficient?
138
+ * **Claude Opus** (powerful reasoning): Does the Skill avoid over-explaining?
139
+
140
+ What works perfectly for Opus might need more detail for Haiku. If you plan to use your Skill across multiple models, aim for instructions that work well with all of them.
141
+
142
+ ## Skill structure
143
+
144
+ <Note>
145
+ **YAML Frontmatter**: The SKILL.md frontmatter requires two fields:
146
+
147
+ * `name` - Human-readable name of the Skill (64 characters maximum)
148
+ * `description` - One-line description of what the Skill does and when to use it (1024 characters maximum)
149
+
150
+ For complete Skill structure details, see the [Skills overview](/en/docs/agents-and-tools/agent-skills/overview#skill-structure).
151
+ </Note>
152
+
153
+ ### Naming conventions
154
+
155
+ Use consistent naming patterns to make Skills easier to reference and discuss. We recommend using **gerund form** (verb + -ing) for Skill names, as this clearly describes the activity or capability the Skill provides.
156
+
157
+ **Good naming examples (gerund form)**:
158
+
159
+ * "Processing PDFs"
160
+ * "Analyzing spreadsheets"
161
+ * "Managing databases"
162
+ * "Testing code"
163
+ * "Writing documentation"
164
+
165
+ **Acceptable alternatives**:
166
+
167
+ * Noun phrases: "PDF Processing", "Spreadsheet Analysis"
168
+ * Action-oriented: "Process PDFs", "Analyze Spreadsheets"
169
+
170
+ **Avoid**:
171
+
172
+ * Vague names: "Helper", "Utils", "Tools"
173
+ * Overly generic: "Documents", "Data", "Files"
174
+ * Inconsistent patterns within your skill collection
175
+
176
+ Consistent naming makes it easier to:
177
+
178
+ * Reference Skills in documentation and conversations
179
+ * Understand what a Skill does at a glance
180
+ * Organize and search through multiple Skills
181
+ * Maintain a professional, cohesive skill library
182
+
183
+ ### Writing effective descriptions
184
+
185
+ The `description` field enables Skill discovery and should include both what the Skill does and when to use it.
186
+
187
+ <Warning>
188
+ **Always write in third person**. The description is injected into the system prompt, and inconsistent point-of-view can cause discovery problems.
189
+
190
+ * **Good:** "Processes Excel files and generates reports"
191
+ * **Avoid:** "I can help you process Excel files"
192
+ * **Avoid:** "You can use this to process Excel files"
193
+ </Warning>
194
+
195
+ **Be specific and include key terms**. Include both what the Skill does and specific triggers/contexts for when to use it.
196
+
197
+ Each Skill has exactly one description field. The description is critical for skill selection: Claude uses it to choose the right Skill from potentially 100+ available Skills. Your description must provide enough detail for Claude to know when to select this Skill, while the rest of SKILL.md provides the implementation details.
198
+
199
+ Effective examples:
200
+
201
+ **PDF Processing skill:**
202
+
203
+ ```yaml theme={null}
204
+ description: Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction.
205
+ ```
206
+
207
+ **Excel Analysis skill:**
208
+
209
+ ```yaml theme={null}
210
+ description: Analyze Excel spreadsheets, create pivot tables, generate charts. Use when analyzing Excel files, spreadsheets, tabular data, or .xlsx files.
211
+ ```
212
+
213
+ **Git Commit Helper skill:**
214
+
215
+ ```yaml theme={null}
216
+ description: Generate descriptive commit messages by analyzing git diffs. Use when the user asks for help writing commit messages or reviewing staged changes.
217
+ ```
218
+
219
+ Avoid vague descriptions like these:
220
+
221
+ ```yaml theme={null}
222
+ description: Helps with documents
223
+ ```
224
+
225
+ ```yaml theme={null}
226
+ description: Processes data
227
+ ```
228
+
229
+ ```yaml theme={null}
230
+ description: Does stuff with files
231
+ ```
232
+
233
+ ### Progressive disclosure patterns
234
+
235
+ SKILL.md serves as an overview that points Claude to detailed materials as needed, like a table of contents in an onboarding guide. For an explanation of how progressive disclosure works, see [How Skills work](/en/docs/agents-and-tools/agent-skills/overview#how-skills-work) in the overview.
236
+
237
+ **Practical guidance:**
238
+
239
+ * Keep SKILL.md body under 500 lines for optimal performance
240
+ * Split content into separate files when approaching this limit
241
+ * Use the patterns below to organize instructions, code, and resources effectively
242
+
243
+ #### Visual overview: From simple to complex
244
+
245
+ A basic Skill starts with just a SKILL.md file containing metadata and instructions:
246
+
247
+
248
+ As your Skill grows, you can bundle additional content that Claude loads only when needed:
249
+
250
+
251
+ The complete Skill directory structure might look like this:
252
+
253
+ ```
254
+ pdf/
255
+ ├── SKILL.md # Main instructions (loaded when triggered)
256
+ ├── FORMS.md # Form-filling guide (loaded as needed)
257
+ ├── reference.md # API reference (loaded as needed)
258
+ ├── examples.md # Usage examples (loaded as needed)
259
+ └── scripts/
260
+ ├── analyze_form.py # Utility script (executed, not loaded)
261
+ ├── fill_form.py # Form filling script
262
+ └── validate.py # Validation script
263
+ ```
264
+
265
+ #### Pattern 1: High-level guide with references
266
+
267
+ ````markdown theme={null}
268
+ ---
269
+ name: PDF Processing
270
+ description: Extracts text and tables from PDF files, fills forms, and merges documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction.
271
+ ---
272
+
273
+ # PDF Processing
274
+
275
+ ## Quick start
276
+
277
+ Extract text with pdfplumber:
278
+ ```python
279
+ import pdfplumber
280
+ with pdfplumber.open("file.pdf") as pdf:
281
+ text = pdf.pages[0].extract_text()
282
+ ```
283
+
284
+ ## Advanced features
285
+
286
+ **Form filling**: See [FORMS.md](FORMS.md) for complete guide
287
+ **API reference**: See [REFERENCE.md](REFERENCE.md) for all methods
288
+ **Examples**: See [EXAMPLES.md](EXAMPLES.md) for common patterns
289
+ ````
290
+
291
+ Claude loads FORMS.md, REFERENCE.md, or EXAMPLES.md only when needed.
292
+
293
+ #### Pattern 2: Domain-specific organization
294
+
295
+ For Skills with multiple domains, organize content by domain to avoid loading irrelevant context. When a user asks about sales metrics, Claude only needs to read sales-related schemas, not finance or marketing data. This keeps token usage low and context focused.
296
+
297
+ ```
298
+ bigquery-skill/
299
+ ├── SKILL.md (overview and navigation)
300
+ └── reference/
301
+ ├── finance.md (revenue, billing metrics)
302
+ ├── sales.md (opportunities, pipeline)
303
+ ├── product.md (API usage, features)
304
+ └── marketing.md (campaigns, attribution)
305
+ ```
306
+
307
+ ````markdown SKILL.md theme={null}
308
+ # BigQuery Data Analysis
309
+
310
+ ## Available datasets
311
+
312
+ **Finance**: Revenue, ARR, billing → See [reference/finance.md](reference/finance.md)
313
+ **Sales**: Opportunities, pipeline, accounts → See [reference/sales.md](reference/sales.md)
314
+ **Product**: API usage, features, adoption → See [reference/product.md](reference/product.md)
315
+ **Marketing**: Campaigns, attribution, email → See [reference/marketing.md](reference/marketing.md)
316
+
317
+ ## Quick search
318
+
319
+ Find specific metrics using grep:
320
+
321
+ ```bash
322
+ grep -i "revenue" reference/finance.md
323
+ grep -i "pipeline" reference/sales.md
324
+ grep -i "api usage" reference/product.md
325
+ ```
326
+ ````
327
+
328
+ #### Pattern 3: Conditional details
329
+
330
+ Show basic content, link to advanced content:
331
+
332
+ ```markdown theme={null}
333
+ # DOCX Processing
334
+
335
+ ## Creating documents
336
+
337
+ Use docx-js for new documents. See [DOCX-JS.md](DOCX-JS.md).
338
+
339
+ ## Editing documents
340
+
341
+ For simple edits, modify the XML directly.
342
+
343
+ **For tracked changes**: See [REDLINING.md](REDLINING.md)
344
+ **For OOXML details**: See [OOXML.md](OOXML.md)
345
+ ```
346
+
347
+ Claude reads REDLINING.md or OOXML.md only when the user needs those features.
348
+
349
+ ### Avoid deeply nested references
350
+
351
+ Claude may partially read files when they're referenced from other referenced files. When encountering nested references, Claude might use commands like `head -100` to preview content rather than reading entire files, resulting in incomplete information.
352
+
353
+ **Keep references one level deep from SKILL.md**. All reference files should link directly from SKILL.md to ensure Claude reads complete files when needed.
354
+
355
+ **Bad example: Too deep**:
356
+
357
+ ```markdown theme={null}
358
+ # SKILL.md
359
+ See [advanced.md](advanced.md)...
360
+
361
+ # advanced.md
362
+ See [details.md](details.md)...
363
+
364
+ # details.md
365
+ Here's the actual information...
366
+ ```
367
+
368
+ **Good example: One level deep**:
369
+
370
+ ```markdown theme={null}
371
+ # SKILL.md
372
+
373
+ **Basic usage**: [instructions in SKILL.md]
374
+ **Advanced features**: See [advanced.md](advanced.md)
375
+ **API reference**: See [reference.md](reference.md)
376
+ **Examples**: See [examples.md](examples.md)
377
+ ```
378
+
379
+ ### Structure longer reference files with table of contents
380
+
381
+ For reference files longer than 100 lines, include a table of contents at the top. This ensures Claude can see the full scope of available information even when previewing with partial reads.
382
+
383
+ **Example**:
384
+
385
+ ```markdown theme={null}
386
+ # API Reference
387
+
388
+ ## Contents
389
+ - Authentication and setup
390
+ - Core methods (create, read, update, delete)
391
+ - Advanced features (batch operations, webhooks)
392
+ - Error handling patterns
393
+ - Code examples
394
+
395
+ ## Authentication and setup
396
+ ...
397
+
398
+ ## Core methods
399
+ ...
400
+ ```
401
+
402
+ Claude can then read the complete file or jump to specific sections as needed.
403
+
404
+ For details on how this filesystem-based architecture enables progressive disclosure, see the [Runtime environment](#runtime-environment) section in the Advanced section below.
405
+
406
+ ## Workflows and feedback loops
407
+
408
+ ### Use workflows for complex tasks
409
+
410
+ Break complex operations into clear, sequential steps. For particularly complex workflows, provide a checklist that Claude can copy into its response and check off as it progresses.
411
+
412
+ **Example 1: Research synthesis workflow** (for Skills without code):
413
+
414
+ ````markdown theme={null}
415
+ ## Research synthesis workflow
416
+
417
+ Copy this checklist and track your progress:
418
+
419
+ ```
420
+ Research Progress:
421
+ - [ ] Step 1: Read all source documents
422
+ - [ ] Step 2: Identify key themes
423
+ - [ ] Step 3: Cross-reference claims
424
+ - [ ] Step 4: Create structured summary
425
+ - [ ] Step 5: Verify citations
426
+ ```
427
+
428
+ **Step 1: Read all source documents**
429
+
430
+ Review each document in the `sources/` directory. Note the main arguments and supporting evidence.
431
+
432
+ **Step 2: Identify key themes**
433
+
434
+ Look for patterns across sources. What themes appear repeatedly? Where do sources agree or disagree?
435
+
436
+ **Step 3: Cross-reference claims**
437
+
438
+ For each major claim, verify it appears in the source material. Note which source supports each point.
439
+
440
+ **Step 4: Create structured summary**
441
+
442
+ Organize findings by theme. Include:
443
+ - Main claim
444
+ - Supporting evidence from sources
445
+ - Conflicting viewpoints (if any)
446
+
447
+ **Step 5: Verify citations**
448
+
449
+ Check that every claim references the correct source document. If citations are incomplete, return to Step 3.
450
+ ````
451
+
452
+ This example shows how workflows apply to analysis tasks that don't require code. The checklist pattern works for any complex, multi-step process.
453
+
454
+ **Example 2: PDF form filling workflow** (for Skills with code):
455
+
456
+ ````markdown theme={null}
457
+ ## PDF form filling workflow
458
+
459
+ Copy this checklist and check off items as you complete them:
460
+
461
+ ```
462
+ Task Progress:
463
+ - [ ] Step 1: Analyze the form (run analyze_form.py)
464
+ - [ ] Step 2: Create field mapping (edit fields.json)
465
+ - [ ] Step 3: Validate mapping (run validate_fields.py)
466
+ - [ ] Step 4: Fill the form (run fill_form.py)
467
+ - [ ] Step 5: Verify output (run verify_output.py)
468
+ ```
469
+
470
+ **Step 1: Analyze the form**
471
+
472
+ Run: `python scripts/analyze_form.py input.pdf`
473
+
474
+ This extracts form fields and their locations, saving to `fields.json`.
475
+
476
+ **Step 2: Create field mapping**
477
+
478
+ Edit `fields.json` to add values for each field.
479
+
480
+ **Step 3: Validate mapping**
481
+
482
+ Run: `python scripts/validate_fields.py fields.json`
483
+
484
+ Fix any validation errors before continuing.
485
+
486
+ **Step 4: Fill the form**
487
+
488
+ Run: `python scripts/fill_form.py input.pdf fields.json output.pdf`
489
+
490
+ **Step 5: Verify output**
491
+
492
+ Run: `python scripts/verify_output.py output.pdf`
493
+
494
+ If verification fails, return to Step 2.
495
+ ````
496
+
497
+ Clear steps prevent Claude from skipping critical validation. The checklist helps both Claude and you track progress through multi-step workflows.
498
+
499
+ ### Implement feedback loops
500
+
501
+ **Common pattern**: Run validator → fix errors → repeat
502
+
503
+ This pattern greatly improves output quality.
504
+
505
+ **Example 1: Style guide compliance** (for Skills without code):
506
+
507
+ ```markdown theme={null}
508
+ ## Content review process
509
+
510
+ 1. Draft your content following the guidelines in STYLE_GUIDE.md
511
+ 2. Review against the checklist:
512
+ - Check terminology consistency
513
+ - Verify examples follow the standard format
514
+ - Confirm all required sections are present
515
+ 3. If issues found:
516
+ - Note each issue with specific section reference
517
+ - Revise the content
518
+ - Review the checklist again
519
+ 4. Only proceed when all requirements are met
520
+ 5. Finalize and save the document
521
+ ```
522
+
523
+ This shows the validation loop pattern using reference documents instead of scripts. The "validator" is STYLE\_GUIDE.md, and Claude performs the check by reading and comparing.
524
+
525
+ **Example 2: Document editing process** (for Skills with code):
526
+
527
+ ```markdown theme={null}
528
+ ## Document editing process
529
+
530
+ 1. Make your edits to `word/document.xml`
531
+ 2. **Validate immediately**: `python ooxml/scripts/validate.py unpacked_dir/`
532
+ 3. If validation fails:
533
+ - Review the error message carefully
534
+ - Fix the issues in the XML
535
+ - Run validation again
536
+ 4. **Only proceed when validation passes**
537
+ 5. Rebuild: `python ooxml/scripts/pack.py unpacked_dir/ output.docx`
538
+ 6. Test the output document
539
+ ```
540
+
541
+ The validation loop catches errors early.
542
+
543
+ ## Content guidelines
544
+
545
+ ### Avoid time-sensitive information
546
+
547
+ Don't include information that will become outdated:
548
+
549
+ **Bad example: Time-sensitive** (will become wrong):
550
+
551
+ ```markdown theme={null}
552
+ If you're doing this before August 2025, use the old API.
553
+ After August 2025, use the new API.
554
+ ```
555
+
556
+ **Good example** (use "old patterns" section):
557
+
558
+ ```markdown theme={null}
559
+ ## Current method
560
+
561
+ Use the v2 API endpoint: `api.example.com/v2/messages`
562
+
563
+ ## Old patterns
564
+
565
+ <details>
566
+ <summary>Legacy v1 API (deprecated 2025-08)</summary>
567
+
568
+ The v1 API used: `api.example.com/v1/messages`
569
+
570
+ This endpoint is no longer supported.
571
+ </details>
572
+ ```
573
+
574
+ The old patterns section provides historical context without cluttering the main content.
575
+
576
+ ### Use consistent terminology
577
+
578
+ Choose one term and use it throughout the Skill:
579
+
580
+ **Good - Consistent**:
581
+
582
+ * Always "API endpoint"
583
+ * Always "field"
584
+ * Always "extract"
585
+
586
+ **Bad - Inconsistent**:
587
+
588
+ * Mix "API endpoint", "URL", "API route", "path"
589
+ * Mix "field", "box", "element", "control"
590
+ * Mix "extract", "pull", "get", "retrieve"
591
+
592
+ Consistency helps Claude understand and follow instructions.
593
+
594
+ ## Common patterns
595
+
596
+ ### Template pattern
597
+
598
+ Provide templates for output format. Match the level of strictness to your needs.
599
+
600
+ **For strict requirements** (like API responses or data formats):
601
+
602
+ ````markdown theme={null}
603
+ ## Report structure
604
+
605
+ ALWAYS use this exact template structure:
606
+
607
+ ```markdown
608
+ # [Analysis Title]
609
+
610
+ ## Executive summary
611
+ [One-paragraph overview of key findings]
612
+
613
+ ## Key findings
614
+ - Finding 1 with supporting data
615
+ - Finding 2 with supporting data
616
+ - Finding 3 with supporting data
617
+
618
+ ## Recommendations
619
+ 1. Specific actionable recommendation
620
+ 2. Specific actionable recommendation
621
+ ```
622
+ ````
623
+
624
+ **For flexible guidance** (when adaptation is useful):
625
+
626
+ ````markdown theme={null}
627
+ ## Report structure
628
+
629
+ Here is a sensible default format, but use your best judgment based on the analysis:
630
+
631
+ ```markdown
632
+ # [Analysis Title]
633
+
634
+ ## Executive summary
635
+ [Overview]
636
+
637
+ ## Key findings
638
+ [Adapt sections based on what you discover]
639
+
640
+ ## Recommendations
641
+ [Tailor to the specific context]
642
+ ```
643
+
644
+ Adjust sections as needed for the specific analysis type.
645
+ ````
646
+
647
+ ### Examples pattern
648
+
649
+ For Skills where output quality depends on seeing examples, provide input/output pairs just like in regular prompting:
650
+
651
+ ````markdown theme={null}
652
+ ## Commit message format
653
+
654
+ Generate commit messages following these examples:
655
+
656
+ **Example 1:**
657
+ Input: Added user authentication with JWT tokens
658
+ Output:
659
+ ```
660
+ feat(auth): implement JWT-based authentication
661
+
662
+ Add login endpoint and token validation middleware
663
+ ```
664
+
665
+ **Example 2:**
666
+ Input: Fixed bug where dates displayed incorrectly in reports
667
+ Output:
668
+ ```
669
+ fix(reports): correct date formatting in timezone conversion
670
+
671
+ Use UTC timestamps consistently across report generation
672
+ ```
673
+
674
+ **Example 3:**
675
+ Input: Updated dependencies and refactored error handling
676
+ Output:
677
+ ```
678
+ chore: update dependencies and refactor error handling
679
+
680
+ - Upgrade lodash to 4.17.21
681
+ - Standardize error response format across endpoints
682
+ ```
683
+
684
+ Follow this style: type(scope): brief description, then detailed explanation.
685
+ ````
686
+
687
+ Examples help Claude understand the desired style and level of detail more clearly than descriptions alone.
688
+
689
+ ### Conditional workflow pattern
690
+
691
+ Guide Claude through decision points:
692
+
693
+ ```markdown theme={null}
694
+ ## Document modification workflow
695
+
696
+ 1. Determine the modification type:
697
+
698
+ **Creating new content?** → Follow "Creation workflow" below
699
+ **Editing existing content?** → Follow "Editing workflow" below
700
+
701
+ 2. Creation workflow:
702
+ - Use docx-js library
703
+ - Build document from scratch
704
+ - Export to .docx format
705
+
706
+ 3. Editing workflow:
707
+ - Unpack existing document
708
+ - Modify XML directly
709
+ - Validate after each change
710
+ - Repack when complete
711
+ ```
712
+
713
+ <Tip>
714
+ If workflows become large or complicated with many steps, consider pushing them into separate files and tell Claude to read the appropriate file based on the task at hand.
715
+ </Tip>
716
+
717
+ ## Evaluation and iteration
718
+
719
+ ### Build evaluations first
720
+
721
+ **Create evaluations BEFORE writing extensive documentation.** This ensures your Skill solves real problems rather than documenting imagined ones.
722
+
723
+ **Evaluation-driven development:**
724
+
725
+ 1. **Identify gaps**: Run Claude on representative tasks without a Skill. Document specific failures or missing context
726
+ 2. **Create evaluations**: Build three scenarios that test these gaps
727
+ 3. **Establish baseline**: Measure Claude's performance without the Skill
728
+ 4. **Write minimal instructions**: Create just enough content to address the gaps and pass evaluations
729
+ 5. **Iterate**: Execute evaluations, compare against baseline, and refine
730
+
731
+ This approach ensures you're solving actual problems rather than anticipating requirements that may never materialize.
732
+
733
+ **Evaluation structure**:
734
+
735
+ ```json theme={null}
736
+ {
737
+ "skills": ["pdf-processing"],
738
+ "query": "Extract all text from this PDF file and save it to output.txt",
739
+ "files": ["test-files/document.pdf"],
740
+ "expected_behavior": [
741
+ "Successfully reads the PDF file using an appropriate PDF processing library or command-line tool",
742
+ "Extracts text content from all pages in the document without missing any pages",
743
+ "Saves the extracted text to a file named output.txt in a clear, readable format"
744
+ ]
745
+ }
746
+ ```
747
+
748
+ <Note>
749
+ This example demonstrates a data-driven evaluation with a simple testing rubric. We do not currently provide a built-in way to run these evaluations. Users can create their own evaluation system. Evaluations are your source of truth for measuring Skill effectiveness.
750
+ </Note>
751
+
752
+ ### Develop Skills iteratively with Claude
753
+
754
+ The most effective Skill development process involves Claude itself. Work with one instance of Claude ("Claude A") to create a Skill that will be used by other instances ("Claude B"). Claude A helps you design and refine instructions, while Claude B tests them in real tasks. This works because Claude models understand both how to write effective agent instructions and what information agents need.
755
+
756
+ **Creating a new Skill:**
757
+
758
+ 1. **Complete a task without a Skill**: Work through a problem with Claude A using normal prompting. As you work, you'll naturally provide context, explain preferences, and share procedural knowledge. Notice what information you repeatedly provide.
759
+
760
+ 2. **Identify the reusable pattern**: After completing the task, identify what context you provided that would be useful for similar future tasks.
761
+
762
+ **Example**: If you worked through a BigQuery analysis, you might have provided table names, field definitions, filtering rules (like "always exclude test accounts"), and common query patterns.
763
+
764
+ 3. **Ask Claude A to create a Skill**: "Create a Skill that captures this BigQuery analysis pattern we just used. Include the table schemas, naming conventions, and the rule about filtering test accounts."
765
+
766
+ <Tip>
767
+ Claude models understand the Skill format and structure natively. You don't need special system prompts or a "writing skills" skill to get Claude to help create Skills. Simply ask Claude to create a Skill and it will generate properly structured SKILL.md content with appropriate frontmatter and body content.
768
+ </Tip>
769
+
770
+ 4. **Review for conciseness**: Check that Claude A hasn't added unnecessary explanations. Ask: "Remove the explanation about what win rate means - Claude already knows that."
771
+
772
+ 5. **Improve information architecture**: Ask Claude A to organize the content more effectively. For example: "Organize this so the table schema is in a separate reference file. We might add more tables later."
773
+
774
+ 6. **Test on similar tasks**: Use the Skill with Claude B (a fresh instance with the Skill loaded) on related use cases. Observe whether Claude B finds the right information, applies rules correctly, and handles the task successfully.
775
+
776
+ 7. **Iterate based on observation**: If Claude B struggles or misses something, return to Claude A with specifics: "When Claude used this Skill, it forgot to filter by date for Q4. Should we add a section about date filtering patterns?"
777
+
778
+ **Iterating on existing Skills:**
779
+
780
+ The same hierarchical pattern continues when improving Skills. You alternate between:
781
+
782
+ * **Working with Claude A** (the expert who helps refine the Skill)
783
+ * **Testing with Claude B** (the agent using the Skill to perform real work)
784
+ * **Observing Claude B's behavior** and bringing insights back to Claude A
785
+
786
+ 1. **Use the Skill in real workflows**: Give Claude B (with the Skill loaded) actual tasks, not test scenarios
787
+
788
+ 2. **Observe Claude B's behavior**: Note where it struggles, succeeds, or makes unexpected choices
789
+
790
+ **Example observation**: "When I asked Claude B for a regional sales report, it wrote the query but forgot to filter out test accounts, even though the Skill mentions this rule."
791
+
792
+ 3. **Return to Claude A for improvements**: Share the current SKILL.md and describe what you observed. Ask: "I noticed Claude B forgot to filter test accounts when I asked for a regional report. The Skill mentions filtering, but maybe it's not prominent enough?"
793
+
794
+ 4. **Review Claude A's suggestions**: Claude A might suggest reorganizing to make rules more prominent, using stronger language like "MUST filter" instead of "always filter", or restructuring the workflow section.
795
+
796
+ 5. **Apply and test changes**: Update the Skill with Claude A's refinements, then test again with Claude B on similar requests
797
+
798
+ 6. **Repeat based on usage**: Continue this observe-refine-test cycle as you encounter new scenarios. Each iteration improves the Skill based on real agent behavior, not assumptions.
799
+
800
+ **Gathering team feedback:**
801
+
802
+ 1. Share Skills with teammates and observe their usage
803
+ 2. Ask: Does the Skill activate when expected? Are instructions clear? What's missing?
804
+ 3. Incorporate feedback to address blind spots in your own usage patterns
805
+
806
+ **Why this approach works**: Claude A understands agent needs, you provide domain expertise, Claude B reveals gaps through real usage, and iterative refinement improves Skills based on observed behavior rather than assumptions.
807
+
808
+ ### Observe how Claude navigates Skills
809
+
810
+ As you iterate on Skills, pay attention to how Claude actually uses them in practice. Watch for:
811
+
812
+ * **Unexpected exploration paths**: Does Claude read files in an order you didn't anticipate? This might indicate your structure isn't as intuitive as you thought
813
+ * **Missed connections**: Does Claude fail to follow references to important files? Your links might need to be more explicit or prominent
814
+ * **Overreliance on certain sections**: If Claude repeatedly reads the same file, consider whether that content should be in the main SKILL.md instead
815
+ * **Ignored content**: If Claude never accesses a bundled file, it might be unnecessary or poorly signaled in the main instructions
816
+
817
+ Iterate based on these observations rather than assumptions. The 'name' and 'description' in your Skill's metadata are particularly critical. Claude uses these when deciding whether to trigger the Skill in response to the current task. Make sure they clearly describe what the Skill does and when it should be used.
818
+
819
+ ## Anti-patterns to avoid
820
+
821
+ ### Avoid Windows-style paths
822
+
823
+ Always use forward slashes in file paths, even on Windows:
824
+
825
+ * ✓ **Good**: `scripts/helper.py`, `reference/guide.md`
826
+ * ✗ **Avoid**: `scripts\helper.py`, `reference\guide.md`
827
+
828
+ Unix-style paths work across all platforms, while Windows-style paths cause errors on Unix systems.
829
+
830
+ ### Avoid offering too many options
831
+
832
+ Don't present multiple approaches unless necessary:
833
+
834
+ ````markdown theme={null}
835
+ **Bad example: Too many choices** (confusing):
836
+ "You can use pypdf, or pdfplumber, or PyMuPDF, or pdf2image, or..."
837
+
838
+ **Good example: Provide a default** (with escape hatch):
839
+ "Use pdfplumber for text extraction:
840
+ ```python
841
+ import pdfplumber
842
+ ```
843
+
844
+ For scanned PDFs requiring OCR, use pdf2image with pytesseract instead."
845
+ ````
846
+
847
+ ## Advanced: Skills with executable code
848
+
849
+ The sections below focus on Skills that include executable scripts. If your Skill uses only markdown instructions, skip to [Checklist for effective Skills](#checklist-for-effective-skills).
850
+
851
+ ### Solve, don't punt
852
+
853
+ When writing scripts for Skills, handle error conditions rather than punting to Claude.
854
+
855
+ **Good example: Handle errors explicitly**:
856
+
857
+ ```python theme={null}
858
+ def process_file(path):
859
+ """Process a file, creating it if it doesn't exist."""
860
+ try:
861
+ with open(path) as f:
862
+ return f.read()
863
+ except FileNotFoundError:
864
+ # Create file with default content instead of failing
865
+ print(f"File {path} not found, creating default")
866
+ with open(path, 'w') as f:
867
+ f.write('')
868
+ return ''
869
+ except PermissionError:
870
+ # Provide alternative instead of failing
871
+ print(f"Cannot access {path}, using default")
872
+ return ''
873
+ ```
874
+
875
+ **Bad example: Punt to Claude**:
876
+
877
+ ```python theme={null}
878
+ def process_file(path):
879
+ # Just fail and let Claude figure it out
880
+ return open(path).read()
881
+ ```
882
+
883
+ Configuration parameters should also be justified and documented to avoid "voodoo constants" (Ousterhout's law). If you don't know the right value, how will Claude determine it?
884
+
885
+ **Good example: Self-documenting**:
886
+
887
+ ```python theme={null}
888
+ # HTTP requests typically complete within 30 seconds
889
+ # Longer timeout accounts for slow connections
890
+ REQUEST_TIMEOUT = 30
891
+
892
+ # Three retries balances reliability vs speed
893
+ # Most intermittent failures resolve by the second retry
894
+ MAX_RETRIES = 3
895
+ ```
896
+
897
+ **Bad example: Magic numbers**:
898
+
899
+ ```python theme={null}
900
+ TIMEOUT = 47 # Why 47?
901
+ RETRIES = 5 # Why 5?
902
+ ```
903
+
904
+ ### Provide utility scripts
905
+
906
+ Even if Claude could write a script, pre-made scripts offer advantages:
907
+
908
+ **Benefits of utility scripts**:
909
+
910
+ * More reliable than generated code
911
+ * Save tokens (no need to include code in context)
912
+ * Save time (no code generation required)
913
+ * Ensure consistency across uses
914
+
915
+
916
+ The diagram above shows how executable scripts work alongside instruction files. The instruction file (forms.md) references the script, and Claude can execute it without loading its contents into context.
917
+
918
+ **Important distinction**: Make clear in your instructions whether Claude should:
919
+
920
+ * **Execute the script** (most common): "Run `analyze_form.py` to extract fields"
921
+ * **Read it as reference** (for complex logic): "See `analyze_form.py` for the field extraction algorithm"
922
+
923
+ For most utility scripts, execution is preferred because it's more reliable and efficient. See the [Runtime environment](#runtime-environment) section below for details on how script execution works.
924
+
925
+ **Example**:
926
+
927
+ ````markdown theme={null}
928
+ ## Utility scripts
929
+
930
+ **analyze_form.py**: Extract all form fields from PDF
931
+
932
+ ```bash
933
+ python scripts/analyze_form.py input.pdf > fields.json
934
+ ```
935
+
936
+ Output format:
937
+ ```json
938
+ {
939
+ "field_name": {"type": "text", "x": 100, "y": 200},
940
+ "signature": {"type": "sig", "x": 150, "y": 500}
941
+ }
942
+ ```
943
+
944
+ **validate_boxes.py**: Check for overlapping bounding boxes
945
+
946
+ ```bash
947
+ python scripts/validate_boxes.py fields.json
948
+ # Returns: "OK" or lists conflicts
949
+ ```
950
+
951
+ **fill_form.py**: Apply field values to PDF
952
+
953
+ ```bash
954
+ python scripts/fill_form.py input.pdf fields.json output.pdf
955
+ ```
956
+ ````
957
+
958
+ ### Use visual analysis
959
+
960
+ When inputs can be rendered as images, have Claude analyze them:
961
+
962
+ ````markdown theme={null}
963
+ ## Form layout analysis
964
+
965
+ 1. Convert PDF to images:
966
+ ```bash
967
+ python scripts/pdf_to_images.py form.pdf
968
+ ```
969
+
970
+ 2. Analyze each page image to identify form fields
971
+ 3. Claude can see field locations and types visually
972
+ ````
973
+
974
+ <Note>
975
+ In this example, you'd need to write the `pdf_to_images.py` script.
976
+ </Note>
977
+
978
+ Claude's vision capabilities help understand layouts and structures.
979
+
980
+ ### Create verifiable intermediate outputs
981
+
982
+ When Claude performs complex, open-ended tasks, it can make mistakes. The "plan-validate-execute" pattern catches errors early by having Claude first create a plan in a structured format, then validate that plan with a script before executing it.
983
+
984
+ **Example**: Imagine asking Claude to update 50 form fields in a PDF based on a spreadsheet. Without validation, Claude might reference non-existent fields, create conflicting values, miss required fields, or apply updates incorrectly.
985
+
986
+ **Solution**: Use the workflow pattern shown above (PDF form filling), but add an intermediate `changes.json` file that gets validated before applying changes. The workflow becomes: analyze → **create plan file** → **validate plan** → execute → verify.
987
+
988
+ **Why this pattern works:**
989
+
990
+ * **Catches errors early**: Validation finds problems before changes are applied
991
+ * **Machine-verifiable**: Scripts provide objective verification
992
+ * **Reversible planning**: Claude can iterate on the plan without touching originals
993
+ * **Clear debugging**: Error messages point to specific problems
994
+
995
+ **When to use**: Batch operations, destructive changes, complex validation rules, high-stakes operations.
996
+
997
+ **Implementation tip**: Make validation scripts verbose with specific error messages like "Field 'signature\_date' not found. Available fields: customer\_name, order\_total, signature\_date\_signed" to help Claude fix issues.
998
+
999
+ ### Package dependencies
1000
+
1001
+ Skills run in the code execution environment with platform-specific limitations:
1002
+
1003
+ * **claude.ai**: Can install packages from npm and PyPI and pull from GitHub repositories
1004
+ * **Anthropic API**: Has no network access and no runtime package installation
1005
+
1006
+ List required packages in your SKILL.md and verify they're available in the [code execution tool documentation](/en/docs/agents-and-tools/tool-use/code-execution-tool).
1007
+
1008
+ ### Runtime environment
1009
+
1010
+ Skills run in a code execution environment with filesystem access, bash commands, and code execution capabilities. For the conceptual explanation of this architecture, see [The Skills architecture](/en/docs/agents-and-tools/agent-skills/overview#the-skills-architecture) in the overview.
1011
+
1012
+ **How this affects your authoring:**
1013
+
1014
+ **How Claude accesses Skills:**
1015
+
1016
+ 1. **Metadata pre-loaded**: At startup, the name and description from all Skills' YAML frontmatter are loaded into the system prompt
1017
+ 2. **Files read on-demand**: Claude uses bash Read tools to access SKILL.md and other files from the filesystem when needed
1018
+ 3. **Scripts executed efficiently**: Utility scripts can be executed via bash without loading their full contents into context. Only the script's output consumes tokens
1019
+ 4. **No context penalty for large files**: Reference files, data, or documentation don't consume context tokens until actually read
1020
+
1021
+ * **File paths matter**: Claude navigates your skill directory like a filesystem. Use forward slashes (`reference/guide.md`), not backslashes
1022
+ * **Name files descriptively**: Use names that indicate content: `form_validation_rules.md`, not `doc2.md`
1023
+ * **Organize for discovery**: Structure directories by domain or feature
1024
+ * Good: `reference/finance.md`, `reference/sales.md`
1025
+ * Bad: `docs/file1.md`, `docs/file2.md`
1026
+ * **Bundle comprehensive resources**: Include complete API docs, extensive examples, large datasets; no context penalty until accessed
1027
+ * **Prefer scripts for deterministic operations**: Write `validate_form.py` rather than asking Claude to generate validation code
1028
+ * **Make execution intent clear**:
1029
+ * "Run `analyze_form.py` to extract fields" (execute)
1030
+ * "See `analyze_form.py` for the extraction algorithm" (read as reference)
1031
+ * **Test file access patterns**: Verify Claude can navigate your directory structure by testing with real requests
1032
+
1033
+ **Example:**
1034
+
1035
+ ```
1036
+ bigquery-skill/
1037
+ ├── SKILL.md (overview, points to reference files)
1038
+ └── reference/
1039
+ ├── finance.md (revenue metrics)
1040
+ ├── sales.md (pipeline data)
1041
+ └── product.md (usage analytics)
1042
+ ```
1043
+
1044
+ When the user asks about revenue, Claude reads SKILL.md, sees the reference to `reference/finance.md`, and invokes bash to read just that file. The sales.md and product.md files remain on the filesystem, consuming zero context tokens until needed. This filesystem-based model is what enables progressive disclosure. Claude can navigate and selectively load exactly what each task requires.
1045
+
1046
+ For complete details on the technical architecture, see [How Skills work](/en/docs/agents-and-tools/agent-skills/overview#how-skills-work) in the Skills overview.
1047
+
1048
+ ### MCP tool references
1049
+
1050
+ If your Skill uses MCP (Model Context Protocol) tools, always use fully qualified tool names to avoid "tool not found" errors.
1051
+
1052
+ **Format**: `ServerName:tool_name`
1053
+
1054
+ **Example**:
1055
+
1056
+ ```markdown theme={null}
1057
+ Use the BigQuery:bigquery_schema tool to retrieve table schemas.
1058
+ Use the GitHub:create_issue tool to create issues.
1059
+ ```
1060
+
1061
+ Where:
1062
+
1063
+ * `BigQuery` and `GitHub` are MCP server names
1064
+ * `bigquery_schema` and `create_issue` are the tool names within those servers
1065
+
1066
+ Without the server prefix, Claude may fail to locate the tool, especially when multiple MCP servers are available.
1067
+
1068
+ ### Avoid assuming tools are installed
1069
+
1070
+ Don't assume packages are available:
1071
+
1072
+ ````markdown theme={null}
1073
+ **Bad example: Assumes installation**:
1074
+ "Use the pdf library to process the file."
1075
+
1076
+ **Good example: Explicit about dependencies**:
1077
+ "Install required package: `pip install pypdf`
1078
+
1079
+ Then use it:
1080
+ ```python
1081
+ from pypdf import PdfReader
1082
+ reader = PdfReader("file.pdf")
1083
+ ```"
1084
+ ````
1085
+
1086
+ ## Technical notes
1087
+
1088
+ ### YAML frontmatter requirements
1089
+
1090
+ The SKILL.md frontmatter requires `name` (64 characters max) and `description` (1024 characters max) fields. See the [Skills overview](/en/docs/agents-and-tools/agent-skills/overview#skill-structure) for complete structure details.
1091
+
1092
+ ### Token budgets
1093
+
1094
+ Keep SKILL.md body under 500 lines for optimal performance. If your content exceeds this, split it into separate files using the progressive disclosure patterns described earlier. For architectural details, see the [Skills overview](/en/docs/agents-and-tools/agent-skills/overview#how-skills-work).
1095
+
1096
+ ## Checklist for effective Skills
1097
+
1098
+ Before sharing a Skill, verify:
1099
+
1100
+ ### Core quality
1101
+
1102
+ * [ ] Description is specific and includes key terms
1103
+ * [ ] Description includes both what the Skill does and when to use it
1104
+ * [ ] SKILL.md body is under 500 lines
1105
+ * [ ] Additional details are in separate files (if needed)
1106
+ * [ ] No time-sensitive information (or in "old patterns" section)
1107
+ * [ ] Consistent terminology throughout
1108
+ * [ ] Examples are concrete, not abstract
1109
+ * [ ] File references are one level deep
1110
+ * [ ] Progressive disclosure used appropriately
1111
+ * [ ] Workflows have clear steps
1112
+
1113
+ ### Code and scripts
1114
+
1115
+ * [ ] Scripts solve problems rather than punt to Claude
1116
+ * [ ] Error handling is explicit and helpful
1117
+ * [ ] No "voodoo constants" (all values justified)
1118
+ * [ ] Required packages listed in instructions and verified as available
1119
+ * [ ] Scripts have clear documentation
1120
+ * [ ] No Windows-style paths (all forward slashes)
1121
+ * [ ] Validation/verification steps for critical operations
1122
+ * [ ] Feedback loops included for quality-critical tasks
1123
+
1124
+ ### Testing
1125
+
1126
+ * [ ] At least three evaluations created
1127
+ * [ ] Tested with Haiku, Sonnet, and Opus
1128
+ * [ ] Tested with real usage scenarios
1129
+ * [ ] Team feedback incorporated (if applicable)
1130
+