Browse Source

feat(skills): Enhance skill-creator with official docs and best practices

- Add official Anthropic documentation links (GitHub, support docs, PDF guide)
- Create references/workflows.md (212 lines):
  - Sequential workflows and conditional logic patterns
  - Subagent delegation patterns (Boris Cherny tips)
  - ASCII diagram usage for understanding protocols/codebases
  - Error handling, state machines, and checklist patterns
- Create references/output-patterns.md (342 lines):
  - Template-based generation patterns
  - Quality criteria and iterative refinement
  - Visual representations and annotated examples
  - Constraint-driven formats
- Add pro tips: use subagents for compute, keep context clean, visualize complexity
- Reference Agent Skills open standard (agentskills.io)

Total additions: 554 lines of proven design patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
0xDarkMatter 2 months ago
parent
commit
b1b8280dbc

+ 18 - 3
skills/skill-creator/SKILL.md

@@ -15,6 +15,13 @@ specialized knowledge, workflows, and tools. Think of them as "onboarding guides
 domains or tasks—they transform Claude from a general-purpose agent into a specialized agent
 equipped with procedural knowledge that no model can fully possess.
 
+**Official Anthropic Resources:**
+- [Agent Skills GitHub Repository](https://github.com/anthropics/skills) - Official examples and specification
+- [Creating Custom Skills](https://support.claude.com/en/articles/12512198-creating-custom-skills) - Step-by-step guide
+- [What are Skills?](https://support.claude.com/en/articles/12512176-what-are-skills) - Overview and concepts
+- [The Complete Guide to Building Skills for Claude](https://resources.anthropic.com/hubfs/The-Complete-Guide-to-Building-Skill-for-Claude.pdf) - Comprehensive PDF guide
+- [Agent Skills Standard](http://agentskills.io) - Open standard specification
+
 ### What Skills Provide
 
 1. Specialized workflows - Multi-step procedures for specific domains
@@ -284,11 +291,17 @@ When editing the (newly-generated or existing) skill, remember that the skill is
 
 Consult these helpful guides based on your skill's needs:
 
-- **Multi-step processes**: See references/workflows.md for sequential workflows and conditional logic
-- **Specific output formats or quality standards**: See references/output-patterns.md for template and example patterns
+- **Multi-step processes**: See [references/workflows.md](references/workflows.md) for sequential workflows, conditional logic, and subagent delegation patterns
+- **Specific output formats or quality standards**: See [references/output-patterns.md](references/output-patterns.md) for template and example patterns
+- **Official examples**: Browse [Anthropic's skills repository](https://github.com/anthropics/skills/tree/main/skills) for production-ready examples
 
 These files contain established best practices for effective skill design.
 
+**Pro tips for complex tasks:**
+- **Use subagents** - Append "use subagents" to requests needing heavy computation or parallel exploration
+- **Keep context clean** - Offload individual subtasks to subagents to prevent context window pollution
+- **Visualize complexity** - Ask Claude to draw ASCII diagrams of new protocols and codebases for better understanding
+
 #### Start with Reusable Skill Contents
 
 To begin implementation, start with the reusable resources identified above: `scripts/`, `references/`, and `assets/` files. Note that this step may require user input. For example, when implementing a `brand-guidelines` skill, the user may need to provide brand assets or templates to store in `assets/`, or documentation to store in `references/`.
@@ -319,7 +332,9 @@ Write instructions for using the skill and its bundled resources.
 
 ### Step 5: Packaging a Skill
 
-Once development of the skill is complete, it must be packaged into a distributable .skill file that gets shared with the user. The packaging process automatically validates the skill first to ensure it meets all requirements:
+Once development of the skill is complete, it must be packaged into a distributable .skill file that gets shared with the user. Skills follow the [Agent Skills open standard](http://agentskills.io) for portability across AI platforms.
+
+The packaging process automatically validates the skill first to ensure it meets all requirements:
 
 ```bash
 scripts/package_skill.py <path/to/skill-folder>

+ 342 - 0
skills/skill-creator/references/output-patterns.md

@@ -0,0 +1,342 @@
+# Output Patterns for Skills
+
+Effective patterns for achieving specific output formats and quality standards.
+
+## Template-Based Generation
+
+Provide templates with clear placeholders:
+
+```markdown
+## Output Template
+
+Use this structure for all responses:
+
+\`\`\`
+# {TITLE}
+
+## Summary
+{BRIEF_OVERVIEW}
+
+## Details
+{COMPREHENSIVE_EXPLANATION}
+
+## Examples
+{CODE_OR_USAGE_EXAMPLES}
+
+## References
+- {LINK_1}
+- {LINK_2}
+\`\`\`
+
+**Placeholder guidelines:**
+- {TITLE}: 5-8 words, action-oriented
+- {BRIEF_OVERVIEW}: 1-2 sentences maximum
+- {COMPREHENSIVE_EXPLANATION}: Structured with headers
+- {CODE_OR_USAGE_EXAMPLES}: 2-3 concrete examples
+```
+
+**When to use:** Consistent formatting across outputs, standardized reports, documented APIs.
+
+## Example-Driven Specification
+
+Show, don't tell:
+
+```markdown
+## Expected Output Format
+
+**Good examples:**
+
+\`\`\`json
+{
+  "status": "success",
+  "data": {
+    "items": [...],
+    "count": 42
+  }
+}
+\`\`\`
+
+**Bad examples to avoid:**
+
+\`\`\`json
+{
+  "result": true  // Too vague, missing data
+}
+\`\`\`
+
+**Key principles:**
+- Always include status field
+- Nest data under "data" key
+- Include count for arrays
+```
+
+**When to use:** API responses, structured data, format specifications.
+
+## Quality Criteria
+
+Define measurable standards:
+
+```markdown
+## Output Requirements
+
+Generated code must:
+1. **Type Safety** - Pass TypeScript strict mode without any errors
+2. **Test Coverage** - Include unit tests for all public functions (>80% coverage)
+3. **Documentation** - JSDoc comments on all exported items
+4. **Error Handling** - Try-catch blocks for all async operations
+5. **Linting** - Pass ESLint with zero warnings
+
+Verify each requirement before finalizing output.
+```
+
+**When to use:** Code generation, document creation, quality-sensitive deliverables.
+
+## Iterative Refinement with Feedback
+
+Build in review cycles:
+
+```markdown
+## Generation Process
+
+1. **Generate initial version**
+   - Focus on structure and completeness
+   - Don't over-optimize yet
+
+2. **Self-review against criteria**
+   - Check each requirement explicitly
+   - Note specific gaps
+
+3. **Revise targeted weaknesses**
+   - Fix identified issues
+   - Don't change working sections
+
+4. **Final verification**
+   - Confirm all criteria met
+   - Present completed output
+```
+
+**When to use:** Complex outputs, high standards, multi-faceted requirements.
+
+## Layered Verbosity
+
+Offer multiple detail levels:
+
+```markdown
+## Output Structure
+
+### Executive Summary (2-3 sentences)
+[High-level overview]
+
+### Key Points (bullets)
+- Point 1
+- Point 2
+- Point 3
+
+### Detailed Analysis (optional, expand on request)
+[Comprehensive explanation with examples]
+
+### Technical Appendix (optional, expand on request)
+[Implementation details, edge cases, references]
+```
+
+**When to use:** Reports, explanations, documentation where audience needs vary.
+
+## Before/After Comparison
+
+Show transformation clearly:
+
+```markdown
+## Changes Made
+
+**Before:**
+\`\`\`python
+def process(data):
+    result = data * 2
+    return result
+\`\`\`
+
+**After:**
+\`\`\`python
+def process(data: list[int]) -> list[int]:
+    """Double all values in the input list.
+
+    Args:
+        data: List of integers to process
+
+    Returns:
+        New list with all values doubled
+    """
+    return [x * 2 for x in data]
+\`\`\`
+
+**Improvements:**
+- Added type hints
+- Added comprehensive docstring
+- Used list comprehension for efficiency
+```
+
+**When to use:** Code refactoring, document editing, migration guides.
+
+## Structured Alternatives
+
+Present options systematically:
+
+```markdown
+## Approach Options
+
+### Option A: [Name]
+**Pros:**
+- Benefit 1
+- Benefit 2
+
+**Cons:**
+- Drawback 1
+- Drawback 2
+
+**Best for:** [Use case]
+
+### Option B: [Name]
+**Pros:**
+- Benefit 1
+- Benefit 2
+
+**Cons:**
+- Drawback 1
+- Drawback 2
+
+**Best for:** [Use case]
+
+**Recommendation:** [Choice with rationale]
+```
+
+**When to use:** Design decisions, technology selection, strategy proposals.
+
+## Incremental Disclosure
+
+Start simple, expand on request:
+
+```markdown
+## Basic Usage
+
+\`\`\`python
+result = process_data(input_file)
+\`\`\`
+
+---
+
+<details>
+<summary>Advanced Options</summary>
+
+\`\`\`python
+result = process_data(
+    input_file,
+    format="json",
+    validate=True,
+    timeout=30
+)
+\`\`\`
+
+**Parameters:**
+- `format`: Output format (json/csv/xml)
+- `validate`: Run validation checks
+- `timeout`: Max processing time in seconds
+</details>
+
+---
+
+<details>
+<summary>Complete API Reference</summary>
+
+[Exhaustive documentation]
+</details>
+```
+
+**When to use:** API documentation, tutorials, learning materials.
+
+## Visual Representations
+
+Use ASCII diagrams for clarity:
+
+```markdown
+## System Architecture
+
+\`\`\`
+┌──────────────┐
+│   Frontend   │
+└──────┬───────┘
+       │
+       │ REST API
+       │
+┌──────▼───────┐      ┌─────────────┐
+│   Backend    │─────>│  Database   │
+└──────────────┘      └─────────────┘
+       │
+       │ Events
+       │
+┌──────▼───────┐
+│ Message Queue│
+└──────────────┘
+\`\`\`
+
+**Flow:**
+1. Frontend sends HTTP requests
+2. Backend processes and queries database
+3. Backend publishes events to queue
+4. Workers consume queue messages
+```
+
+**When to use:** Architecture documentation, data flow explanation, protocol visualization.
+
+## Annotated Examples
+
+Explain while showing:
+
+```markdown
+## Implementation
+
+\`\`\`python
+# Initialize connection with retry logic
+connection = connect_db(
+    host="localhost",     # Database server address
+    retry_count=3,        # Attempt connection 3 times
+    timeout=5             # 5 second timeout per attempt
+)
+
+# Execute query with parameter binding (prevents SQL injection)
+results = connection.query(
+    "SELECT * FROM users WHERE status = ?",
+    params=["active"]     # Safe parameterized query
+)
+
+# Process results lazily to conserve memory
+for row in results:     # Iterator pattern - doesn't load all at once
+    process_user(row)
+\`\`\`
+```
+
+**When to use:** Code examples, tutorials, onboarding materials.
+
+## Constraint-Driven Format
+
+Specify hard limits:
+
+```markdown
+## Output Constraints
+
+**Length:**
+- Title: Max 60 characters
+- Summary: 100-150 words
+- Body: 500-1000 words
+
+**Structure:**
+- Exactly 3 main sections
+- 2-4 bullet points per section
+- 1 code example per section
+
+**Tone:**
+- Professional but conversational
+- Active voice preferred
+- Technical accuracy paramount
+```
+
+**When to use:** Content creation, marketing copy, technical writing with space constraints.

+ 212 - 0
skills/skill-creator/references/workflows.md

@@ -0,0 +1,212 @@
+# Workflow Patterns for Skills
+
+Effective patterns for designing multi-step processes and conditional logic in skills.
+
+## Sequential Workflows
+
+For tasks that follow a clear sequence, use numbered steps with verification checkpoints:
+
+```markdown
+## Workflow
+
+1. **Validate inputs**
+   - Check required parameters exist
+   - Verify file formats are correct
+   - Exit early if validation fails
+
+2. **Prepare environment**
+   - Create working directory
+   - Load required dependencies
+   - Set configuration values
+
+3. **Execute main task**
+   - [Primary operation here]
+   - Log progress at key milestones
+
+4. **Verify results**
+   - Check output exists and is valid
+   - Compare against expected format
+   - Run validation tests
+
+5. **Clean up**
+   - Remove temporary files
+   - Close connections
+   - Report completion status
+```
+
+**When to use:** Tasks with clear dependencies where each step must complete before the next can begin.
+
+## Conditional Logic
+
+For workflows that branch based on context, use decision trees:
+
+```markdown
+## Decision Flow
+
+1. Analyze the request
+2. Choose approach based on criteria:
+
+   **If [condition A]:**
+   - Follow path A
+   - Use tool X
+   - Apply settings Y
+
+   **If [condition B]:**
+   - Follow path B
+   - Use tool Z
+   - Apply settings W
+
+   **Otherwise:**
+   - Use default approach
+```
+
+**When to use:** When different scenarios require different handling strategies.
+
+## Iterative Refinement
+
+For tasks that improve through iteration:
+
+```markdown
+## Iterative Process
+
+1. Generate initial draft
+2. Review against criteria
+3. While quality threshold not met:
+   - Identify specific weaknesses
+   - Apply targeted improvements
+   - Re-evaluate
+4. Finalize when acceptable
+```
+
+**When to use:** Creative tasks, optimization problems, or quality-sensitive outputs.
+
+## Parallel Execution
+
+For independent tasks that can run concurrently:
+
+```markdown
+## Parallel Tasks
+
+Execute these steps simultaneously:
+
+- **Task A:** [Description]
+- **Task B:** [Description]
+- **Task C:** [Description]
+
+Then combine results:
+- [Integration logic]
+```
+
+**When to use:** When tasks have no dependencies and can benefit from concurrent execution.
+
+## Error Handling
+
+Build resilience into workflows:
+
+```markdown
+## Error Recovery
+
+For each critical step:
+
+1. Attempt operation
+2. If failure occurs:
+   - Log specific error
+   - Try fallback approach if available
+   - Otherwise, exit gracefully with clear error message
+3. Continue to next step only on success
+```
+
+**Best practice:** Always provide actionable error messages that explain what went wrong and how to fix it.
+
+## Subagent Delegation Patterns
+
+**Use subagents for:**
+
+1. **Heavy computation** - Append "use subagents" to requests needing more compute
+2. **Context isolation** - Offload individual tasks to keep main agent's context clean
+3. **Parallel exploration** - Split research across multiple agents
+4. **Specialized expertise** - Route domain-specific subtasks to expert agents
+
+```markdown
+## Subagent Workflow
+
+1. Identify subtasks that can be delegated
+2. For each subtask:
+   - Spawn subagent with clear objective
+   - Provide minimal necessary context
+   - Collect results
+3. Synthesize findings in main context
+```
+
+**Benefits:**
+- Keeps main agent focused on coordination
+- Allows throwing more compute at complex problems
+- Prevents context pollution from exploratory work
+
+## ASCII Diagrams for Understanding
+
+When working with new protocols or codebases, request ASCII diagrams:
+
+```markdown
+## Request Format
+
+"Draw an ASCII diagram showing:
+- [System component relationships]
+- [Data flow between modules]
+- [Protocol message sequence]"
+```
+
+**Example output:**
+```
+┌─────────────┐      ┌──────────────┐
+│   Client    │─────>│   API Server │
+└─────────────┘      └──────────────┘
+       │                     │
+       │  HTTP Request       │
+       │                     │
+       │  JSON Response      │
+       │<────────────────────│
+```
+
+**When to use:** Onboarding to new systems, documenting architecture, clarifying complex interactions.
+
+## Checklist Pattern
+
+For comprehensive coverage:
+
+```markdown
+## Pre-flight Checklist
+
+Before proceeding, verify:
+- [ ] Dependencies installed
+- [ ] Configuration valid
+- [ ] Test data available
+- [ ] Permissions granted
+- [ ] Output directory writable
+```
+
+**When to use:** Setup procedures, validation steps, quality gates.
+
+## State Machine Pattern
+
+For workflows with multiple modes:
+
+```markdown
+## State Transitions
+
+Current state determines available actions:
+
+**State: INITIALIZED**
+→ Can transition to: PROCESSING, ERROR
+→ Actions: validate, start
+
+**State: PROCESSING**
+→ Can transition to: COMPLETED, ERROR
+→ Actions: process_batch, check_progress
+
+**State: COMPLETED**
+→ Can transition to: INITIALIZED (reset)
+→ Actions: export_results, cleanup
+```
+
+**When to use:** Complex workflows with distinct phases and clear transition conditions.