The Importance of System Prompts and Types of Prompting in AI (with Code Examples)

Day 2 of the GenAI with JS cohort with Hitesh Choudhary sir and Piyush Garg sir was one of those “Ok… now we’re cooking!” kind of days.
Yesterday was about understanding how AI thinks.
Today was about making it think — and not just think once, but keep thinking until it’s sure.
We explored how a simple tweak in how you talk to AI can turn it from a quick, one-shot answer machine into a patient, step-by-step problem solver. This is where system prompts and different prompting techniques (like zero-shot, few-shot, and chain-of-thought) come in.
And yes, we even made the AI answer questions about cricket, Indian history, and Bollywood — because why not?
1. What is a System Prompt?
A system prompt is like a “hidden instruction manual” you give your AI before the conversation even starts.
It sets the tone, behavior, and role of the AI.
Think of it as telling your auto-rickshaw driver:
"Bhaiya, seedha India Gate, meter se chalao, aur radio pe Kishore Kumar lagao."
Once you say this, you don’t have to repeat it every 2 minutes — the driver already knows the plan.
Example: Setting a system prompt in JavaScript
import OpenAI from "openai";
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
async function run() {
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "system", content: "You are a polite Delhi tour guide who loves Bollywood trivia." },
{ role: "user", content: "Suggest 3 must-visit places in Delhi with a Bollywood reference." }
]
});
console.log(response.choices[0].message.content);
}
run();
2. Types of Prompting
a) Zero-Shot Prompting
No examples given — just ask directly.
const messages = [
{ role: "system", content: "You are a cricket commentator." },
{ role: "user", content: "Who won the 2011 Cricket World Cup?" }
];
// Output: "India won the 2011 Cricket World Cup by defeating Sri Lanka in the final."
b) Few-Shot Prompting
Provide a few examples so the AI understands the format.
const messages = [
{ role: "system", content: "You answer in Hinglish and give funny Bollywood-style nicknames." },
{ role: "user", content: "Sachin Tendulkar" },
{ role: "assistant", content: "Master Blaster" },
{ role: "user", content: "Virat Kohli" }
];
// Output: "King Kohli"
c) Chain-of-Thought Prompting
Ask the AI to think step-by-step.
const messages = [
{ role: "system", content: "You are a math teacher from India." },
{ role: "user", content: "If a train leaves Delhi at 6 AM at 60 km/h and another from Jaipur at 7 AM at 80 km/h, when will they meet?" },
{ role: "assistant", content: "Let's solve step-by-step..." }
];
// Output: AI breaks down the time difference, speeds, and calculates meeting time.
3. Why This Matters
Once you master prompts:
AI becomes your junior developer (or cricket expert, or Bollywood critic).
You control the style, accuracy, and format.
You can build tools that feel Indian in flavor and context for your audience.
Quick Recap
System prompt = AI’s personality and role.
Zero-shot = Ask directly.
Few-shot = Give examples first.
Chain-of-thought = Force step-by-step reasoning.
If you enjoyed this, just imagine tomorrow — we might make the AI write a full IPL commentary in Harsha Bhogle style.
Subscribe to my newsletter
Read articles from Aman Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
