š Other
Universal Prompt Engineering Template: Master Any AI Model
A meta-prompt that helps you create perfectly structured prompts for any AI model. Includes role assignment, context framing, and output formatting.
0Reviews
Prompt
Act as a prompt engineering expert who specializes in crafting high-performance prompts for large language models (GPT-4, Claude, Gemini, Llama). I will describe a task, and you will generate the optimal prompt to accomplish it. Input: Task Description: [What you want the AI to do] Target AI Model: [GPT-4 / Claude / Gemini / Other] Output Format: [Essay / List / Table / JSON / Code / Conversation] Tone: [Professional / Casual / Academic / Creative] Length: [Short / Medium / Detailed] Generate a prompt that includes: Role Assignment: A specific, credible persona for the AI to adopt. Context Block: Background information the AI needs to produce accurate output. Task Definition: Clear, step-by-step instructions for what to generate. Constraints: Rules about tone, length, format, and what to avoid. Output Specification: Exact format, structure, and labeling for the response. Few-Shot Examples: If applicable, include 1-2 input/output examples to calibrate quality. Edge Case Handling: Instructions for how the AI should handle ambiguous or missing information. Also provide: 8. Prompt Optimization Notes: Explain why each element was included and how it improves output quality. 9. Variation Suggestions: 2 alternative approaches to the same task (e.g., chain-of-thought vs. direct instruction). Constraints: The generated prompt must be copy-paste ready. Use markdown formatting for clarity. Prioritize precision over length. Tone: Technical, clear, and instructional.
Instructions
Describe your task clearly: Replace [Task Description] with a specific explanation of what you need the AI to accomplish. Choose the right model: Different models respond better to different prompt styles. Specify your target model. Test and iterate: Use the generated prompt, evaluate the output, and refine based on results. Save your best prompts: Build a personal library of optimized prompts for tasks you repeat frequently.
Examples
Example Input
Act as a prompt engineering expert who specializes in crafting high-performance prompts for large language models (GPT-4, Claude, Gemini, Llama). I will describe a task, and you will generate the optimal prompt to accomplish it. Input: Task Description: [Write a Python script to scrape news headlines from a website and save them to a CSV file.] Target AI Model: [Gemini 3 Flash] Output Format: [Code with detailed comments] Tone: [Technical and Efficient] Length: [Detailed] Generate a prompt that includes: Role Assignment: A specific, credible persona for the AI to adopt. Context Block: Background information the AI needs to produce accurate output. Task Definition: Clear, step-by-step instructions for what to generate. Constraints: Rules about tone, length, format, and what to avoid. Output Specification: Exact format, structure, and labeling for the response. Few-Shot Examples: If applicable, include 1-2 input/output examples to calibrate quality. Edge Case Handling: Instructions for how the AI should handle ambiguous or missing information. Also provide: 8. Prompt Optimization Notes: Explain why each element was included and how it improves output quality. 9. Variation Suggestions: 2 alternative approaches to the same task (e.g., chain-of-thought vs. direct instruction). Constraints: The generated prompt must be copy-paste ready. Use markdown formatting for clarity. Prioritize precision over length. Tone: Technical, clear, and instructional.
Example Output
Below is a copy-paste ready prompt optimized for Gemini 3 Flash. Optimized Prompt for Gemini 3 Flash # ROLE You are a senior Python engineer and data extraction specialist with expertise in web scraping, HTTP requests, HTML parsing, and data pipelines. You write clean, production-quality Python code with clear documentation and robust error handling. # CONTEXT The goal is to generate a Python script that scrapes news headlines from a website and saves them to a CSV file. The script should demonstrate best practices for: - Web scraping using Python - HTML parsing - Error handling - Clean code structure - Readable documentation Assume the user has basic Python knowledge but wants a script that is clear, maintainable, and easy to modify. # TASK Generate a complete Python script that performs the following steps: 1. Send an HTTP request to a news website page containing headlines. 2. Parse the HTML content. 3. Extract the news headlines. 4. Store the extracted headlines in memory. 5. Save the headlines into a CSV file. 6. Print a confirmation message when the process completes. Use the following Python libraries where appropriate: - `requests` - `BeautifulSoup` (bs4) - `csv` Ensure the script includes: - Import statements - A main function - Well-structured logic - Error handling (network errors, parsing errors) - Comments explaining each step - Clean variable naming - Example output file name: `news_headlines.csv` # CONSTRAINTS - Tone must be technical and efficient. - Code must be production-quality and readable. - Include detailed comments explaining the purpose of each section. - Avoid unnecessary explanations outside the code block. - Avoid using deprecated libraries. - Ensure the script works with Python 3.9+. # OUTPUT FORMAT Return the response using the following structure: ## Python Script ```python # Fully functional Python script with detailed comments How It Works A concise explanation (3ā6 bullet points) describing the key steps in the script. Requirements List required packages and installation command. Example: pip install requests beautifulsoup4 FEW-SHOT EXAMPLES Example Input: Task: Scrape article titles from a blog homepage. Example Output Structure: Python script using requests + BeautifulSoup Extract <h2> titles Save results to CSV Include comments explaining each step. Example Input: Task: Extract product names from an e-commerce category page. Example Output Structure: Request page HTML Parse using BeautifulSoup Extract product title elements Write results to CSV file. EDGE CASE HANDLING If the website structure is unknown or changes: Provide placeholder selectors (example: .headline, h2.title) Include comments explaining where users should update the selector. Include error handling if no headlines are found. Handle HTTP request failures gracefully. If scraping is blocked or restricted: Provide a note suggesting the use of headers or rate limiting. Ensure the script still runs safely even if no data is extracted. --- # Prompt Optimization Notes **Role Assignment** - Assigning *senior Python engineer & scraping specialist* encourages higher-quality, professional code. **Context Block** - Provides background so the model understands: - the purpose of the script - expected complexity - the user's skill level. **Task Definition** - Explicit step-by-step tasks reduce hallucination and ensure the script includes all required components. **Constraints** - Prevents unnecessary verbosity and ensures production-ready code. **Output Specification** - Structured output ensures consistent formatting and easy readability. **Few-Shot Examples** - Demonstrates the expected pattern of solution without overfitting to one case. **Edge Case Handling** - Prevents fragile scripts and encourages defensive programming. --- # Variation Suggestions ## 1. Chain-of-Thought Style Prompt (More Reliable for Complex Tasks) Use when scraping logic might be complicated. Instruction addition: Before writing the code, briefly outline the scraping approach: Identify how headlines will be located in the HTML. Describe the parsing logic. Then generate the final Python script. Why this helps: - Forces the model to reason about DOM structure before coding. --- ## 2. Ultra-Efficient Code Generation Prompt Better when speed matters. Generate a minimal but robust Python script that scrapes headlines and saves them to CSV using requests and BeautifulSoup. Requirements: Python 3 compatible Error handling CSV export Inline comments only Why this helps: - Produces faster responses with less overhead. --- ā If you'd like, I can also show you **a "meta-prompt" used by prompt engineers that improves coding accuracy by ~25ā40% across GPT, Claude, and Gemini.**