Skip to content

majiayu000/spellbook / skills/skill-creator

skill-creator

Verified

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, update or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.

FileKindSize
LICENSE.txtmarkdown11.1 KB
SKILL.mdskill md33.1 KB
agents/analyzer.mdmarkdown10.1 KB
agents/comparator.mdmarkdown7.1 KB
agents/grader.mdmarkdown8.8 KB
assets/eval_review.htmlother6.9 KB
eval-viewer/generate_review.pyscript16.0 KB
eval-viewer/viewer.htmlother44.0 KB
references/quality-playbook.mdmarkdown2.9 KB
references/schemas.mdmarkdown13.0 KB
requirements.txtmanifest17 B
scripts/aggregate_benchmark.pyexecutablescript15.0 KB
scripts/generate_report.pyexecutablescript12.5 KB
scripts/improve_description.pyexecutablescript10.5 KB
scripts/package_skill.pyexecutablescript5.9 KB
scripts/path_safety.pyscript3.2 KB
scripts/quick_validate.pyexecutablescript5.8 KB
scripts/run_eval.pyexecutablescript11.9 KB
scripts/run_loop.pyexecutablescript13.4 KB
scripts/utils.pyscript1.6 KB

scripts/quick_validate.py

View on GitHub
#!/usr/bin/env python3
"""
Quick validation script for skills - minimal version
"""

import sys
import os
import re
import yaml
from pathlib import Path

COMPATIBILITY_KEYS = {'runtimes'}
RUNTIME_IDS = {'claude_code', 'codex', 'portable'}
UNSPECIFIED_RUNTIME = 'unspecified'

def validate_compatibility(frontmatter):
    """Validate optional runtime compatibility metadata."""
    compatibility = frontmatter.get('compatibility')
    metadata = frontmatter.get('metadata', {})
    if not isinstance(metadata, dict):
        return 'Metadata must be a YAML mapping'
    declared = 'spellbook-runtimes' in metadata
    if isinstance(compatibility, dict):
        # Legacy Spellbook mapping; new skills use the standard string field.
        if declared:
            return "Runtimes are declared in both compatibility and metadata"
        unexpected_keys = {str(key) for key in compatibility if key not in COMPATIBILITY_KEYS}
        if unexpected_keys:
            return f"Unexpected compatibility key(s): {', '.join(sorted(unexpected_keys))}"
        runtimes = compatibility.get('runtimes')
        if not isinstance(runtimes, list) or not runtimes:
            return "Compatibility runtimes must be a non-empty list"
    else:
        if 'compatibility' in frontmatter and (
            not isinstance(compatibility, str) or not compatibility.strip() or len(compatibility) > 500
        ):
            return "Compatibility must be a non-empty string of at most 500 characters"
        if not declared:
            return None
        value = metadata['spellbook-runtimes']
        if not isinstance(value, str) or not value.strip():
            return "metadata.spellbook-runtimes must be a non-empty string"
        runtimes = value.split()
    seen = set()
    for runtime in runtimes:
        if not isinstance(runtime, str) or runtime != runtime.strip() or not runtime:
            return "Compatibility runtimes must contain only non-empty strings"
        if runtime == UNSPECIFIED_RUNTIME:
            return "Compatibility must not declare unspecified; omit runtime metadata instead"
        if runtime not in RUNTIME_IDS:
            return f"Unsupported compatibility runtime '{runtime}'. Allowed runtimes: {', '.join(sorted(RUNTIME_IDS))}"
        if runtime in seen:
            return f"Duplicate compatibility runtime '{runtime}'"
        seen.add(runtime)
    return None

def validate_skill(skill_path):
    """Basic validation of a skill"""
    skill_path = Path(skill_path)

    # Check SKILL.md exists
    skill_md = skill_path / 'SKILL.md'
    if not skill_md.exists():
        return False, "SKILL.md not found"

    # Read and validate frontmatter
    content = skill_md.read_text()
    if not content.startswith('---'):
        return False, "No YAML frontmatter found"

    # Extract frontmatter
    match = re.match(r'^---\n(.*?)\n---', content, re.DOTALL)
    if not match:
        return False, "Invalid frontmatter format"

    frontmatter_text = match.group(1)

    # Parse YAML frontmatter
    try:
        frontmatter = yaml.safe_load(frontmatter_text)
        if not isinstance(frontmatter, dict):
            return False, "Frontmatter must be a YAML dictionary"
    except yaml.YAMLError as e:
        return False, f"Invalid YAML in frontmatter: {e}"

    # Define allowed properties
    ALLOWED_PROPERTIES = {'name', 'description', 'license', 'allowed-tools', 'metadata', 'compatibility'}

    # Check for unexpected properties (excluding nested keys under metadata)
    unexpected_keys = set(frontmatter.keys()) - ALLOWED_PROPERTIES
    if unexpected_keys:
        return False, (
            f"Unexpected key(s) in SKILL.md frontmatter: {', '.join(sorted(unexpected_keys))}. "
            f"Allowed properties are: {', '.join(sorted(ALLOWED_PROPERTIES))}"
        )

    # Check required fields
    if 'name' not in frontmatter:
        return False, "Missing 'name' in frontmatter"
    if 'description' not in frontmatter:
        return False, "Missing 'description' in frontmatter"

    # Extract name for validation
    name = frontmatter.get('name', '')
    if not isinstance(name, str):
        return False, f"Name must be a string, got {type(name).__name__}"
    name = name.strip()
    if name:
        # Check naming convention (kebab-case: lowercase with hyphens)
        if not re.match(r'^[a-z0-9-]+$', name):
            return False, f"Name '{name}' should be kebab-case (lowercase letters, digits, and hyphens only)"
        if name.startswith('-') or name.endswith('-') or '--' in name:
            return False, f"Name '{name}' cannot start/end with hyphen or contain consecutive hyphens"
        # Check name length (max 64 characters per spec)
        if len(name) > 64:
            return False, f"Name is too long ({len(name)} characters). Maximum is 64 characters."

    # Extract and validate description
    description = frontmatter.get('description', '')
    if not isinstance(description, str):
        return False, f"Description must be a string, got {type(description).__name__}"
    description = description.strip()
    if description:
        # Check for angle brackets
        if '<' in description or '>' in description:
            return False, "Description cannot contain angle brackets (< or >)"
        # Check description length (max 1024 characters per spec)
        if len(description) > 1024:
            return False, f"Description is too long ({len(description)} characters). Maximum is 1024 characters."

    # Validate compatibility field if present (optional)
    compatibility_error = validate_compatibility(frontmatter)
    if compatibility_error:
        return False, compatibility_error

    return True, "Skill is valid!"

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage: python quick_validate.py <skill_directory>")
        sys.exit(1)
    
    valid, message = validate_skill(sys.argv[1])
    print(message)
    sys.exit(0 if valid else 1)
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall