Skip to content

Instantly share code, notes, and snippets.

@jazonlee
Created February 21, 2026 10:25
Show Gist options
  • Select an option

  • Save jazonlee/ef9713a56f1f79cda293d85a117e17a8 to your computer and use it in GitHub Desktop.

Select an option

Save jazonlee/ef9713a56f1f79cda293d85a117e17a8 to your computer and use it in GitHub Desktop.
Prompt Engineering Techniques for LLMs

Ever wonder how some people get amazing, highly accurate results out of AI while others just get robotic gibberish? It all comes down to prompt engineering—the art of effectively communicating with Large Language Models (LLMs) like GPT-4 or Claude.

Below is a comprehensive guide breaks down the essential 7 prompting techniques that can take your AI interactions from basic to brilliant. Since the original deep-dive is quite lengthy, here is a streamlined, conversational summary that gives you the absolute core concepts in a fraction of the time.

Here are the heavy-hitting techniques you need to know, simplified:

1. Zero-Shot Prompting (The Direct Approach)

  • What it is: Asking the AI to do something straight up, without providing any examples or demonstrations. It relies entirely on what the AI already knows.

  • Use Cases: Ideal for straightforward tasks or when example data is unavailable. Common applications include simple Q&A, summarization, translation, classification, or fact retrieval where the AI likely already "knows" the procedure.

  • Examples:

    • Daily Work: "Summarize this long, messy email thread into three bullet points so I know what my boss wants me to do today."

    • Daily Living: "Translate this list of ingredients from a traditional Italian recipe website into English so I can buy them at the grocery store."

    • Daily Living/Work: "Extract the dates, times, and locations from this messy text message and format them so I can easily copy and paste them into my calendar."

2. Few-Shot Prompting (Leading by Example)

  • What it is: Showing the AI a "mini training set" of examples within your prompt before asking it to complete the actual task.

  • Use Cases: Shines when zero-shot prompting handles a task poorly or when you have example pairs illustrating the desired behavior. Specific uses include text classification with custom categories, format conversion, answering questions in a specific style, math problem-solving, or introducing new concepts by example.

  • Examples:

    • Daily Work: "Here are two examples of how I politely reply to angry customer emails: [Example 1], [Example 2]. Now, write a reply to this new angry customer complaint using the same empathetic tone."

    • Daily Living: "I like my grocery lists organized by supermarket aisle. For example: 'Apples -> Produce', 'Milk -> Dairy'. Now, categorize this messy list of 20 items for me."

    • Daily Work: "Turn this raw text of expenses into a neat CSV format. Example: 'Bought coffee for $4 on Tuesday' becomes 'Date, Category, Amount: Tuesday, Food, $4.00'. Now do the same for these receipts."

3. Chain-of-Thought (CoT) Prompting (Thinking Out Loud)

  • What it is: Forcing the AI to explain its reasoning step-by-step before giving the final answer. You can do this by literally adding the phrase, "Let's think step by step" to your prompt.

  • Use Cases: Particularly useful for complex problem-solving and any task where reasoning or logical deduction is needed. Common uses include multi-step math problems, logical puzzles, commonsense reasoning questions, complicated decision-making scenarios, and debugging a model's reasoning.

  • Examples:

    • Daily Work: "My office printer is flashing a red light and saying 'Error 404', but there's no paper jam. Let's think step by step to troubleshoot what could be wrong before I call IT."

    • Daily Living: "I am hosting a dinner party at 7:00 PM. The turkey takes 3 hours to cook, and needs to rest for 30 minutes. Let's think step by step backward from 7:00 PM to figure out exactly when I need to turn the oven on."

    • Daily Living: "I have a $2,500 budget for a 5-day trip to Japan. Let's work this out step by step: first deduct the estimated flight cost, then the hotel per night, and tell me what my daily food budget is."

4. Prompt Chaining (Divide and Conquer)

  • What it is: Instead of giving the AI one massive, overwhelming instruction, you break the task into a sequence of smaller prompts where the output of one feeds into the next.

  • Use Cases: Best used when a single prompt would be too unwieldy or when a task naturally breaks down into stages. Key uses include document Q&A or summarization, data transformation pipelines, complex reasoning (like generating hypotheses then evaluating them), and building LLM-powered agents that maintain state across turns.

  • Examples:

    • Daily Work (Presentations): * Prompt 1: "Extract the top 5 statistical wins from this 30-page quarterly report."

      • Prompt 2: "Now, turn those 5 stats into punchy, one-sentence bullet points for a PowerPoint slide."
    • Daily Living (Meal Prep):

      • Prompt 1: "Give me 5 healthy, high-protein dinner ideas that take under 30 minutes to make."

      • Prompt 2: "Great, now generate a consolidated grocery shopping list for those exact 5 meals."

    • Daily Work (Writing):

      • Prompt 1: "Write a structured outline for a blog post about time management."

      • Prompt 2: "Now, write just the introduction paragraph based on the first bullet point of that outline."

5. Meta-Prompting (The Blueprint Method)

  • What it is: Instead of giving the AI specific content examples, you give it a structural rule, template, or formula to follow.

  • Use Cases: Useful in scenarios where formatting and structure are crucial, allowing the model to generalize to new content following a pattern. Use cases include complex problem-solving described algorithmically (like algebra steps), code generation, formal logic, and evaluating model performance without the bias of specific examples.

  • Examples:

    • Daily Work: "Whenever you write a meeting recap for me, always use this blueprint: 1. [Decisions Made], 2. [Action Items with Assignees], 3. [Next Meeting Date]. Here are my messy notes from today's meeting; apply the blueprint."

    • Daily Living: "To create a good workout, always follow this formula: 10 minutes of dynamic stretching, 3 main lifting exercises (3 sets of 10 reps each), and 15 minutes of cardio. Build me a 'Leg Day' workout using this exact formula."

    • Daily Work: "When reviewing my code for errors, always output your feedback in this format: [Line Number], [Type of Error], [Suggested Fix]. Review this Python script."

6. Automatic Prompt Engineer (APE) (Letting the AI Do the Work)

  • What it is: Using the AI model to brainstorm, test, and score the best possible prompts for your specific task, rather than trying to guess the right words yourself.

  • Use Cases: Automating the trial-and-error process of prompt engineering. It is used to discover clever or unintuitive prompts that humans might miss, systematically boost task accuracy, and allow non-experts to get high-level results without deep prompt engineering knowledge.

  • Examples:

    • Daily Work: "I need to write a highly persuasive email to a cold sales lead, but I'm not getting good results. Give me 3 different, highly-effective prompts I could feed back to you to get the ultimate sales email."

    • Daily Living: "I want you to act as my tough-love fitness coach to keep me accountable to my diet. What is the absolute best prompt I can give you so that you take on this persona perfectly?"

    • Daily Work: "I have a massive spreadsheet of messy customer survey data. I want you to find hidden trends. What is the best prompt I can use to ask you to analyze this data?"

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