AI Literacy for Developers·A reliable AI workflow

Prompting with context and examples

Specific context, a clear task and an output shape outperform clever wording.

Beginner 13 min read Lesson 7 of 300 Challenge included
What you will be able to do
  • State the audience, goal, constraints and output format.
  • Provide the smallest context that contains the answer.
  • Ask for questions when the requirement is ambiguous.

In plain English

A useful prompt defines the role, the goal, the constraints and the expected format. Examples show the pattern you want. Ask for a plan before a large change, and ask the model to list assumptions it had to make.

structured-prompt.txtText
Role: senior JavaScript reviewer
Goal: find bugs in the function below
Constraints: no refactor suggestions yet; max 5 findings
Output: JSON array of {line, issue, severity, why}
If context is missing, ask before answering.

Function:
${code}
Your turn

Ask for assumptions

Easy

Add a requirement that the model list every assumption it made before giving a solution.

TEXT · starter
Solve this problem.
Check your understanding before moving on.
Knowledge checkQuestion 1

Which addition most improves a review prompt?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 7 of 300 · 0% of course