#!/usr/bin/env python3 """ Skill Builder - Rebuild validation skills from Apple Style Guide Usage: python build_skill.py validate-classical-metadata python build_skill.py validate-track-metadata python build_skill.py validate-release-metadata python build_skill.py --all """ import asyncio import sys from pathlib import Path from claude_agent_sdk import query, ClaudeAgentOptions SKILLS = { "validate-classical-metadata": { "description": "Build validate-classical-metadata skill from Apple Style Guide classical rules including section 13", "task_section": "Build validate-classical-metadata" }, "validate-track-metadata": { "description": "Build validate-track-metadata skill from Apple Style Guide track rules", "task_section": "Build validate-track-metadata" }, "validate-release-metadata": { "description": "Build validate-release-metadata skill from Apple Style Guide album rules", "task_section": "Build validate-release-metadata" } } async def build_skill(skill_name: str): """Build a single validation skill""" if skill_name not in SKILLS: print(f"āŒ Unknown skill: {skill_name}") print(f"Available skills: {', '.join(SKILLS.keys())}") return False skill_info = SKILLS[skill_name] print(f"\nšŸ”Ø Building {skill_name}...") print(f" {skill_info['description']}\n") # Load the task instructions task_path = Path("prompts/build_validation_skill_prompt.md") with open(task_path) as f: task_content = f.read() # Create a focused prompt for this specific skill prompt = f""" I need you to rebuild the {skill_name} skill by following the instructions in the task file. Read the file: prompts/build_validation_skill_prompt.md Then execute ONLY the section titled "### {skill_info['task_section']}" from that file. Follow all the instructions in that section precisely: 1. Delete and recreate the skill directory if it exists 2. Fetch the latest Apple Style Guide rules 3. Create SKILL.md with proper formatting 4. Create the *_RULES.md file with all relevant rules 5. Follow the severity level guidelines and rule structure Do not reference or build any other skills - only {skill_name}. """ # Execute the skill building task try: async for message in query( prompt=prompt, options=ClaudeAgentOptions( setting_sources=["user", "project"], allowed_tools=["Bash", "Read", "Write", "WebFetch", "Glob"] ) ): print(message) print(f"\nāœ… {skill_name} built successfully") return True except Exception as e: print(f"\nāŒ Error building {skill_name}: {e}") return False async def build_all_skills(): """Build all validation skills""" print("šŸ”Ø Building all validation skills...\n") results = {} for skill_name in SKILLS.keys(): success = await build_skill(skill_name) results[skill_name] = success print("\n" + "="*60 + "\n") # Print summary print("\nšŸ“Š Build Summary:") for skill_name, success in results.items(): status = "āœ…" if success else "āŒ" print(f" {status} {skill_name}") all_success = all(results.values()) return all_success async def main(): if len(sys.argv) < 2: print("Usage: python build_skill.py ") print(" python build_skill.py --all") print("\nAvailable skills:") for name, info in SKILLS.items(): print(f" - {name}") print(f" {info['description']}") sys.exit(1) arg = sys.argv[1] if arg == "--all": success = await build_all_skills() elif arg in SKILLS: success = await build_skill(arg) else: print(f"āŒ Unknown skill: {arg}") print(f"Available skills: {', '.join(SKILLS.keys())}") print("Or use --all to build all skills") sys.exit(1) sys.exit(0 if success else 1) if __name__ == "__main__": asyncio.run(main())