Skip to content

Instantly share code, notes, and snippets.

@dbolser
Forked from disler/README.md
Created December 10, 2024 18:59
Show Gist options
  • Save dbolser/e9c7c0fd8b7e20228a5f110a147d5cb9 to your computer and use it in GitHub Desktop.
Save dbolser/e9c7c0fd8b7e20228a5f110a147d5cb9 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>
<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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment