Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Create, test, and iteratively improve Claude skills with eval benchmarks and description optimization
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/quick_validate.py
1#!/usr/bin/env python32"""3Quick validation script for skills - minimal version4"""56import sys7import os8import re9import yaml10from pathlib import Path1112def validate_skill(skill_path):13"""Basic validation of a skill"""14skill_path = Path(skill_path)1516# Check SKILL.md exists17skill_md = skill_path / 'SKILL.md'18if not skill_md.exists():19return False, "SKILL.md not found"2021# Read and validate frontmatter22content = skill_md.read_text()23if not content.startswith('---'):24return False, "No YAML frontmatter found"2526# Extract frontmatter27match = re.match(r'^---\n(.*?)\n---', content, re.DOTALL)28if not match:29return False, "Invalid frontmatter format"3031frontmatter_text = match.group(1)3233# Parse YAML frontmatter34try:35frontmatter = yaml.safe_load(frontmatter_text)36if not isinstance(frontmatter, dict):37return False, "Frontmatter must be a YAML dictionary"38except yaml.YAMLError as e:39return False, f"Invalid YAML in frontmatter: {e}"4041# Define allowed properties42ALLOWED_PROPERTIES = {'name', 'description', 'license', 'allowed-tools', 'metadata', 'compatibility'}4344# Check for unexpected properties (excluding nested keys under metadata)45unexpected_keys = set(frontmatter.keys()) - ALLOWED_PROPERTIES46if unexpected_keys:47return False, (48f"Unexpected key(s) in SKILL.md frontmatter: {', '.join(sorted(unexpected_keys))}. "49f"Allowed properties are: {', '.join(sorted(ALLOWED_PROPERTIES))}"50)5152# Check required fields53if 'name' not in frontmatter:54return False, "Missing 'name' in frontmatter"55if 'description' not in frontmatter:56return False, "Missing 'description' in frontmatter"5758# Extract name for validation59name = frontmatter.get('name', '')60if not isinstance(name, str):61return False, f"Name must be a string, got {type(name).__name__}"62name = name.strip()63if name:64# Check naming convention (kebab-case: lowercase with hyphens)65if not re.match(r'^[a-z0-9-]+$', name):66return False, f"Name '{name}' should be kebab-case (lowercase letters, digits, and hyphens only)"67if name.startswith('-') or name.endswith('-') or '--' in name:68return False, f"Name '{name}' cannot start/end with hyphen or contain consecutive hyphens"69# Check name length (max 64 characters per spec)70if len(name) > 64:71return False, f"Name is too long ({len(name)} characters). Maximum is 64 characters."7273# Extract and validate description74description = frontmatter.get('description', '')75if not isinstance(description, str):76return False, f"Description must be a string, got {type(description).__name__}"77description = description.strip()78if description:79# Check for angle brackets80if '<' in description or '>' in description:81return False, "Description cannot contain angle brackets (< or >)"82# Check description length (max 1024 characters per spec)83if len(description) > 1024:84return False, f"Description is too long ({len(description)} characters). Maximum is 1024 characters."8586# Validate compatibility field if present (optional)87compatibility = frontmatter.get('compatibility', '')88if compatibility:89if not isinstance(compatibility, str):90return False, f"Compatibility must be a string, got {type(compatibility).__name__}"91if len(compatibility) > 500:92return False, f"Compatibility is too long ({len(compatibility)} characters). Maximum is 500 characters."9394return True, "Skill is valid!"9596if __name__ == "__main__":97if len(sys.argv) != 2:98print("Usage: python quick_validate.py <skill_directory>")99sys.exit(1)100101valid, message = validate_skill(sys.argv[1])102print(message)103sys.exit(0 if valid else 1)