Skip to content

Check_skill

FieldValue
TypeSkill Resource
Source~/.copilot/skills/skill-forge/scripts/check_skill.py
DescriptionNot specified

Source Content

#!/usr/bin/env python3
"""Check a skill directory has valid frontmatter and no dangling references.
Usage: check_skill.py <skill-dir>
"""
import re
import sys
from pathlib import Path
def main() -> int:
if len(sys.argv) != 2:
print("Usage: check_skill.py <skill-dir>", file=sys.stderr)
return 2
skill_dir = Path(sys.argv[1])
skill_md = skill_dir / "SKILL.md"
fail = 0
if not skill_md.exists():
print(f"❌ no SKILL.md found in {skill_dir}")
return 1
text = skill_md.read_text(encoding="utf-8")
fm = re.match(r"^---\n(.*?)\n---\n", text, re.DOTALL)
if not fm:
print("❌ no YAML frontmatter found")
fail = 1
else:
frontmatter = fm.group(1)
name_match = re.search(r"^name:\s*(.+)$", frontmatter, re.MULTILINE)
desc_match = re.search(r"^description:\s*(.+)$", frontmatter, re.MULTILINE | re.DOTALL)
if not name_match:
print("❌ frontmatter missing 'name'")
fail = 1
elif name_match.group(1).strip() != skill_dir.name:
print(f"❌ frontmatter name '{name_match.group(1).strip()}' does not match directory name '{skill_dir.name}'")
fail = 1
else:
print(f"✅ name matches directory: {skill_dir.name}")
if not desc_match:
print("❌ frontmatter missing 'description'")
fail = 1
else:
desc_len = len(desc_match.group(1))
if desc_len > 1500:
print(f"❌ description is {desc_len} chars — too long to trigger reliably, tighten it")
fail = 1
else:
print(f"✅ description present ({desc_len} chars)")
referenced = re.findall(r"`(references/[\w./-]+|scripts/[\w./-]+|templates/[\w./-]+)`", text)
missing = [r for r in referenced if not (skill_dir / r).exists()]
if missing:
print(f"❌ SKILL.md references path(s) that don't exist on disk: {missing}")
fail = 1
else:
print(f"✅ all {len(referenced)} referenced references/scripts/templates paths exist")
return fail
if __name__ == "__main__":
raise SystemExit(main())