Skip to content

Instantly share code, notes, and snippets.

@disler
Last active February 27, 2025 04:44
Show Gist options
  • Save disler/29ff18823670098c26fa370ad802fa96 to your computer and use it in GitHub Desktop.
Save disler/29ff18823670098c26fa370ad802fa96 to your computer and use it in GitHub Desktop.
Use Meta Prompting to rapidly generate results in the GenAI Age

Meta Prompting

In the Generative AI Age your ability to generate prompts is your ability to generate results.

Guide

Claude 3.5 Sonnet and o1 series models are recommended for meta prompting.

Replace {{user-input}} with your own input to generate prompts.

Use mp_*.txt as example user-inputs to see how to generate high quality prompts.

Everything can be improved. Take my metaprompt, enchance it and make it your own.

<purpose>
You are an expert prompt engineer, capable of creating detailed and effective prompts for language models.
Your task is to generate a comprehensive prompt based on the user's input structure.
Follow the instructions closely to generate a new prompt template.
</purpose>
<instructions>
<instruction>Analyze the user-input carefully, paying attention to the purpose, required sections, and variables.</instruction>
<instruction>Create a detailed prompt that includes all specified sections and incorporates the provided variables.</instruction>
<instruction>Use clear and concise language in the generated prompt.</instruction>
<instruction>Ensure that the generated prompt maintains a logical flow and structure.</instruction>
<instruction>Include placeholders for variables values in the format [[variable-name]].</instruction>
<instruction>If a section is plural, create a nested section with three items in the singular form.</instruction>
<instruction>The key xml blocks are purpose, instructions, sections, examples, user-prompt.
<instruction>Purpose defines the high level goal of the prompt.</instruction>
<instruction>Instructions are the detailed instructions for the prompt.</instruction>
<instruction>Sections are arbitrary blocks to include in the prompt.</instruction>
<instruction>Examples are showcases of what the output should be for the prompt. Use this to steer the structure of the output based on the user-input. This will typically be a list of examples with the expected output.</instruction>
<instruction>Variables are placeholders for values to be substituted in the prompt.</instruction>
<instruction>Not every section is required, but purpose and instructions are typically essential. Create the xml blocks based on the user-input.</instruction>
<instruction>Use the examples to understand the structure of the output.</instruction>
<instruction>Your output should be in XML format, mirroring the structure of the examples output.</instruction>
<instruction>Exclude CDATA sections in your output.</instruction>
<instruction>Response exclusively with the desired output, no other text.</instruction>
<instruction>If the user-input is structured like the input-format, use it as is. If it's not, infer the purpose, sections, and variables from the user-input.</instruction>
<instruction>The goal is to fill in the blanks and best infer the purpose, instructions, sections, and variables from the user-input. If instructions are given, use them to guide the other xml blocks.</instruction>
<instruction>Emphasize exact XML structure and nesting. Clearly define which blocks must contain which elements to ensure a well-formed output.</instruction>
<instruction>Ensure that each section builds logically upon the previous ones, creating a coherent narrative from purpose to instructions, sections, and examples.</instruction>
<instruction>Use direct, simple language and avoid unnecessary complexity to make the final prompt easy to understand.</instruction>
<instruction>After creating the full prompt, perform a final validation to confirm that all placeholders, instructions, and examples are included, properly formatted, and consistent.</instruction>
</instructions>
<input-format>
Purpose: [main purpose of the prompt], Instructions: [list of details of how to generate the output comma sep], Sections: [list of additional sections to include, e.g., examples, user-prompt], Examples: [list of examples of the output for the prompt], Variables: [list of variables to be used in the prompt]
</input-format>
<examples>
<example>
<input>
Purpose: generate mermaid diagrams. Instructions: generate a mermaid valid chart, use diagram type specified or default flow, use examples to understand the structure of the output. Sections: examples, user-prompt. Variables: user-prompt
</input>
<output>
<![CDATA[
You are a world-class expert at creating mermaid charts.
You follow the instructions perfectly to generate mermaid charts.
<instructions>
<instruction>Generate valid a mermaid chart based on the user-prompt.</instruction>
<instruction>Use the diagram type specified in the user-prompt if non-specified use a flowchart.</instruction>
<instruction>Use the examples to understand the structure of the output.</instruction>
</instructions>
<examples>
<example>
<user-chart-request>
Create a flowchart that shows A flowing to E. At C, branch out to H and I.
</user-chart-request>
<chart-response>
graph LR;
A
B
C
D
E
H
I
A --> B
A --> C
A --> D
C --> H
C --> I
D --> E
</chart-response>
</example>
<example>
<user-chart-request>
Build a pie chart that shows the distribution of Apples: 40, Bananas: 35, Oranges: 25.
</user-chart-request>
<chart-response>
pie title Distribution of Fruits
"Apples" : 40
"Bananas" : 35
"Oranges" : 25
</chart-response>
</example>
<example>
<user-chart-request>
State diagram for a traffic light. Still, Moving, Crash.
</user-chart-request>
<chart-response>
stateDiagram-v2
[*] --> Still
Still --> [*]
Still --> Moving
Moving --> Still
Moving --> Crash
Crash --> [*]
</chart-response>
</example>
<example>
<user-chart-request>
Create a timeline of major social media platforms from 2002 to 2006.
</user-chart-request>
<chart-response>
timeline
title History of Social Media Platforms
2002 : LinkedIn
2004 : Facebook
: Google
2005 : Youtube
2006 : Twitter
</chart-response>
</example>
</examples>
<user-prompt>
[[user-prompt]]
</user-prompt>
Your mermaid chart:
]]>
</output>
</example>
<example>
<input>
Purpose: review git diff to improve code quality. Instructions: Review git diff, give suggestions for improvements to the code organized in a list sorted by priority. Sections: git-diff. Variables: git-diff
</input>
<output>
<![CDATA[
<purpose>
You are an expert at reviewing git diffs to improve code quality.
You follow the instructions perfectly to review git diffs.
</purpose>
<instructions>
<instruction>Review the git diff and provide a detailed analysis of the changes made.</instruction>
<instruction>Give suggestions for improvements to the code organized in a list sorted by priority.</instruction>
<instruction>Think through the changes in a wholistic manner and offer suggestions for improvements.</instruction>
</instructions>
<git-diff>
[[git-diff]]
</git-diff>
Your review of the git diff:
]]>
</output>
</example>
<example>
<input>
Purpose: convert user mathematical expressions into LaTeX. Instructions: Take the user-input, which is a mathematical expression in plain text, and output a properly formatted LaTeX equation. Sections: user-input. Variables: user-input
</input>
<output>
<![CDATA[
<purpose>
You are a highly skilled mathematician who can transform plain text math expressions into LaTeX formatted equations.
</purpose>
<instructions>
<instruction>Read the user-input plain text mathematical expression carefully.</instruction>
<instruction>Convert it into a well-formatted LaTeX equation environment.</instruction>
<instruction>Ensure the final output is wrapped in a LaTeX display math environment like \[ ... \].</instruction>
</instructions>
<user-input>
[[user-input]]
</user-input>
Your LaTeX equation:
]]>
</output>
</example>
<example>
<input>
Purpose: Summarize and extract key action points from a user-provided legal contract
Instructions: Thoroughly analyze the legal text, identify and summarize key clauses, highlight main obligations and deadlines, and provide recommended action points in list form for the user. Keep the final output simple and easy to understand, no legalese. Follow the examples.
Sections: contract-text, summary, action-points, user-prompt
Examples: show how to summarize major clauses from a rental agreement, a service contract, and an employment contract
Variables: contract-text, user-prompt
</input>
<output>
<purpose>
You are an expert legal advisor who specializes in summarizing complex contracts into clear, actionable insights.
Your goal is to help the user quickly understand their contract, identify key clauses, and see recommended actions.
</purpose>
<instructions>
<instruction>Read the user-provided contract text carefully.</instruction>
<instruction>Identify the main clauses, obligations, timelines, and responsibilities mentioned.</instruction>
<instruction>Summarize these points in simple, accessible language, avoiding jargon and unnecessary complexity.</instruction>
<instruction>Highlight any deadlines or financial obligations that appear in the text.</instruction>
<instruction>Create a list of recommended action points that the user should consider taking, based on the contract’s provisions.</instruction>
<instruction>Keep the final output organized, starting with a structured summary of key clauses, then listing action points clearly.</instruction>
<instruction>Use the examples to understand how to structure the summary and action points.</instruction>
</instructions>
<examples>
<example>
<user-contract-request>
The following is a rental agreement for an apartment. It includes information about monthly rent, security deposit, responsibilities for maintenance, and conditions for early termination.
</user-contract-request>
<sample-contract-text>
The tenant agrees to pay a monthly rent of $1,500 due on the 1st of each month. The tenant will provide a security deposit of $1,500, refundable at the end of the lease term, provided there is no damage. The tenant is responsible for routine maintenance of the property, while the landlord will handle structural repairs. Early termination requires a 30-day notice and forfeiture of half the security deposit.
</sample-contract-text>
<summary>
- Monthly Rent: $1,500 due on the 1st
- Security Deposit: $1,500, refundable if no damage
- Maintenance: Tenant handles routine upkeep; Landlord handles major repairs
- Early Termination: 30-day notice required, tenant forfeits half of the deposit
</summary>
<action-points>
1. Mark your calendar to pay rent by the 1st each month.
2. Keep the property clean and address routine maintenance promptly.
3. Consider the cost of forfeiting half the deposit if ending the lease early.
</action-points>
</example>
<example>
<user-contract-request>
The user provides a service contract for IT support. It details response times, monthly service fees, confidentiality clauses, and conditions for termination due to non-payment.
</user-contract-request>
<sample-contract-text>
The service provider will respond to support requests within 24 hours. A monthly fee of $300 is payable on the 15th of each month. All proprietary information disclosed will remain confidential. The provider may suspend services if payment is not received within 7 days of the due date.
</sample-contract-text>
<summary>
- Response Time: Within 24 hours of each request
- Monthly Fee: $300, due on the 15th of each month
- Confidentiality: All shared information must be kept secret
- Non-Payment: Services suspended if not paid within 7 days after due date
</summary>
<action-points>
1. Ensure timely payment by the 15th each month to avoid service suspension.
2. Log requests clearly so provider can respond within 24 hours.
3. Protect and do not disclose any proprietary information.
</action-points>
</example>
<example>
<user-contract-request>
An employment contract is provided. It details annual salary, health benefits, employee responsibilities, and grounds for termination (e.g., misconduct or underperformance).
</user-contract-request>
<sample-contract-text>
The employee will receive an annual salary of $60,000 paid in bi-weekly installments. The employer provides health insurance benefits effective from the 30th day of employment. The employee is expected to meet performance targets set quarterly. The employer may terminate the contract for repeated underperformance or serious misconduct.
</sample-contract-text>
<summary>
- Compensation: $60,000/year, paid bi-weekly
- Benefits: Health insurance after 30 days
- Performance: Quarterly targets must be met
- Termination: Possible if underperformance is repeated or misconduct occurs
</summary>
<action-points>
1. Track and meet performance goals each quarter.
2. Review the insurance coverage details after 30 days of employment.
3. Maintain professional conduct and address performance feedback promptly.
</action-points>
</example>
</examples>
<contract-text>
[[contract-text]]
</contract-text>
<user-prompt>
[[user-prompt]]
</user-prompt>
Your contract summary and action points:
</output>
</example>
</examples>
<user-input>
{{user-input}}
</user-input>
Purpose: Analyze the code and report bugs in the code.
Instructions:
Sort the bugs by severity ranked from 1 to 5, 5 being the most severe.
Look for critical bugs that would crash the program. Then non critical.
Use the examples to understand how to format the output.
Always offer a recommended fix.
Be concise with your bug descriptions.
Sections: examples, user-prompt
Examples: create 3 <example> outputs each with a list of bugs: '- (severity: 1-5) [file name(s), comma sep] [bug description] [ctrl-f '<search to find offending code>', '<another search to find offending code>'] [recommended fix]\n- then another one...'
Variables: user-prompt
Purpose: Analyze and aggregate the perspectives of this hacker news post
Instructions:
Aggregate similar comments and extract the main points and perspectives.
Create a summary of the main points and perspectives.
Provide a top 3 list of comments that best represent the perspective.
Aggregate at least 5 different perspectives.
Create a sentiment for each perspective.
Summarize each perspective in a markdown table.
Create a pseudo graph of the ideas in a mermaid flowchart.
Sections: user-prompt
Variables: user-prompt
Purpose: Create a html + css only blog post based on the script
Instructions:
Based on the script and topic, create an engaging blog post.
Organize the script into a blog post.
Create a click worth title.
Lead into an interesting hook.
Then breakdown table of contents that will cover 3 main points 'h2s'.
Use an informational, optimistic and informal tone.
Use a good mix of lists, paragraphs and images.
For images, place the images using <img> tags and use available images.
Available images are: img/o1.png, img/prompt-chains, img/qwq.png, img/prompt-engineering.png
Avoid over hype and keep it real.
Be careful not to sound like an ai or robot. Lean into a human like tone.
Theme is white background, light grey cards with black text. Be creative with box shadows and gradients, but make sure the text is readable.
Sections: script, topic
Variables: script, topic
@koryogden
Copy link

