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