🧠 The Importance of System Prompts & Types of Prompting (with Examples)


In the world of AI and Large Language Models (LLMs) like ChatGPT, Gemini, or Claude, your prompt is your superpower.
A well-crafted prompt can be the difference between:
"Umm… not what I asked for" 😅
and
"Perfect! That’s exactly what I needed!" 🚀
One of the most overlooked yet critical aspects of prompt engineering is the system prompt — the invisible instruction that sets the AI’s personality, style, and behavior.
1️⃣ What Are System Prompts?
A system prompt is the hidden instruction that guides the AI's behavior before the user even types anything.
For example:
“You are a friendly assistant that explains technical concepts simply.”
“You are a sarcastic tech blogger with a sense of humor.”
Think of it like the director's note for an actor — the actor (AI) then delivers lines according to the role.
In OpenAI's API, a system prompt looks like this:
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
{
role: "system",
content: "You are an expert JavaScript tutor who explains with code examples."
},
{
role: "user",
content: "Explain closures in JavaScript."
}
]
});
console.log(response.choices[0].message.content);
💡 Pro tip: If your AI keeps drifting off-topic, tighten your system prompt.
2️⃣ Why Are System Prompts Important?
Control the AI's personality (formal, casual, witty, etc.)
Reduce irrelevant answers by setting boundaries
Ensure consistency across multiple responses
Boost reliability for production apps
Imagine building a customer support bot without a system prompt — one moment it’s polite, next moment it’s roasting your customers. 🙃
3️⃣ Types of Prompting (with Examples)
a) Zero-shot Prompting
You ask the AI to do something without giving examples — relies on the model’s general knowledge.
const prompt = "Summarize this text in one sentence: JavaScript is a high-level, versatile programming language...";
Pros:
Fast and simple
Good for straightforward tasks
Cons:
- Might miss your exact tone or format
b) Few-shot Prompting
You give the AI a few examples so it understands the style/output you want.
const prompt = `
Translate English to French:
English: Hello, how are you?
French: Bonjour, comment ça va?
English: I love programming.
French:
`;
Pros:
Higher accuracy for style-specific tasks
Great for classification, translation, formatting
Cons:
- Takes more tokens (cost + length)
c) Chain-of-Thought Prompting
You guide the AI’s reasoning step-by-step.
Example: Math reasoning
const prompt = `
Let's solve this step-by-step:
Question: If I have 5 apples and give 2 to John, how many do I have left?
Step 1:
`;
Pros:
Improves reasoning for complex problems
Helps avoid logic mistakes
Cons:
- May produce verbose answers unless told to summarize at the end
d) Role-based Prompting
You assign the AI a specific role.
const prompt = `
You are a cybersecurity analyst.
Analyze this suspicious log file and tell me possible threats.
Log: [data here]
`;
Pros:
Boosts realism for domain-specific tasks
Keeps tone consistent
e) Instruction + Context Prompting
You combine direct instructions with relevant data.
const prompt = `
Act as a SQL query generator.
Given the table 'users' with columns (id, name, email, created_at),
write a query to get users created in the last 30 days.
`;
4️⃣ Combining Techniques
In real-world apps, you often combine these methods.
Example: A customer support bot might use:
System Prompt for tone
Few-shot for formatting answers
Role-based for domain context
5️⃣ Final Tips for Better Prompts
Be explicit — the AI is not a mind reader.
Give constraints — e.g., “Answer in 3 bullet points.”
Iterate — test, tweak, and refine your prompts.
Use system prompts for global behavior.
Keep examples short but clear for Few-shot.
🎯 Conclusion
Prompting isn’t just typing a question — it’s designing a conversation.
System prompts lay the foundation, while Zero-shot, Few-shot, and other techniques help fine-tune responses for your exact needs.
If you treat your prompts like API requests — precise, consistent, and well-structured — your AI’s output will skyrocket in quality. 🚀
Subscribe to my newsletter
Read articles from Surendra singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