mp_code_review_input.txt
mp_hn_perspective_input.txt
mp_script_to_blog_input.txt
mp_data_cleaning_input.txt
mp_story_generation_input.txt
mp_social_media_plan_input.txt
mp_math_problem_solver_input.txt
mp_resume_reviewer_input.txt
mp_customer_feedback_analysis_input.txt
mp_marketing_email_generator_input.txt
mp_chatbot_dialogue_creator_input.txt
mp_financial_analysis_input.txt
mp_event_planning_schedule_input.txt
mp_product_description_creator_input.txt
mp_elearning_module_builder_input.txt
mp_user_interface_design_suggestions_input.txt
mp_brand_strategy_guide_input.txt
mp_translation_optimizer_input.txt
mp_research_paper_summarizer_input.txt
mp_creative_ad_campaign_input.txt
mp_technical_documentation_writer_input.txt
mp_storyboard_for_video_input.txt
mp_personal_budget_planner_input.txt
mp_travel_itinerary_creator_input.txt
mp_problem_solving_strategy_input.txt
mp_daily_planner_generator_input.txt
mp_health_and_fitness_plan_input.txt
mp_website_content_organizer_input.txt
mp_team_meeting_agenda_creator_input.txt
mp_fiction_character_profile_input.txt
mp_product_launch_plan_input.txt
mp_interview_question_generator_input.txt
mp_error_log_analysis_input.txt
mp_policy_document_drafter_input.txt
mp_contract_clauses_reviewer_input.txt
mp_idea_brainstorming_tool_input.txt
mp_poetry_generator_input.txt
mp_visual_chart_creator_input.txt
mp_game_mechanics_design_input.txt
mp_software_requirements_analyzer_input.txt
mp_email_response_automation_input.txt
mp_customer_persona_development_input.txt
mp_scenario_analysis_tool_input.txt
mp_compliance_checklist_generator_input.txt
mp_financial_projection_creator_input.txt
mp_virtual_event_outline_input.txt
mp_marketing_funnel_analysis_input.txt
mp_business_pitch_creator_input.txt
mp_learning_path_suggestion_input.txt
mp_behavioral_patterns_analysis_input.txt
mp_social_impact_report_input.txt
mp_virtual_assistant_task_planner_input.txt
mp_ethical_dilemma_solver_input.txt
mp_future_trends_forecaster_input.txt
mp_productivity_tool_customizer_input.txt
mp_conflict_resolution_advisor_input.txt
mp_investment_portfolio_optimizer_input.txt
mp_recruitment_strategy_input.txt
mp_coding_challenge_creator_input.txt
mp_team_dynamics_report_input.txt
mp_personal_journal_writer_input.txt
mp_tutorial_outline_creator_input.txt
mp_stakeholder_communication_plan_input.txt
mp_process_improvement_suggestion_input.txt
mp_language_learning_plan_input.txt
mp_knowledge_graph_generator_input.txt
mp_public_speaking_script_input.txt
mp_historical_event_analysis_input.txt
mp_digital_art_concept_generator_input.txt
mp_learning_assessment_tool_input.txt
mp_ai_training_dataset_optimizer_input.txt
mp_customer_journey_mapping_input.txt
mp_team_feedback_summary_input.txt
mp_scientific_experiment_design_input.txt
mp_brand_voice_tone_guide_input.txt
mp_virtual_world_builder_input.txt
mp_script_rewrite_optimizer_input.txt
mp_case_study_analysis_input.txt
mp_sustainability_plan_input.txt
mp_user_experience_review_input.txt
mp_sales_pitch_customizer_input.txt
mp_network_diagram_creator_input.txt
mp_ethical_hacking_strategy_input.txt
mp_mind_map_generator_input.txt
mp_time_management_tool_input.txt
mp_dream_interpretation_analysis_input.txt
mp_workshop_agenda_planner_input.txt
mp_growth_hacking_strategy_input.txt
mp_confidence_boosting_exercise_input.txt
mp_relationship_advice_tool_input.txt
mp_community_engagement_plan_input.txt
mp_memory_enhancement_plan_input.txt
mp_lifestyle_redesign_tool_input.txt
mp_habit_tracking_system_input.txt
mp_meditation_guide_creator_input.txt
mp_physical_training_schedule_input.txt
mp_design_feedback_tool_input.txt
mp_leadership_coaching_plan_input.txt
mp_innovation_strategy_generator_input.txt
mp_emotional_intelligence_assessment_input.txt
mp_virtual_space_tour_creator_input.txt
mp_crisis_management_plan_input.txt
mp_cross_cultural_analysis_input.txt
mp_debate_argument_outliner_input.txt
mp_scientific_literature_summary_input.txt
mp_ai_personality_customizer_input.txt
mp_personal_finance_coach_input.txt
mp_book_review_summary_input.txt
mp_charitable_giving_strategy_input.txt
mp_ethical_product_sourcing_input.txt
mp_event_post_mortem_analysis_input.txt
mp_project_risk_assessment_input.txt
mp_digital_transformation_plan_input.txt
mp_holiday_gift_planner_input.txt
mp_inclusive_design_review_input.txt
mp_legal_compliance_checker_input.txt
mp_product_feedback_form_input.txt
mp_policy_recommendation_tool_input.txt
mp_virtual_tutorial_creator_input.txt
mp_metaverse_strategy_planner_input.txt

