Skip to main content
Lesson 4

Prompt Engineering & Working With AI

You've learned how LLMs process language. Now it's time to learn how to talk to them effectively. The quality of what you get out of an AI depends heavily on the quality of what you put in.

After this lesson, you'll be able to:

  • Apply zero-shot, few-shot, and chain-of-thought prompting techniques
  • Understand how system prompts shape AI behavior
  • Use temperature settings to control output creativity

What is Prompt Engineering?

Prompt engineering is the practice of crafting effective inputs (prompts) to get the best outputs from an LLM. It's not about tricking the AI — it's about communicating clearly so the model understands exactly what you need.

Think of it this way: if you asked a new coworker to "write something about our product," you'd get a very different result than if you said "write a 200-word product description for our homepage, targeting small business owners, in a friendly but professional tone." The same applies to AI.

Key Techniques

Zero-Shot Prompting
Ask the model directly with no examples. You rely entirely on the model's pre-trained knowledge to complete the task.
Example: "Summarize this article."
Few-Shot Prompting
Give the model a few examples of what you want before asking it to perform the task. This helps the model understand the pattern, format, and style you're looking for.
Example: "Here are 3 examples of good summaries. Now summarize this."
Chain-of-Thought Prompting
Ask the model to "think step by step" to improve its reasoning. This technique dramatically improves performance on math, logic, and complex problems.
Example: "Solve this math problem. Show your reasoning step by step."
System Prompts
Set the role, context, or behavioral guidelines for the model before the conversation begins. This shapes how the model responds throughout the entire interaction.
Example: "You are a helpful math tutor for 8th graders."

Temperature: Controlling Creativity

Temperature is a number (usually between 0 and 2) you set when you send a request to a model. It controls how predictable or random the output feels. The name is borrowed from physics — low temperature = frozen and orderly, high temperature = chaotic — and the same metaphor applies here: low values keep the output safe and repeatable, high values let the model take more risks with word choice.

Where do you actually set it? You won't find a temperature slider inside ChatGPT or Claude's chat apps — those companies pick a value for you. You'll see it when you use a developer "playground" tool (like OpenAI's Playground or Anthropic's Console) or when you call the model from code.

Temperature is a continuous slider, not a switch. The two cards below show the two ends of the dial; most real-world use sits somewhere in between.

Low Temperature (close to 0)

Deterministic & focused
Great for factual tasks, code generation, and consistent answers. The model picks the most likely word every time.

High Temperature (~0.8–1.5)

Creative & varied
Great for brainstorming, creative writing, and exploring diverse ideas. The model is more willing to pick words that aren't the top choice.

The accepted range varies by provider — OpenAI accepts 0 to 2, Anthropic 0 to 1. Pushed toward the upper end, the output starts to feel incoherent rather than creative.

Real-World Example: Prompt Engineering in Practice

Developers working with AI coding agents often keep a project-level file (commonly named CLAUDE.md) that acts as a persistent system prompt. It describes what the project is, what design rules to follow, and what tone to use — so every session starts with the right context instead of re-explaining everything from scratch.

The payoff is consistency: the AI produces code that matches the project's style because the rules are always in front of it. It's prompt engineering applied to a real workflow, not a one-off prompt trick.

Think of it this way: A system prompt is like onboarding a new team member. You don't explain the company, the project, and the coding standards every single time you assign a task — you give them a handbook once, and they reference it for everything they do.

Be specific. Instead of "write about dogs," try "write a 150-word paragraph about why golden retrievers make great family pets."

Provide context. Tell the model who the audience is, what the purpose is, and any constraints. The more context, the better the output.

Give examples. If you want a specific format or style, show the model what good output looks like (few-shot prompting).

Specify the format you want. Say "respond as a bulleted list," "use markdown," or "return JSON" — don't leave the format to chance.

Iterate and refine. Your first prompt rarely produces the perfect result. Treat it as a conversation — give feedback, adjust your prompt, and try again. Prompt engineering is an iterative process.

Key Takeaway

How you communicate with AI determines what you get back. Zero-shot, few-shot, and chain-of-thought are your core techniques. System prompts set the rules. Temperature controls creativity. Prompt engineering is an iterative skill, not a one-time trick.

Try This (Optional)

Take a recent prompt you've sent to ChatGPT or Claude and identify which technique it used (zero-shot, few-shot, chain-of-thought, or none of the above). Then rewrite it using a different technique and notice what shifts about the response — tone, structure, accuracy, or all three.

Knowledge Check

You want an AI to write a professional email, so you show it 3 examples of good professional emails first, then ask it to write one. What technique is this?

Correct! Providing examples before your request is the definition of few-shot prompting. The model learns the pattern from your examples and applies it.
Not quite. The key clue is that you're showing the model examples before asking it to perform the task. That's few-shot prompting.

When would you use a low temperature setting (close to 0)?

Correct! Low temperature makes the model more deterministic and focused — perfect for factual tasks where you want consistent, reliable answers.
Not quite. Low temperature (close to 0) makes the model more deterministic — it picks the most likely word each time. This is ideal for factual, consistent answers. High temperature is for creativity and randomness.