TetSharing
AI basics tutorial · 10 chapters
  1. What machine learning is
  2. Features and labels
  3. Train, test and validation data
  4. Overfitting
  5. Accuracy, precision, recall
  6. k-nearest neighbors
  7. LLMs, tokens and context
  8. Prompt basics
  9. Embeddings and similarity
  10. Responsible AI (NIST AI RMF)

Final AI basics quiz

Chapter 8 of 10 · By Ethan Cole · Updated November 21, 2026

Prompt Basics: Write Clear Instructions for an LLM

A prompt is the text you give a language model. Because the model continues text based on everything in its context, the quality of the prompt strongly shapes the quality of the answer. There is no secret phrasing; good prompts are simply clear instructions, the kind you would give a capable colleague who knows nothing about your situation.

Five ingredients

  1. Task: what you want, stated directly. "Summarize this bug report" beats "Thoughts?".
  2. Context: what the model cannot know: who the audience is, what the text is for, what has been tried.
  3. Constraints: length, tone, reading level, things to avoid.
  4. Output format: a bulleted list, a table, JSON with named fields. Saying exactly what you want is easier than cleaning it up later.
  5. Examples: one to three input/output pairs. This is called few-shot prompting, and it is often the fastest way to show a pattern that is hard to describe.

Put long material, such as an article to summarize, in a clearly marked block so the model can tell instructions from data.

Building prompts in code

Applications usually assemble prompts from a template plus data. The example builds a vague prompt and a structured one for the same job, then a few-shot prompt for classifying support tickets. It only prints the prompts; sending them to a model would need a provider's API and key.

Python 3 · editable

Expected output

=== vague (18 words)
Thoughts? Users report the app logs them out after 5 minutes on iOS 17. Started after release 2.3.

=== structured (56 words)
Task: Summarize the bug report below for a non-technical manager.
Context: The manager decides whether to delay the next release.
Constraints: 3 bullet points, plain English, no jargon.
Format: Start each bullet with "- ".

Bug report:
"""
Users report the app logs them out after 5 minutes on iOS 17. Started after release 2.3.
"""

=== few-shot (33 words)
Classify each support ticket as billing, bug or other.

Ticket: I was charged twice
Category: billing

Ticket: The app crashes on start
Category: bug

Ticket: How do I change my email address?
Category:

The structured prompt is longer, but every line removes a guess the model would otherwise have to make.

Iterate and check

  • Iterate: if the answer misses, ask what was ambiguous and fix the prompt, rather than piling on capital letters or "please".
  • Ask for reasoning or sources when you need to verify the answer, and then actually verify it.
  • Check everything that matters: facts, numbers, links and code. A confident tone is not evidence. Run generated code and tests before trusting them.

Safety basics

  • Do not paste secrets, passwords or personal data about other people into a prompt unless your organization's policy explicitly allows that service.
  • Text from outside sources (web pages, emails, uploaded files) can contain instructions of its own. Applications that feed such text to a model should treat it as data and limit what the model is allowed to do with it. This risk is known as prompt injection.

Summary

  • State the task, context, constraints and format; add examples for patterns.
  • Separate instructions from the material being processed.
  • Verify outputs, and keep secrets out of prompts.

Quiz: Prompt basics

1. What is few-shot prompting?

Examples show the model the pattern you want.

2. Which prompt is most likely to get a useful summary?

It states the task, the audience, the length and the format.

3. Why should text from web pages be treated carefully in a prompt?

This is prompt injection; treat outside text as data, not instructions.

Official docs

Written under the pen name Ethan Cole with AI-assisted drafting. Every code example on this page is executed by our test suite before publishing. Found a mistake? Tell us.