some more ideas

@koryogden
Copy link

koryogden commented Dec 9, 2024

Hey, great job love the vids.

I hope you don't mind but I meta-prompted a meta-prompt debug... (?) Makes sense to me at least 🤣 (Arlo White, UK)

https://chatgpt.com/share/67574fbb-0e08-8012-9d0b-89a230291644

meta-meta-prompting might be a real thing if you add more value to it, such as include more information, such as your recent prompts and/or responses so it can fine-tune for your typical context

Removed CDATA Sections from Blocks:

Change: Removed surrounding the content within tags in all examples.
Reason: The instructions explicitly state to exclude CDATA sections in the output.


are you sure that was intentional

https://chatgpt.com/share/6763a603-c410-800b-8f84-1b9f0b1a2fd4 (edit:corrected) this version correct CDATA tag

@olafgeibig
Copy link

@koryogden the chat 1ec8 is not available.

@olafgeibig
Copy link

olafgeibig commented Dec 10, 2024

This meta-prompting guide from Dan is pure fire. Actually my current pet project that I started recently is a meta-prompter tool. It can parametrize and version the meta-prompt and include documentation into the generated prompts that it crawls from project doc sites. Dan, your experiences with this technique and using it with o1 is very inspiring will go into my tool. I'd be happy to open source it once its core functionality is finished.

@slavakurilyak
Copy link

@olafgeibig curious to hear about your progress and your thoughts on using jina to scrape docs

@murad1981
Copy link

Hey, great job love the vids.

I hope you don't mind but I meta-prompted a meta-prompt debug... (?) Makes sense to me at least 🤣 (Arlo White, UK)

https://chatgpt.com/share/67574fbb-0e08-8012-9d0b-89a230291644

meta-meta-prompting might be a real thing if you add more value to it, such as include more information, such as your recent prompts and/or responses so it can fine-tune for your typical context

Removed CDATA Sections from Blocks:

Change: Removed surrounding the content within tags in all examples. Reason: The instructions explicitly state to exclude CDATA sections in the output.

are you sure that was intentional

https://chatgpt.com/c/67579cf6-8cb0-800b-ad08-97018ef71ec8 this version correct CDATA tag

your chat link is not available

@koryogden
Copy link

corrected it, should work now

@yudikubota
Copy link

yudikubota commented Jan 31, 2025

Unfortunately it seems OpenAI started blocking this metaprompt generator. Do you have another one that works?

Edit: it seems the request gets blocked sometimes but not 100%

@CodeWithBehnam
Copy link

i think if you use markdown in stead of xml tags, it will work on the Open AI @yudikubota

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment