import asyncio import json from pathlib import Path from claude_agent_sdk import query, ClaudeAgentOptions async def main(): print("Asking Claude to validate the product...\n") # Load the validation prompt from file prompt_path = Path("prompts/validation_prompt.md") with open(prompt_path) as f: prompt = f.read() # Query Claude to validate the product async for message in query( prompt=prompt, options=ClaudeAgentOptions( setting_sources=["user", "project"], # Required to load skills allowed_tools=["Skill", "Bash", "Read", "Write"] ) ): print(message) # Optionally validate the output against the schema print("\nValidating output against schema...") try: import jsonschema schema_path = Path("validation_result_schema.json") output_path = Path("validation_results.json") with open(schema_path) as f: schema = json.load(f) with open(output_path) as f: results = json.load(f) jsonschema.validate(instance=results, schema=schema) print("✓ Output conforms to schema") except ImportError: print("ℹ Install jsonschema for validation: pip install jsonschema") except jsonschema.ValidationError as e: print(f"✗ Schema validation failed: {e.message}") print(f" Failed at: {'.'.join(str(p) for p in e.path)}") except FileNotFoundError as e: print(f"✗ File not found: {e.filename}") except Exception as e: print(f"✗ Validation error: {e}") asyncio.run(main())