GuidesSkills

Writing Skills

Learn how to write effective Skills that extend your AI agent's capabilities.

A well-written Skill provides clear instructions and resources that help your AI agent accomplish specialized tasks. This guide covers best practices for creating Skills that are effective, maintainable, and efficient.

Skill Components

Every Skill consists of:

  1. SKILL.md (required) - The manifest file with metadata and instructions
  2. Scripts (optional) - Helper code the agent can execute
  3. References (optional) - Additional documentation and templates
  4. Dependencies (optional) - Runtime packages via requirements.txt or package.json

Progressive Disclosure

Skills follow a progressive disclosure model to minimize context usage:

Level 1: Name + Description (~100 tokens)
    ↓ (triggered by user request)
Level 2: SKILL.md content
    ↓ (as needed)
Level 3: Scripts, references, templates

Design Principles

  • Keep SKILL.md focused - Main instructions only; move deep dives to separate files
  • Reference, don't inline - Link to scripts and resources rather than embedding them
  • Load on demand - The agent reads additional files only when needed
my-skill/
├── SKILL.md              # Required: Manifest and main instructions
├── requirements.txt      # Optional: Python dependencies
├── package.json          # Optional: Node.js dependencies
├── scripts/
│   ├── process.py        # Helper scripts
│   └── utils.js
├── reference/
│   ├── api-guide.md      # Detailed documentation
│   └── examples.md
└── templates/
    └── output.hbs        # Output templates

Writing SKILL.md

Frontmatter

Every SKILL.md must start with YAML frontmatter:

---
name: pdf-processing
description: Extract text, tables, and images from PDF files. Use when working with PDF documents or converting PDFs to other formats.
---

Content Sections

Structure your SKILL.md with clear sections:

---
name: pdf-processing
description: Extract text, tables, and images from PDF files.
---

# PDF Processing

## Quick Start

Use this skill when the user needs to:

- Extract text from PDF documents
- Convert PDF tables to structured data
- Extract images from PDFs

## Usage

To extract text from a PDF:

```python
python /skills/pdf-processing/scripts/extract.py input.pdf
```

Scripts

  • scripts/extract.py - Main extraction script
  • scripts/tables.py - Table extraction utility

References

For complex PDFs with forms, see reference/forms.md.


### Best Practices for SKILL.md

1. **Start with purpose** - Clearly state what the Skill does and when to use it
2. **Provide quick examples** - Show the most common usage patterns first
3. **Reference scripts** - Point to helper scripts rather than inlining code
4. **Keep it under 500 lines** - Split longer content into reference files
5. **Use clear headings** - Help the agent navigate to relevant sections

## Writing Scripts

### Script Guidelines

- **Make scripts executable** - Include shebang and proper permissions
- **Accept arguments** - Use command-line arguments for flexibility
- **Output clearly** - Print results in a parseable format
- **Handle errors** - Provide meaningful error messages

### Example Python Script

```python
#!/usr/bin/env python3
"""Extract text from PDF files."""

import sys
import pdfplumber

def extract_text(pdf_path):
    """Extract all text from a PDF file."""
    with pdfplumber.open(pdf_path) as pdf:
        text = ""
        for page in pdf.pages:
            text += page.extract_text() or ""
            text += "\n\n"
    return text.strip()

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: extract.py <pdf_path>", file=sys.stderr)
        sys.exit(1)

    pdf_path = sys.argv[1]
    try:
        result = extract_text(pdf_path)
        print(result)
    except Exception as e:
        print(f"Error: {e}", file=sys.stderr)
        sys.exit(1)

Script Location

Place scripts in a scripts/ directory and reference them by path:

## Usage

Run the extraction script:

```bash
python /skills/pdf-processing/scripts/extract.py document.pdf
```

## Reference Files

Use reference files for:

- Detailed API documentation
- Complex examples
- Domain-specific guides
- Configuration templates

### Linking References

Reference additional files from SKILL.md:

```md
## Advanced Usage

For handling encrypted PDFs, see `reference/encryption.md`.

For batch processing multiple files, see `reference/batch-processing.md`.

Naming Conventions

Skill Names

  • Use lowercase letters, numbers, and hyphens
  • Maximum 64 characters
  • Cannot start or end with a hyphen
  • Avoid reserved names: anthropic, claude, bluebag

Good names:

  • pdf-processing
  • data-analysis-v2
  • customer-sentiment

Bad names:

  • PDF_Processing (uppercase, underscore)
  • -my-skill (starts with hyphen)
  • my-skill- (ends with hyphen)

File Names

  • Use lowercase with hyphens or underscores
  • Include appropriate extensions
  • Be descriptive but concise

Testing Skills

Before uploading, test your Skill locally:

  1. Verify SKILL.md parses - Check frontmatter syntax
  2. Run scripts - Ensure they execute without errors
  3. Check dependencies - Verify all imports are available
  4. Test edge cases - Handle missing files, invalid input

Common Patterns

Workflow Skills

For multi-step processes:

## Workflow

1. **Validate Input** - Check file format and size
2. **Process** - Run the main transformation
3. **Validate Output** - Verify results
4. **Return** - Provide the final output

### Step 1: Validate Input

```python
python /skills/my-skill/scripts/validate.py input.pdf
```

Step 2: Process

...


### Template Skills

For generating structured output:

```md
## Templates

Use the Handlebars template in `templates/report.hbs`:

```python
python /skills/my-skill/scripts/generate.py --template templates/report.hbs --data input.json

### Reference Skills

For domain expertise:

```md
## Domain Knowledge

This skill provides expertise in financial reporting. Key references:

- `reference/gaap-rules.md` - GAAP compliance guidelines
- `reference/formats.md` - Standard report formats
- `reference/examples/` - Sample reports

Next Steps

On this page