Back to guides
4
5 min

System Prompts

Role, Rules & Output Control

The Three-Message Pattern

Modern LLM APIs use a structured message format with three roles:

[
  {"role": "system", "content": "You are a financial analyst..."},
  {"role": "user", "content": "Analyze this quarterly report..."},
  {"role": "assistant", "content": "Based on the Q3 data..."}
]
  • System — Sets identity, rules, and constraints. The model treats this as foundational context.
  • User — The human's input. Questions, data, instructions.
  • Assistant — The model's response. In multi-turn conversations, prior assistant messages provide continuity.
  • The system message is your most powerful lever. It runs before every user message and shapes the model's entire behavior.

    Anatomy of a System Prompt

    Effective system prompts have four sections:

    1. Role Assignment

    Tell the model who it is. Specific roles produce better output than generic ones.

    # Weak
    You are a helpful assistant.
    
    # Strong
    You are a senior data analyst at a Fortune 500 retail company. You specialize in customer behavior analytics and have 10 years of experience with SQL, Python, and Tableau.

    The specific role gives the model a frame of reference for tone, vocabulary, and depth of analysis.

    2. Behavioral Rules

    Define what the model should and should not do.

    ## Rules
    - Always cite specific data points when making claims
    - If data is insufficient for a conclusion, say so explicitly
    - Never fabricate statistics or percentages
    - Use business language, not technical jargon
    - Keep responses under 300 words unless asked for detail

    Negative rules ("never do X") are as important as positive ones. They prevent common failure modes.

    3. Output Format

    Specify exactly what the response should look like.

    ## Output Format
    Respond using this structure:
    1. **Summary** (2-3 sentences)
    2. **Key Findings** (bullet points)
    3. **Recommendation** (one paragraph)
    4. **Confidence Level** (High/Medium/Low with reasoning)

    4. Context & Constraints

    Provide domain knowledge the model needs.

    ## Context
    - Our fiscal year runs April–March
    - Revenue targets: Q1 $2.1M, Q2 $2.4M, Q3 $2.8M, Q4 $3.2M
    - "Enterprise" means deals over $100K ARR
    - The APAC region launched 6 months ago and is not expected to hit targets yet

    Putting It Together

    Here's a complete system prompt for a business use case:

    You are a customer support quality analyst for a B2B SaaS company. You review support tickets and agent responses to identify coaching opportunities.
    
    ## Rules
    - Evaluate agent responses on: accuracy, tone, resolution speed, and empathy
    - Score each dimension 1-5 with specific reasoning
    - Flag any compliance issues (data privacy, unauthorized discounts, SLA violations)
    - Be constructive — frame issues as coaching opportunities, not failures
    - If the agent handled something well, call it out specifically
    
    ## Output Format
    ### Ticket Summary
    [One sentence describing the customer issue]
    
    ### Agent Performance
    | Dimension | Score | Notes |
    |-----------|-------|-------|
    | Accuracy  | X/5   | ...   |
    | Tone      | X/5   | ...   |
    | Speed     | X/5   | ...   |
    | Empathy   | X/5   | ...   |
    
    ### Coaching Notes
    [1-3 specific, actionable suggestions]
    
    ### Compliance Flags
    [Any issues, or "None identified"]

    Common System Prompt Mistakes

    Too Vague

    # Bad: "Be helpful and accurate"
    # Good: "Always include the source data row number when referencing specific figures"

    Too Long

    System prompts over 2,000 words start to degrade performance. The model pays less attention to instructions buried deep in a wall of text. Put the most important rules first.

    Conflicting Instructions

    # Bad: "Be concise" + "Always explain your reasoning in detail"
    # Good: "Be concise in your conclusion. Show reasoning only when the user asks for it."

    No Output Format

    Without a format spec, the model picks its own structure — which changes between runs. Always define what the output looks like.

    Practice Tasks

  • Write a system prompt for an email triage assistant that classifies incoming emails from data/emails.json by urgency, department, and required action
  • Write a system prompt for a product review analyzer that processes data/reviews.json and outputs structured quality insights
  • Compare the same user query with two different system prompts — observe how the role changes the response
  • Key Takeaways

  • System prompts have four parts: role, rules, output format, and context.
  • Specific roles beat generic ones. "Senior data analyst at a retail company" > "helpful assistant."
  • Negative rules prevent common failures. Tell the model what NOT to do.
  • Always define output format. Without it, responses are inconsistent across runs.
  • Keep system prompts under 2,000 words. Put the most important rules first.
  • This is chapter 4 of Prompt Engineering Essentials.

    Get the full hands-on course — free during early access. Build the complete system. Your projects become your portfolio.

    View course details