Skip to content
← Catalogue Modern Skills 200 level Created by AI

The Craft of Prompt Engineering: Getting the Best from AI

Professor: Sikh Archive · Source: Sikh Archive

A practical, plain-English guide to writing prompts that get great results from AI — clear instructions, context and examples, reasoning and constraints, fixing common failures, and adapting to chat, coding, and image tools.

Begin course 6 lessons · 8-question test · 80% to pass
Created by AI. Drafted with AI and reviewed for accuracy. Spotted an error? Tell us.

What you'll learn

  • Explain what a prompt is and why specific, clear instructions produce far better AI output than vague ones.
  • Use context, few-shot examples, and roles to give an AI everything it needs to do a task well.
  • Improve accuracy and usefulness by asking for step-by-step reasoning, setting constraints, and specifying the output format.
  • Recognize common AI failure modes such as hallucination and rambling, and apply fixes for each.
  • Iterate through follow-up messages and verify important facts before relying on the result.
  • Adapt your prompting style for chat, coding, and image tools to get the best from each.

Key terms — ਸ਼ਬਦਾਵਲੀ

TermAcademic context
PromptThe words you give an AI to tell it what you want; the quality of the output depends on the quality of the prompt.
ContextThe background information you provide, such as who you are, who the audience is, and the material to work with.
Few-shot promptingShowing the AI two or three examples of input and the matching output you want, so it copies the pattern.
Role (system prompt)Telling the AI who to act as, such as a patient tutor or strict editor, to set its tone and perspective.
Chain-of-thoughtAsking the AI to work through a problem step by step before answering, which improves accuracy on hard tasks.
ConstraintsThe rules you set for the answer, such as length limits, banned words, or required facts.
HallucinationWhen an AI confidently states made-up facts, fake quotes, or invented sources that are not true.
IteratingRefining the result through follow-up messages, telling the AI what to change until it matches what you want.

Lessons

1. What Prompting Really Is

Full course contents
  1. What Prompting Really Is
  2. Context, Examples, and Roles
  3. Reasoning, Constraints, and Format
  4. Iterating and Fixing Failures
  5. Prompting Different Tools
  6. Putting It All Together

A prompt is an instruction

A prompt is simply the words you give an AI to tell it what you want. The AI does not read your mind. It reads your text, then predicts a helpful continuation. So the quality of what comes back depends almost entirely on the quality of what you put in.

Think of it like talking to a very fast, very well-read new coworker who has never met you, knows nothing about your project, and will take you completely literally. If your request is vague, you get a vague answer. If your request is clear and specific, you usually get something useful on the first try.

Vague in, vague out

Compare these two requests. The first is what most people type. The second is what an experienced user types.

Weak promptStrong prompt
Write about dogs.Write a friendly 150-word paragraph for a pet-shelter website explaining why adopting an older dog is rewarding. Warm tone, no bullet points.
Fix my email.Rewrite this email to a customer so it stays polite but firmly declines a refund. Keep it under 5 sentences. Here is the email: ...

The strong prompts win because they say who it is for, how long it should be, what tone to use, and what to avoid. None of that is technical. It is just being specific.

The core habit

Before you hit send, ask yourself: have I said what I want, who it is for, how long it should be, and what 'good' looks like? If you can answer those, you are already prompting well. Everything else in this course is just sharpening that one habit.

References
  • OpenAI. GPT-4 and prompting guidance in the OpenAI API documentation (platform.openai.com).
  • Anthropic. Prompt engineering guide in the Claude documentation (docs.anthropic.com).
  • Google. Prompting guidance for Gemini in Google AI for Developers (ai.google.dev).
  • Brown, Tom, et al. "Language Models are Few-Shot Learners." NeurIPS, 2020.
  • Wei, Jason, et al. "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." NeurIPS, 2022.

2. Context, Examples, and Roles

Give it the background

The AI only knows what you tell it in the conversation. Context is the background it needs to do the job: who you are, who the audience is, the goal, and any facts it cannot guess. Pasting the relevant document, the rules, or the prior draft directly into the prompt almost always beats describing it from memory.

A good pattern is: state the situation, paste the material, then ask the question. For example: 'I run a small bakery. Here is our current menu (pasted below). Suggest three new seasonal items that fit our style.'

Show, don't just tell: few-shot examples

One of the most powerful tricks is giving examples of what you want. Showing the AI two or three sample inputs and the matching outputs you would have written is called few-shot prompting. The AI copies the pattern. This is far more reliable than describing the pattern in words.

For instance, if you want product names rewritten in a punchy style, show it: 'Plain: Blue cotton t-shirt → Punchy: The Everyday Blue Tee.' After two or three of those, it will match your style on the rest.

