|
| 1 | +name: Validate Skills |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'project/.claude/skills/**' |
| 7 | + - 'plugin/skills/**' |
| 8 | + - 'scripts/validate_skills.sh' |
| 9 | + pull_request: |
| 10 | + paths: |
| 11 | + - 'project/.claude/skills/**' |
| 12 | + - 'plugin/skills/**' |
| 13 | + - 'scripts/validate_skills.sh' |
| 14 | + |
| 15 | +jobs: |
| 16 | + validate: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: '3.x' |
| 26 | + |
| 27 | + - name: Install PyYAML |
| 28 | + run: pip install pyyaml |
| 29 | + |
| 30 | + - name: Validate SKILL.md files |
| 31 | + run: ./scripts/validate_skills.sh |
| 32 | + |
| 33 | + - name: Check YAML syntax (additional verification) |
| 34 | + run: | |
| 35 | + for skill in $(find . -name "SKILL.md" -path "*/skills/*"); do |
| 36 | + echo "Checking $skill..." |
| 37 | + python3 << PYEOF |
| 38 | +import yaml |
| 39 | +import sys |
| 40 | + |
| 41 | +with open('$skill', 'r') as f: |
| 42 | + content = f.read() |
| 43 | + |
| 44 | +lines = content.split('\n') |
| 45 | +if lines[0] != '---': |
| 46 | + print(f"Error: {sys.argv[0]} - No YAML frontmatter") |
| 47 | + sys.exit(1) |
| 48 | + |
| 49 | +end_idx = -1 |
| 50 | +for i, line in enumerate(lines[1:], 1): |
| 51 | + if line == '---': |
| 52 | + end_idx = i |
| 53 | + break |
| 54 | + |
| 55 | +if end_idx == -1: |
| 56 | + print(f"Error: No closing frontmatter delimiter") |
| 57 | + sys.exit(1) |
| 58 | + |
| 59 | +frontmatter = '\n'.join(lines[1:end_idx]) |
| 60 | +try: |
| 61 | + data = yaml.safe_load(frontmatter) |
| 62 | + if not data.get('name'): |
| 63 | + print(f"Error: Missing 'name' field") |
| 64 | + sys.exit(1) |
| 65 | + if not data.get('description'): |
| 66 | + print(f"Error: Missing 'description' field") |
| 67 | + sys.exit(1) |
| 68 | + print(f"Valid: {data.get('name')}") |
| 69 | +except yaml.YAMLError as e: |
| 70 | + print(f"YAML Error: {e}") |
| 71 | + sys.exit(1) |
| 72 | +PYEOF |
| 73 | + done |
| 74 | + echo "All SKILL.md files are valid!" |
| 75 | + |
| 76 | + - name: Check description length |
| 77 | + run: | |
| 78 | + failed=0 |
| 79 | + for skill in $(find . -name "SKILL.md" -path "*/skills/*"); do |
| 80 | + python3 << PYEOF |
| 81 | +import sys |
| 82 | + |
| 83 | +with open('$skill', 'r') as f: |
| 84 | + content = f.read() |
| 85 | + |
| 86 | +lines = content.split('\n') |
| 87 | +for line in lines[1:]: |
| 88 | + if line == '---': |
| 89 | + break |
| 90 | + if line.startswith('description:'): |
| 91 | + desc = line[12:].strip() |
| 92 | + if len(desc) > 1024: |
| 93 | + print(f"Error: $skill description exceeds 1024 characters ({len(desc)})") |
| 94 | + sys.exit(1) |
| 95 | + break |
| 96 | +PYEOF |
| 97 | + if [ $? -ne 0 ]; then |
| 98 | + failed=1 |
| 99 | + fi |
| 100 | + done |
| 101 | + if [ $failed -eq 1 ]; then |
| 102 | + echo "Some SKILL.md files have description length issues" |
| 103 | + exit 1 |
| 104 | + fi |
| 105 | + echo "All descriptions are within limits!" |
| 106 | + |
| 107 | + - name: Check name format |
| 108 | + run: | |
| 109 | + failed=0 |
| 110 | + for skill in $(find . -name "SKILL.md" -path "*/skills/*"); do |
| 111 | + python3 << PYEOF |
| 112 | +import sys |
| 113 | +import re |
| 114 | + |
| 115 | +with open('$skill', 'r') as f: |
| 116 | + content = f.read() |
| 117 | + |
| 118 | +lines = content.split('\n') |
| 119 | +for line in lines[1:]: |
| 120 | + if line == '---': |
| 121 | + break |
| 122 | + if line.startswith('name:'): |
| 123 | + name = line[5:].strip() |
| 124 | + if not re.match(r'^[a-z0-9-]+$', name): |
| 125 | + print(f"Error: $skill name '{name}' contains invalid characters") |
| 126 | + sys.exit(1) |
| 127 | + if len(name) > 64: |
| 128 | + print(f"Error: $skill name exceeds 64 characters ({len(name)})") |
| 129 | + sys.exit(1) |
| 130 | + break |
| 131 | +PYEOF |
| 132 | + if [ $? -ne 0 ]; then |
| 133 | + failed=1 |
| 134 | + fi |
| 135 | + done |
| 136 | + if [ $failed -eq 1 ]; then |
| 137 | + echo "Some SKILL.md files have name format issues" |
| 138 | + exit 1 |
| 139 | + fi |
| 140 | + echo "All names are valid!" |
0 commit comments