Skip to main content
Great prompts produce consistent, high-quality results. This guide covers proven patterns for writing effective prompts in Endprompt.

Core Principles

Be Specific

Tell the model exactly what you want, step by step

Show, Don't Tell

Include examples of desired output

Constrain Output

Specify exact format, length, and structure

Handle Edge Cases

Tell the model what to do when things go wrong

Prompt Structure

A well-structured prompt typically includes:
[1. Role/Context]
You are a [specific role] with expertise in [domain].

[2. Task Definition]
Your task is to [specific action].

[3. Detailed Instructions]
Follow these steps:
1. First, do X
2. Then, do Y
3. Finally, do Z

[4. Input Data]
Here is the data to process:
{{ inputs.data }}

[5. Output Format]
Return your response as [format] with the following structure:
{
  "field1": "description",
  "field2": "description"
}

[6. Constraints]
- Do not include [unwanted things]
- Always include [required things]
- If [edge case], then [behavior]

Techniques

Few-Shot Learning

Provide examples to show the model what you want:
Classify the following customer feedback as positive, negative, or neutral.

Examples:
- "Great product, fast shipping!" → positive
- "Arrived broken, very disappointed" → negative
- "It works as described" → neutral

Now classify:
{{ inputs.feedback }}
3-5 examples is usually enough. More examples improve consistency but increase token usage.

Chain of Thought

Ask the model to reason step-by-step:
Analyze this investment opportunity. Think through it step by step:

1. First, identify the key financial metrics
2. Then, assess the market conditions
3. Next, evaluate the risks
4. Finally, provide your recommendation

Data:
{{ inputs.investment_data }}

Show your reasoning for each step before giving your final recommendation.

Role Assignment

Give the model a specific persona:
You are a senior software architect with 15 years of experience in distributed systems. 
You are known for giving practical, implementation-focused advice.
You always consider scalability, maintainability, and cost.

Review this system design and provide feedback:
{{ inputs.design }}

Negative Instructions

Tell the model what NOT to do:
Summarize this article.

Do NOT:
- Include your own opinions
- Add information not in the original
- Use marketing language
- Exceed 100 words

{{ inputs.article }}

JSON Output Patterns

Explicit Structure

Return your response as a JSON object with exactly these fields:
{
  "sentiment": "positive" | "negative" | "neutral",
  "confidence": 0.0 to 1.0,
  "keywords": ["array", "of", "strings"],
  "summary": "one sentence summary"
}

Return ONLY the JSON object, no additional text.

Error Handling in Output

If you cannot complete the analysis:
{
  "error": true,
  "reason": "explanation of why"
}

If successful:
{
  "error": false,
  "result": { ... }
}

Common Patterns

Classification

Classify the following text into exactly one category:
- Category A: [description]
- Category B: [description]
- Category C: [description]

Text: {{ inputs.text }}

Return: {"category": "selected_category", "confidence": 0.0-1.0}

Extraction

Extract the following information from the text:
- Person names (list)
- Dates mentioned (ISO format)
- Monetary amounts (with currency)
- Action items (list)

If a field has no matches, return an empty array.

Text: {{ inputs.text }}

Generation with Constraints

Write a {{ inputs.content_type }} about {{ inputs.topic }}.

Constraints:
- Length: {{ inputs.word_count | default: 200 }} words
- Tone: {{ inputs.tone | default: "professional" }}
- Audience: {{ inputs.audience | default: "general" }}
- Must include: {{ inputs.required_points | join: ", " }}
- Must avoid: {{ inputs.avoid_topics | join: ", " | default: "nothing specific" }}

Transformation

Rewrite the following text to:
- Use {{ inputs.reading_level | default: "8th grade" }} reading level
- Maintain the original meaning
- Be approximately the same length

Original:
{{ inputs.text }}

Temperature Guidelines

TaskTemperatureWhy
Classification0.0-0.2Consistent categories
Data extraction0.0-0.2Accurate parsing
Summarization0.2-0.4Consistent structure, some flexibility
Rewriting0.4-0.6Balance of faithful and fresh
Creative writing0.7-0.9Variety and creativity
Brainstorming0.8-1.0Maximum diversity

Testing Your Prompts

Run Multiple Times

Test the same input 5-10 times to check consistency:
  • With temperature 0, outputs should be nearly identical
  • Higher temperatures should vary within acceptable bounds

Test Edge Cases

Always test with:
  • Empty optional fields
  • Very long inputs
  • Unusual characters (emoji, unicode)
  • Inputs in different languages
  • Adversarial inputs (attempts to break the prompt)

Compare Models

Test with different models to find the best balance of:
  • Quality
  • Speed
  • Cost

Common Mistakes

❌ “Summarize the text” ✅ “Write a 3-sentence summary covering the main argument, key evidence, and conclusion”
❌ “Analyze the sentiment” ✅ Return JSON: {"sentiment": "positive"|"negative"|"neutral", "score": 0-1}
❌ “Extract the email address” ✅ Extract the email address. If none found, return {"email": null}
❌ 50 bullet points of instructions ✅ Clear, numbered steps with examples

Next Steps