Set a role

You can also tell the AI who to be. A role or system prompt frames its perspective: 'You are a patient math tutor for a 10-year-old' produces very different output than 'You are a strict academic editor.' The role shapes vocabulary, tone, and what it pays attention to.

TechniqueWhat it addsBest for
ContextThe facts and backgroundAny task needing your specific information
Few-shot examplesThe exact pattern to copyConsistent formatting, style, or classification
Role / system promptA point of view and toneTutoring, editing, customer support, persona work

Combine all three and the AI has what it needs to behave like a true expert collaborator rather than a generic search box.

References
  • OpenAI. GPT-4 and prompting guidance in the OpenAI API documentation (platform.openai.com).
  • Anthropic. Prompt engineering guide in the Claude documentation (docs.anthropic.com).
  • Google. Prompting guidance for Gemini in Google AI for Developers (ai.google.dev).
  • Brown, Tom, et al. "Language Models are Few-Shot Learners." NeurIPS, 2020.
  • Wei, Jason, et al. "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." NeurIPS, 2022.

3. Reasoning, Constraints, and Format

Ask for the thinking

For anything involving logic, math, or multiple steps, tell the AI to work step by step before giving its final answer. This is called chain-of-thought prompting. When the model writes out its reasoning, it makes fewer mistakes, and you can spot where it went wrong.

A simple phrase like 'Think through this step by step, then give your final answer' often turns a wrong answer into a right one. For word problems, planning, or comparisons, it is one of the highest-value additions you can make.

Give it boundaries

Constraints tell the AI what it must and must not do. Length limits, banned words, required facts, tone rules, reading level: all of these narrow the output toward what you actually want. Positive constraints ('use simple words a beginner understands') tend to work better than negative ones, but both help.

Specify the format

If you need the answer in a particular shape, say so exactly. Ask for a numbered list, a table, JSON, a single sentence, or a markdown heading. AI is good at following format instructions, but only if you give them. 'Return your answer as a table with columns Name, Pros, Cons' will get you a clean table every time.

You wantAdd this to your prompt
Careful reasoning"Work through it step by step before answering."
A short answer"Answer in one sentence, under 25 words."
Structured output"Return a table with columns X, Y, Z."
Safe boundaries"Do not invent facts; if unsure, say so."

Reasoning, constraints, and format work together: the reasoning improves accuracy, the constraints keep it on task, and the format makes the result easy to use.

References
  • OpenAI. GPT-4 and prompting guidance in the OpenAI API documentation (platform.openai.com).
  • Anthropic. Prompt engineering guide in the Claude documentation (docs.anthropic.com).
  • Google. Prompting guidance for Gemini in Google AI for Developers (ai.google.dev).
  • Brown, Tom, et al. "Language Models are Few-Shot Learners." NeurIPS, 2020.
  • Wei, Jason, et al. "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." NeurIPS, 2022.

4. Iterating and Fixing Failures

Treat it as a conversation

You rarely get the perfect result on the first try, and that is fine. The real skill is iterating: read what came back, tell the AI what to change, and let it revise. 'Good, but make it shorter and warmer' is a perfectly valid next message. Each round narrows in on what you want.

Save prompts that work well. Once you find wording that reliably produces good output, reuse it as a template and just swap in the new details.

Common failure modes

AI fails in predictable ways. Knowing the patterns lets you fix them quickly.

FailureWhat it looks likeHow to fix it
HallucinationConfident made-up facts, fake quotes, invented sourcesProvide the source material; ask it to only use what you gave and to say "I don't know" when unsure
Too vagueGeneric, surface-level answerAdd context, audience, and a concrete example of good output
Ignored instructionsWrong length or format despite askingPut key rules at the end, number them, and keep the prompt focused
Overlong / ramblingPadding, repetition, restating the questionSet a strict length limit and say "no preamble, answer directly"
Refusal or hedgingExcessive caveats or declining a safe taskClarify the legitimate purpose and rephrase plainly

Always verify

The most important rule of all: check the output. AI is a fast, fluent assistant, not an oracle. For facts, names, numbers, dates, and anything that matters, confirm against a trustworthy source before you rely on it. Used this way, iteration plus verification gives you both speed and accuracy.

References
  • OpenAI. GPT-4 and prompting guidance in the OpenAI API documentation (platform.openai.com).
  • Anthropic. Prompt engineering guide in the Claude documentation (docs.anthropic.com).
  • Google. Prompting guidance for Gemini in Google AI for Developers (ai.google.dev).
  • Brown, Tom, et al. "Language Models are Few-Shot Learners." NeurIPS, 2020.
  • Wei, Jason, et al. "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." NeurIPS, 2022.

