System Prompt Builder & Engineering Guide

Select an archetype or build your prompt from scratch. The prompt will update below as you make changes.

Prompting Tips:

    This structures the entire system prompt you're building.

    Provide 1-3 clear input/output pairs. Few-shot examples significantly improve performance, especially for custom formats or nuanced tasks. Ensure examples are high-quality and accurately reflect the desired output.

    Generated System Prompt:

    Your generated prompt will appear here as you build it...

    Effective Prompt Engineering: A Cheatsheet

    Master the art of crafting prompts that get the best results from Large Language Models (LLMs).

    I. Foundational Principles (The Bedrock)

    A. Clarity and Specificity

    Your prompt must be unambiguous. The AI should know exactly what you want. State the goal directly.

    • Be explicit: Don't assume the AI knows implicit context.
    • Use action verbs: Clearly define the task (e.g., Summarize, Analyze, Generate, List, Translate).
    • Avoid jargon unless you're sure the AI knows it or you define it in the prompt.
    B. Provide Sufficient Context

    LLMs don't have memory of past separate conversations (unless using specific session features). Give all necessary background in the prompt.

    • Include relevant details, parameters, or constraints the AI needs to consider.
    • If referring to something specific, provide it (e.g., "Summarize the following text: [text here]").
    C. Define the Desired Output Format

    Tell the AI how you want its response structured. This greatly improves usability.

    • Examples:
      • Provide the answer as a JSON object with keys 'name' and 'capital'.
      • List the steps as a numbered list.
      • Write a 500-word blog post with an introduction, three main points, and a conclusion.
      • Use Markdown for formatting.
    • For complex tasks, specifying structured output (JSON, XML, YAML) is highly recommended for the AI's response.
    D. Assign a Persona/Role

    Instructing the AI to adopt a specific persona helps tailor the tone, style, and expertise level.

    • Examples:
      • You are a senior financial analyst.
      • Act as a travel guide for Paris, focusing on historical sites.
      • Respond as if you are a patient and encouraging high school science teacher.
    • Specify desired tone (e.g., formal, casual, witty, empathetic) and target audience.
    • Be specific about the persona's expertise level, background, and even disposition if relevant (e.g., 'You are a skeptical but fair journalist,' 'You are an encouraging mentor').

    II. Core Prompting Techniques

    A. Zero-Shot Prompting

    Asking the model to perform a task it hasn't been explicitly trained on with in-prompt examples for that specific task. Relies on generalization.

    Example: Translate the following English text to French: "Hello, how are you?"

    B. Few-Shot Prompting (In-Context Learning)

    Providing a few examples (input/output pairs) within the prompt to demonstrate the desired behavior, format, or style. Highly effective.

    Structure:
    User: [Example Input 1]
    AI: [Example Ideal Output 1]
    User: [Example Input 2]
    AI: [Example Ideal Output 2]
    User: [Actual Input for AI to process]
    AI:

    • Usually 1-5 examples are sufficient. Too many can exceed context length or confuse the model.
    • Ensure examples are high quality and accurately reflect the desired output.
    C. Chain-of-Thought (CoT) Prompting

    Guiding the AI to "think step by step" by providing examples where the reasoning process is explicitly laid out before the final answer. Significantly improves performance on tasks requiring reasoning (math, logic puzzles, complex Q&A).

    Example of a CoT example pair in a few-shot prompt:

    User: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?
    AI: Roger started with 5 balls. He bought 2 cans, and each can has 3 balls. So, he bought 2 * 3 = 6 more balls. In total, he now has 5 + 6 = 11 balls. The final answer is 11.

    You can also trigger CoT by adding phrases like "Let's think step by step." or "Break this down." to your prompt. Some models respond well to instructions like "Show your work."

    D. Self-Consistency

    For complex reasoning tasks where high accuracy is crucial, you can improve reliability by generating multiple responses to the same prompt (e.g., by increasing the model's "temperature" or randomness setting if available, or by slightly rephrasing the prompt). Then, select the most common answer or the one that appears most robust across several generations. This helps reduce the chance of an occasional flawed reasoning path.

    III. Advanced & Evolving Strategies

    A. Iterative Refinement & Experimentation

    Prompt engineering is an empirical science. Start simple and build up. Test, analyze the output, and refine your prompt. Small changes can have big impacts.

    • Keep a log of prompts and their results.
    • Try different phrasings, order of instructions, or levels of detail.
    B. Structuring Prompts with Delimiters/Tags

    Use clear separators (e.g., triple quotes """, XML tags like <instruction>...</instruction>, or Markdown headings ## Input Data) to distinguish instructions, context, examples, and input data. This is highly recommended as it significantly helps the AI parse the prompt effectively. Anthropic's Claude models, for instance, are specifically trained to pay attention to XML tags, making them particularly effective for structuring prompts for these models. Using distinct tags for different instruction types (e.g., <role>, <user_query>, <output_constraints>) is a best practice.

    <role_definition>
      You are a helpful assistant.
    </role_definition>
    
    <user_query>
      What's the capital of France?
    </user_query>
    
    <output_instructions>
      Respond concisely.
    </output_instructions>
    C. Breaking Down Complex Tasks (Prompt Chaining)

    Decompose very complex requests into smaller, manageable steps. The output of one prompt can become the input or context for the next (prompt chaining).

    D. Self-Refine Prompting

    Instruct the model to generate an initial response, then critically evaluate its own response for weaknesses (e.g., accuracy, completeness, clarity), and finally refine it before presenting the final answer. This can be done in a multi-turn conversation or within a complex single prompt.

    Example instruction: "First, write a draft answer. Then, review your draft for any inaccuracies or areas that could be explained more clearly. Finally, provide the revised and improved answer."

    E. Using a "Scratchpad" / Internal Monologue

    For complex reasoning, instruct the model to "think out loud" or use a scratchpad area (which you might instruct it to exclude from the final output). Some models benefit from being told to put intermediate thoughts in specific tags (e.g., <thinking>...</thinking> or <scratchpad>...</scratchpad>) and then explicitly tell it to exclude content within these tags from the final user-facing response.

    F. Retrieval Augmented Generation (RAG)

    Retrieval Augmented Generation (RAG) is a powerful technique where the LLM's knowledge is augmented by dynamically retrieving information from external sources (like a vector database of your documents, or a live API) before generating a response. While setting up a full RAG system is beyond simple prompting, you can simulate aspects of it by:

    • Providing specific context directly in the prompt (if it's short enough).
    • Instructing the AI to formulate queries it would use to find information if it had access to a search tool, then (if in an interactive setup) you can run those searches and provide the results back to the AI in a subsequent turn.
    • For models with built-in browsing/tool use, explicitly instructing them to search for specific information can be a form of RAG.
    This is key for tasks requiring up-to-date, domain-specific, or private knowledge not present in the model's training data.

    G. Understanding Context Window & Placement
    • Be mindful of the model's context window (max input length).
    • Experiment with instruction placement. Some models are more sensitive to instructions at the beginning, others at the end, especially with long contexts (e.g., Anthropic suggests important instructions can go at the end for Claude). It's often effective to place the most critical instruction or the primary task right before the user's input if providing few-shot examples or extensive context.
    H. Tree of Thoughts (ToT)

    An advanced technique where the model is prompted to explore multiple reasoning paths (like branches of a tree) for a problem. It can evaluate these different paths and choose the most promising one, or even backtrack if a path seems unhelpful. This is more complex to implement in a single prompt and often involves the LLM self-critiquing different lines of thought.

    I. ReAct (Reasoning and Acting)

    This framework enables LLMs to generate both reasoning traces (like Chain-of-Thought) and task-specific actions. These actions can include using tools (like a calculator or a search engine API) and then integrating the information gathered from these tools back into its reasoning process to arrive at a final answer. To implement this, you'd define the available tools and instruct the model on how it can decide to use them.

    J. Directional Stimulus Prompting (DSP)

    Instead of providing highly explicit instructions for every detail, DSP involves giving the model subtle "hints" or "cues" that gently steer it towards the desired output style, content focus, or level of detail. This can be useful for creative tasks where you want to guide the model without over-constraining it. For example, including a few keywords related to a specific theme can act as a directional stimulus.

    K. CLEAR Framework (Concise, Logical, Explicit, Adapt, Reflect)

    Some practitioners advocate for frameworks like CLEAR to structure their prompting approach systematically:

    • Concise: Be brief but comprehensive. Avoid verbosity.
    • Logical: Structure your prompt in a way that makes sense for the AI to process.
    • Explicit: Clearly state what you want, including format, persona, and constraints. Don't make the AI guess.
    • Adapt: Be prepared to iterate. If the first prompt doesn't work, analyze the output and adapt your prompt.
    • Reflect: After the interaction, consider what worked, what didn't, and why, to improve future prompts.

    IV. Key Considerations

    A. Ethical Considerations & Bias Mitigation

    Design prompts to avoid generating harmful, biased, or inaccurate information. Be aware that LLMs can reflect biases present in their training data.

    • Explicitly instruct against stereotypes or biased language if the topic is sensitive.
    • Ask for balanced perspectives.
    • If appropriate for the AI's role, instruct it to acknowledge uncertainty or the limitations of its knowledge, rather than generating speculative or potentially misleading information.
    B. Adapting to Model Updates

    LLMs are constantly evolving. Strategies that work well today might need adjustment as models are updated. Stay informed about best practices for the specific model you're using.

    Different models may have different strengths, weaknesses, and optimal prompting styles. What works best for GPT-4o might need slight adjustments for Claude 3.5 Sonnet or Gemini 1.5 Pro. Always refer to the latest documentation or guides provided by the AI lab for the specific model you are using.

    This guide is a starting point. The best way to learn is by experimenting!