Requirements
How To Start
A Note From The Author of CRAFT
- After hundreds (perhaps thousands) of hours of using these recipes, I rarely need to use any of the CORE Cookbook recipes aside from Recipes RCP-001-001-002-HANDOFF-SNAPSHOT and RCP-001-001-002-HANDOFF-SNAPSHOT, but when I do, they are essential to the functioning of CRAFT. Also, the A.I. reads all of these recipes at the start of each session. This happens quietly in the background. Even though you may never need to call the recipe, the A.I. will know all of them and it helps the A.I. to understand what CRAFT is and how it works. Even if you rarely need to use these recipes, they are still working for you and are essential to the CRAFT Framework.
STEP 1: Trigger the Recipe
- Provide the recipe directive with source parameters: #H->AI::Directive: (Please execute the Single Recipe Runner with these parameters: * source_type: [file/url] * source: [path or URL] )
STEP 2: Recipe Acquisition
- For file sources: - Verify .txt extension for security - Read and parse file contents - Extract recipe code from markers For URL sources: - Fetch page content - Check domain against CRAFTFramework.ai - Warn for non-official sources - Require explicit consent to proceed
STEP 3: Format Validation (Check 1/3)
- Verify CRAFT standards compliance: - Required elements present (recipe_id, title, description, parameters, prompt_template) - Recipe ID follows RCP-XXX-XXX-XXX-NAME format - Proper version numbering
STEP 4: Section Validation (Check 2/3)
- Verify required sections: - Step markers or phase structure present - CRAFT comment formatting (H->AI, AI->H) - Clear execution flow defined
STEP 5: Security Scan (Check 3/3)
- Scan for suspicious patterns: - Dangerous file operations - Code injection risks - System command execution - Unauthorized file access Block recipes with security concerns.
STEP 6: Review or Execute
- Present validated recipe summary: - Recipe ID and name - Description and difficulty - Required parameters User chooses: review, execute, or cancel.
STEP 7: Parameter Collection
- If executing, collect required parameters: - Present each required parameter - Show available options if defined - Validate parameter types
STEP 8: Recipe Execution
- Execute the imported recipe: - Store in session memory - Run prompt_template with parameters - Report success or handle errors Note: Imported recipes persist only for the current session.
When to Use This Recipe
Use this recipe when you need to:- Import a recipe from a text file attachment- Fetch and run a recipe from CRAFTFramework.ai- Execute recipes shared by other CRAFT users- Test external recipes before adding to cookbook
Recipe FAQ
Q: What file formats are accepted?
A: Only .txt files are accepted for security reasons. Q: Can I import recipes from any URL?
A: Yes, but non-CRAFTFramework.ai sources trigger a
security warning requiring explicit consent. Q: Do imported recipes persist across sessions?
A: No, imported recipes are available only for the
current session. Q: What happens if validation fails?
A: The recipe provides specific error details and
does not execute invalid or unsafe recipes.
A: Only .txt files are accepted for security reasons. Q: Can I import recipes from any URL?
A: Yes, but non-CRAFTFramework.ai sources trigger a
security warning requiring explicit consent. Q: Do imported recipes persist across sessions?
A: No, imported recipes are available only for the
current session. Q: What happens if validation fails?
A: The recipe provides specific error details and
does not execute invalid or unsafe recipes.
Actual Recipe Code
(Copy This Plaintext Code To Use)
# ===========================================================# START: RCP-001-001-019-SINGLE-RECIPE-RUNNER-v2.00a# ===========================================================SINGLE_RECIPE_RUNNER_RECIPE = Recipe( recipe_id="RCP-001-001-019-SINGLE-RECIPE-RUNNER-v2.00a", title="Single Recipe Runner - Import and Execute", description="Safely import and execute external CRAFT recipes from files or URLs with comprehensive validation and security checks", category="CAT-001-CORE", difficulty="medium", version="2.00a", parameters={ "source_type": { "type": "string", "required": True, "options": ["file", "url"], "description": "Where the recipe comes from" }, "source": { "type": "string", "required": True, "description": "File path or URL for recipe" } }, prompt_template=''' #H->AI::Directive: (Import and execute external CRAFT recipe with validation) #H->AI::Context: (Source type: {source_type}, Source: {source}) # PHASE 1: RECIPE ACQUISITION # =========================== #AI->H::Status: (Acquiring recipe from {source_type}) IF source_type == "file": #AI->H::Status: (Reading attached .txt file) VERIFY file_extension == ".txt" IF NOT .txt: #AI->H::Error: (Only .txt files accepted) #AI->H::Note: (Security requirement) STOP recipe_content = read_file(source) #AI->H::Status: (File loaded successfully) ELIF source_type == "url": #AI->H::Status: (Fetching recipe from URL) recipe_content = web_fetch(source) # Domain security check extract_domain = parse_url(source) IF domain != "craftframework.ai": #AI->H::SecurityWarning: (Non-official source) #AI->H::Warning: (Domain: {domain}) #AI->H::SecurityNote: (Official recipes are reviewed and tested. External recipes may contain untested code.) #AI->H::RequiredQuestion: (Type "yes, proceed anyway" to continue) WAIT for user_confirmation IF confirmation != "yes, proceed anyway": #AI->H::Status: (Import cancelled) STOP # Parse recipe from content #AI->H::Status: (Parsing recipe code) TRY: LOCATE "START RECIPE-ID" marker LOCATE "END RECIPE-ID" marker recipe_content = extract_between_markers() EXCEPT markers_not_found: #AI->H::Error: (Recipe delimiters not found) #AI->H::Note: (Looking for START/END markers) STOP #AI->H::Status: (Recipe extracted successfully) # PHASE 2: VALIDATION AND SECURITY # ================================ #AI->H::Status: (Running validation checks) validation_results = { "craft_format": False, "required_sections": False, "security_scan": False } # CHECK 1: CRAFT Standards Format #AI->H::Status: (Check 1/3: Verifying format) required_elements = [ "recipe_id", "title", "description", "parameters", "prompt_template" ] FOR element in required_elements: IF element NOT in recipe_content: #AI->H::ValidationError: (Missing: {element}) #AI->H::Note: (Recipe format invalid) STOP # Verify recipe_id format recipe_id_pattern = "RCP-XXX-XXX-XXX-NAME-vX.XXa" IF NOT matches_pattern(recipe_content.recipe_id): #AI->H::ValidationError: (Invalid recipe_id) #AI->H::ExpectedFormat: ({recipe_id_pattern}) STOP validation_results["craft_format"] = True #AI->H::Status: (Check 1/3 passed: Format valid) # CHECK 2: Required Sections #AI->H::Status: (Check 2/3: Verifying sections) IF NOT contains_craft_comments(prompt): #AI->H::ValidationError: (Missing CRAFT comments) #AI->H::Details: (Need H->AI and AI->H format) STOP IF NOT has_execution_structure(prompt): #AI->H::ValidationError: (Missing structure) #AI->H::Details: (Need steps or phases) STOP validation_results["required_sections"] = True #AI->H::Status: (Check 2/3 passed: Sections valid) # CHECK 3: Security Pattern Scan #AI->H::Status: (Check 3/3: Security scan) suspicious_patterns = [ "rm -rf /", "chmod 777", "eval(", "exec(", "__import__", "subprocess.call", "os.system", "/etc/passwd", "base64.decode" ] FOR pattern in suspicious_patterns: IF pattern_found(pattern, recipe_content): #AI->H::SecurityError: (Suspicious pattern) #AI->H::Pattern: ({pattern}) #AI->H::Note: (Recipe blocked) STOP IF contains_path_outside("/home/claude"): #AI->H::SecurityError: (Unauthorized path access) STOP validation_results["security_scan"] = True #AI->H::Status: (Check 3/3 passed: Secure) #AI->H::Status: (All validation checks passed) # PHASE 3: REVIEW/EXECUTE DECISION # ================================ #AI->H::Status: (Recipe validated and ready) #AI->H::RecipeInfo: (Displaying summary) Display recipe summary: RECIPE SUCCESSFULLY VALIDATED: - Recipe ID: {recipe_content.recipe_id} - Recipe Name: {recipe_content.title} - Description: {recipe_content.description} - Category: {recipe_content.category} - Difficulty: {recipe_content.difficulty} - Version: {recipe_content.version} PARAMETERS REQUIRED: FOR param in recipe_content.parameters: - {param.name} ({param.type}): {param.description} - Required: {param.required} #AI->H::RequiredQuestion: (How would you like to proceed?) #AI->H::Options: ( "review" - Show complete recipe code "execute" - Run recipe immediately "cancel" - Do not run this recipe ) WAIT for user_choice IF user_choice == "review": #AI->H::Status: (Displaying complete recipe) SHOW complete recipe_content #AI->H::Question: (Type "execute" or "cancel") WAIT for execution_confirmation IF confirmation != "execute": #AI->H::Status: (Import cancelled) STOP ELIF user_choice == "cancel": #AI->H::Status: (Recipe import cancelled) STOP # PHASE 4: RECIPE EXECUTION # ========================= #AI->H::Status: (Executing imported recipe) IF recipe_content.parameters has required params: #AI->H::RequiredQuestion: (Provide parameters:) FOR param in recipe_content.parameters: IF param.required == True: #AI->H::Parameter: ({param.name}) IF param.options: #AI->H::Options: ({param.options}) COLLECT parameter_values from user FOR param, value in parameter_values: IF NOT validate_type(value, param.type): #AI->H::Error: (Invalid type for {param}) STOP # Store recipe in session SESSION.imported_recipes.append({ "recipe_id": recipe_content.recipe_id, "recipe_object": recipe_content, "imported_at": current_timestamp(), "source": source, "source_type": source_type }) #AI->H::Status: (Recipe loaded into session) TRY: EXECUTE recipe_content.prompt_template #AI->H::Status: (Recipe execution complete) #AI->H::Note: (Recipe: {recipe_content.title}) #AI->H::Note: (Available this session only) EXCEPT execution_error as e: #AI->H::ExecutionError: (Recipe failed) #AI->H::ErrorDetails: ({e}) ''')# ===========================================================# END RECIPE-ID: RCP-001-001-019-SINGLE-RECIPE-RUNNER-v2.00a# ===========================================================