5. Prompting Different Tools

The tool shapes the prompt

The same core skills apply everywhere, but each kind of AI tool rewards a slightly different style of prompt. Knowing the differences saves you a lot of frustration.

Chat assistants

For everyday chat (writing, summarizing, explaining, brainstorming), lead with context and a clear goal, then iterate in the conversation. Paste the material you are working with. Ask follow-up questions freely; the assistant remembers the thread.

Coding tools

For coding assistants, be precise about the language, the framework, the inputs and outputs, and any constraints. Paste the actual error message and the relevant code. Ask it to explain its plan before writing, and to handle edge cases. Then run the code and feed back what happened; debugging is a loop.

Image generators

For image tools, describe the subject, the style, the composition, the lighting, and the mood, roughly in that order. 'A watercolor painting of a quiet mountain village at dawn, soft pastel light, wide landscape view' beats 'a village.' Generate, then refine: change one thing at a time so you can see what each word does.

Tool typeLead withWatch out for
ChatContext, goal, audienceVagueness; not pasting source material
CodingLanguage, inputs/outputs, the error textSkipping constraints and edge cases
ImageSubject, style, composition, lightingChanging too many things at once

One caution that crosses all tools: when working with cultural, historical, or sacred subjects, AI can confidently get details wrong. Verify before you share anything that represents a community or tradition.

References
  • OpenAI. GPT-4 and prompting guidance in the OpenAI API documentation (platform.openai.com).
  • Anthropic. Prompt engineering guide in the Claude documentation (docs.anthropic.com).
  • Google. Prompting guidance for Gemini in Google AI for Developers (ai.google.dev).
  • Brown, Tom, et al. "Language Models are Few-Shot Learners." NeurIPS, 2020.
  • Wei, Jason, et al. "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." NeurIPS, 2022.

6. Putting It All Together

A simple recipe

You now have all the pieces. Here is a reliable order to assemble them into one strong prompt. You will not need every part every time, but this checklist covers the vast majority of tasks.

StepWhat to write
1. RoleWho the AI should act as
2. ContextThe background and any pasted material
3. TaskThe specific thing you want done
4. ExamplesOne or two samples of good output, if style matters
5. ConstraintsLength, tone, things to avoid
6. FormatThe exact shape of the answer

A worked example

'You are a friendly community newsletter editor. Our gurdwara is hosting a free langar and blood drive on Saturday. Write a short announcement for our members. Keep it warm and welcoming, under 120 words, no jargon. End with the date, time, and a one-line call to action.' Notice how it quietly uses role, context, task, constraints, and format all at once.

Keep practicing

Prompting is a craft you improve by doing. Start with a clear request, read the result honestly, refine, and verify the facts. Save the prompts that work. Over a few weeks these moves become automatic, and you will get noticeably better results than someone typing one-line questions into the same tools.

The goal is not clever tricks. It is clear thinking, written down. If you can explain what you want to a smart human, you can prompt an AI well.

References
  • OpenAI. GPT-4 and prompting guidance in the OpenAI API documentation (platform.openai.com).
  • Anthropic. Prompt engineering guide in the Claude documentation (docs.anthropic.com).
  • Google. Prompting guidance for Gemini in Google AI for Developers (ai.google.dev).
  • Brown, Tom, et al. "Language Models are Few-Shot Learners." NeurIPS, 2020.
  • Wei, Jason, et al. "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." NeurIPS, 2022.

Course test

Pass with 80% or higher to complete the course and unlock the next one.

1. What is the single biggest factor in the quality of an AI's answer?
2. Why does giving two or three examples (few-shot) work so well?
3. What does a 'role' or system prompt do?
4. For a multi-step math or logic problem, what helps most?
5. If you need the answer as a clean table, what should you do?
6. What is a 'hallucination' in AI output?
7. What is the best response when the first answer is close but not quite right?
8. When prompting an image generator, which order works best?

References & further reading

  1. OpenAI. GPT-4 and prompting guidance in the OpenAI API documentation (platform.openai.com).
  2. Anthropic. Prompt engineering guide in the Claude documentation (docs.anthropic.com).
  3. Google. Prompting guidance for Gemini in Google AI for Developers (ai.google.dev).
  4. Brown, Tom, et al. "Language Models are Few-Shot Learners." NeurIPS, 2020.
  5. Wei, Jason, et al. "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." NeurIPS, 2022.

Read the source texts

Read the primary sources for yourself — the Gurbani in our read-along reader, and the original works in the source library.

Rate this course

Discussion & Q&A

Sign in to post.