Lesson 814 lessons

System Prompt Engineering

What is a system prompt and why it matters

A system prompt is an invisible instruction that runs before every conversation. It's the DNA of an AI assistant — it defines who the AI is, how it behaves, what it knows about its context, and what it should never do.


When you use ChatGPT or Claude normally, you're using a system prompt that Anthropic or OpenAI wrote. When you build your own AI product, you write the system prompt that shapes your AI's identity.


System prompts are powerful because:

- They persist across every message in a conversation (the user can't override them easily)

- They define the AI's persona, tone, and expertise

- They inject context the AI needs (company info, product knowledge, user data)

- They set guardrails — what the AI should always or never do


Mastering system prompt engineering means you can build AI assistants that feel purpose-built, not generic.

The anatomy of a great system prompt

A production-quality system prompt has six components:


1. Identity — Who the AI is. Name, role, personality traits.

You are Layla, a friendly Arabic-first customer support agent for Souq Digital.


2. Expertise — What the AI knows.

You are an expert in e-commerce, shipping logistics in the GCC region, and our product catalog.


3. Tone and style — How it communicates.

Always respond in the same language the user writes in (Arabic or English). Be warm, concise, and solution-focused.


4. Context and knowledge — What it knows about the business.

Our return policy: 14 days, free return shipping, refund to original payment method within 3 business days.


5. Guardrails — What it must always or never do.

Never discuss competitor products. If asked about pricing not in your catalog, say 'I'll connect you with our sales team.'


6. Output format — How responses should look.

Keep responses under 150 words. Use bullet points for lists of steps. Always end with 'Is there anything else I can help with?'

System prompt patterns for common AI products

Different AI products need different system prompt architectures:


Customer Support Bot:

Focus on: company knowledge injection, escalation rules, tone matching, language detection. Key guardrail: 'If you don't know, say so and offer to connect the user with a human agent.'


Content Generator:

Focus on: brand voice definition, format templates, audience profile, what to avoid. Key element: example outputs that demonstrate the desired style.


Research Assistant:

Focus on: domain expertise declaration, citation behavior ('always note when you're uncertain'), structured output format. Key guardrail: 'Never state uncertain information as fact.'


Onboarding Guide:

Focus on: product knowledge, user goal detection, progressive disclosure (don't overwhelm), celebration of small wins. Key behavior: 'When a user completes a step, acknowledge it and tell them what's next.'


Each archetype has a different emphasis — matching your system prompt to the product type is the first decision.

Testing and iterating system prompts

System prompts are never done on the first version. Build an iteration process:


Red-teaming your system prompt:

After writing it, try to break it. Ask the AI things it shouldn't answer. Push its persona. Try edge cases. A system prompt that fails red-teaming will fail with real users.


The 10-question test:

Write 10 diverse test questions that real users might ask — including edge cases, out-of-scope requests, and ambiguous queries. The system prompt should handle all 10 gracefully.


Regression testing:

When you update a system prompt, re-run all previous test cases. System prompt changes often fix one thing and break another unexpectedly.


Version control for system prompts:

Treat your system prompt like code. Store versions with dates. Note what each version changed and why. When something breaks in production, you can roll back to the last good version.

Key Takeaways

  • System prompts are the persistent instructions that define an AI assistant's identity, knowledge, tone, and guardrails.
  • A great system prompt has six components: Identity, Expertise, Tone, Context/Knowledge, Guardrails, and Output Format.
  • Different AI product types (support bot, content generator, research assistant) need different system prompt architectures.
  • Treat system prompts like code: red-team them, test with 10 diverse cases, version control, and regression test on every update.

Build a system prompt for your AI product idea

Design a system prompt for an AI assistant that would be genuinely useful in your business or community. Cover all 6 components: Identity, Expertise, Tone, Context, Guardrails, and Output Format. Then red-team it: write 5 tricky questions and see if the AI handles them correctly.

System prompt for an Arabic business coach AI: You are Rakan, a friendly Arabic-speaking business coach specializing in helping early-stage entrepreneurs in the Arab world validate and launch their ideas. Expertise: lean startup methodology, GCC market dynamics, bootstrapping, social media marketing, basic financial modeling. Tone: warm, encouraging, practical. Respond in Arabic unless the user writes in English. Use simple language — avoid jargon. Guardrails: Never promise specific financial outcomes. If asked for legal or accounting advice, refer to a professional. Don't compare the user's idea to a competitor negatively. Output format: Keep responses under 200 words. Use numbered steps for action items. End with one specific question to help the user think deeper.